Deploying the application
$ kubectl apply -f deployment.yaml -f service.yaml
- The kubectl tool sends the deployment and service definitions to the Kubernetes API server. This central control plane processes the apply request.
- The API server then persists the deployment and service objects into etcd (the cluster database). This makes our desired state of running the containerized application part of the current known cluster state. The Kubernetes controllers notice the new deployment and service have been created. The controllers manage reconciling actual vs desired state.
- So the deployment controller spins up pods on the cluster nodes to match the pod template from the deployment YAML. It spreads them across nodes for high availability.
- The service controller allocates a cluster IP and configures network routing to map traffic from that IP to the pods. This makes the application accessible internally. Finally, the kube-proxy component on each node handles forwarding application requests arriving at the service IP to the backs the pods based on updated iptables rules.
- So in summary, kubectl apply triggers persistent storage of our state definitions, which the control plane work to reconcile towards that goal state, configuring fundamental resources like pods and networking. The cluster works to match reality to the desired state we specificed in the YAMLs!
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!