Kubernetes: Deployments and Services

Deployments

You create a Deployment object with a desired state. A Deployment controller changes the actual state to the desired state at a controlled rate.

https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

Deployments (updates and rollbacks) wrap around Replication Controllers (actually for Deployments a Replica Set – Scalability, reliability, desired state) which wrap around Pods.

 

Old way of deploying:

Use Replication Controller and do:

kubectl rolling-update -f updated-rc.yml

but now handled by the control plane:

YAML -> apiserver -> deployed to cluster

To change, update YAML and push to apiserver. This then creates a new Replica Set.

Note: the old Replica Set remains. Which makes it easy to rollback.

 

New way:

Declaratively, with a manifest. E.g.

Note the relevant bits are:

Handy commands:

Note: I’m aliasing kubectl -> k

 

 

Services

A Kubernetes Service defines Pods and a policy – aka a micro-service.

Note: the set of Pods targetted by a Service is usually done using a Label Selector.

https://kubernetes.io/docs/concepts/services-networking/service/

 

Note: you can create a Service at the same time you create a Deployment by using
--expose in kubectl. E.g.

kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080

Service Types

ClusterIP: internal IP only available in cluster

NodePort: usually used as a Cluster wide point of access for a LoadBalancer.

LoadBalancer:

Visually: https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0

https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types

 

Leave a Reply

Your email address will not be published. Required fields are marked *