Kubernetes Manifests
The Kubernetes deployment and service YAML definitions are key to actually running our containerized application on the cluster:
Deployment:
The Deployment resource defines the desired state for running our app:
- selector and labels map deployment to pods using app: hello-world labels
- spec.template defines the pod structure and container to run
- image: myaccount/hello-world:v1 tells each pod to run our container image
- ports expose 3000 inside container to cluster networking
This deployment lets Kubernetes know how to run and distribute our application as pods across nodes.
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: myaccount/hello-world:v1
ports:
- containerPort: 3000
Service:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: myaccount/hello-world:v1
ports:
- containerPort: 3000
The Service provides networking for accessing the deployment:
- selector targets deployment pods with app: hello-world labels
- Creates single access point to pods for hello-world app
- targetPort: 3000 directs traffic internally across pods
- port: 80 is where external requests are received for the app
So the Service exposes and load balances traffic to our deployment. It gives reliable networking for the app. Together, the manifests package up the “what and how” for Kubernetes to make our container image run application pods accessible to users
Rolling Updates and Rollbacks in Kubernetes: Managing Application Updates
Many websites and apps now run on clusters of computers called containers. Containers let apps run smoothly as groups work on updating and improving the software behind the apps. A system called Kubernetes helps manage and update all those containerized apps. Sometimes app updates go wrong or cause problems for users. Kubernetes has clever ways to update apps that avoid issues.
The main method is called a rolling update. This slowly switches the software behind the scenes from an old version to a new one. A few containers at a time are updated to the new software. Kubernetes checks that each small batch works fine before updating more. This means no downtime for users! Another useful capability is rollbacks. If a new software version causes glitches, Kubernetes can automatically revert to the previous stable version. There is no need for websites to crash or stay broken!