Trying out a sample Deployment
Let’s see how we can do the following:
- Deploy a simple web server based on NGINX in our Kubernetes cluster
- Apply some changes to the Deployment:
- Change the current state by deleting the Pod and verify that the
ReplicaSet
creates a new one - Change the desired state by scaling the web server to three Pods and verify that the
ReplicaSet
fills the gap by starting up two new Pods
- Change the current state by deleting the Pod and verify that the
- Route external traffic to the web server using a Service with a node port
First, create a namespace, first-attempts
, and update the kubectl
context to use this namespace by default:
kubectl create namespace first-attempts
kubectl config set-context $(kubectl config current-context) --namespace=first-attempts
We can now create a Deployment of NGINX in the namespace using the kubernetes/first-attempts/nginx-deployment.yaml
file. This file looks as follows:
apiVersion: apps/v1
kind: Deployment
metadata...