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:
- Delete a pod and verify that the ReplicaSet creates a new one.
- Scale the web server to three pods to verify that the ReplicaSet fills the gap.
- Route external traffic to it 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:
name: nginx-deploy
spec:
replicas: 1
selector...