Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The DevOps 2.3 Toolkit

You're reading from   The DevOps 2.3 Toolkit Kubernetes: Deploying and managing highly-available and fault-tolerant applications at scale

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781789135503
Length 418 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Viktor Farcic Viktor Farcic
Author Profile Icon Viktor Farcic
Viktor Farcic
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. How Did We Get Here? FREE CHAPTER 2. Running Kubernetes Cluster Locally 3. Creating Pods 4. Scaling Pods With ReplicaSets 5. Using Services to Enable Communication between Pods 6. Deploying Releases with Zero-Downtime 7. Using Ingress to Forward Traffic 8. Using Volumes to Access Host's File System 9. Using ConfigMaps to Inject Configuration Files 10. Using Secrets to Hide Confidential Information 11. Dividing a Cluster into Namespaces 12. Securing Kubernetes Clusters 13. Managing Resources 14. Creating a Production-Ready Kubernetes Cluster 15. Persisting State 16. The End 17. Other Books You May Enjoy

Discovering Services

Services can be discovered through two principal modes; environment variables and DNS.

Every Pod gets environment variables for each of the active Services. They are provided in the same format as what Docker links expect, as well with the simpler Kubernetes-specific syntax.

Let's take a look at the environment variables available in one of the Pods we're running.

POD_NAME=$(kubectl get pod \
    --no-headers \
    -o=custom-columns=NAME:.metadata.name \
    -l type=api,service=go-demo-2 \
    | tail -1)
    
kubectl exec $POD_NAME env  

The output, limited to the environment variables related to the go-demo-2-db service, is as follows:

GO_DEMO_2_DB_PORT=tcp://10.0.0.250:27017
GO_DEMO_2_DB_PORT_27017_TCP_ADDR=10.0.0.250
GO_DEMO_2_DB_PORT_27017_TCP_PROTO=tcp
GO_DEMO_2_DB_PORT_27017_TCP_PORT=27017
GO_DEMO_2_DB_PORT_27017_TCP=tcp://10.0.0.250:27017...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime