Kubernetes: Deployments and Services


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


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




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.



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.


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



Leave a Reply

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