my net house

WAHEGURU….!

RUn Nginx in Kubernetes (Deployment and Scaling replicas) Part-2

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

Take above yaml file as an example.

Now run Following command to create Deployment.

kubectl create -f nginx-depoy.yaml

Ways to check your pod has been Created or not.

khangura@metal-machine:~$ kubectl get pod

NAME READY STATUS RESTARTS AGE
hello-minikube-6ddfcc9757-k7qqv 1/1 Running 0 24h
nginx-deployment-5d59d67564-57sk7 1/1 Running 0 2m3s
nginx-deployment-5d59d67564-6d9t8 1/1 Running 0 2m3s
nginx-deployment-5d59d67564-bpsrj 1/1 Running 0 2m3s

We can always Update the deployment like increase/scale number of replicas.

Use following to update the Deployment.

kubectl edit deployment nginx-deployment # it will use our basic editor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: