46

kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 2: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 3: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 4: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 5: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 6: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 7: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

STEPS TO CREATE PODSCreate a Sample Pod i.e file with pod.ymlapiVersion: v1kind: Podmetadata:name: hello-pod

spec:containers:- name: hello-ctr

image: jenkinsports:- containerPort: 8080

Page 8: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

STEPS TO CREATE PODSExecute the following commands● kubectl get nodes● kubectl create -f pod.yml● kubectl get pods● kubectl describe pods● kubectl get pods -o wide● kubectl get pods/hello-pod● kubectl get pods --all-namespaces● kubectl delete pods/hello-pod

Page 9: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

STEPS TO CREATE REPLICATION CONTROLLERWrite a manifest with rc.yml (any name) with followint contentapiVersion: v1kind: ReplicationControllermetadata:name: hello-rc

spec:replicas: 10selector:

app: hello-worldtemplate:

metadata:labels:app: hello-worldspec:containers:- name: hello-ctrimage: jenkinsports:- containerPort: 8080

Page 10: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

STEPS TO CREATE REPLICATION CONTROLLERExecute following commandskubectl create -f rc.ymlkubectl get rc -o widekubectl describe rckubectl apply -f rc.ymlkubectl get rckubectl get pods

Refer: https://coreos.com/kubernetes/docs/latest/replication-controller.html

Page 11: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 12: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 13: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 14: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 15: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 16: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 17: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 18: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 19: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 20: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 21: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 22: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 23: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 24: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 25: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 26: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 27: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 28: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

Creating SERVICECreate the svc.yml file with following contentapiVersion: v1kind: Servicemetadata:name: hello-svclabels:

app: nginxspec:type: NodePortports:- port: 80

nodePort: 30001protocol: TCP

selector:app: nginx

Page 29: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

Creating SERVICEEnsure you give name of app “kubectl describe pods | grep app”### The following command deploys a new Service from the "svc.yml". The YAML

file is shown at the bottom of this document$ kubectl create -f svc.yml

### The following commands list all running Services and then describe the Service called "hello-svc"

$ kubectl get svc$ kubectl describe svc hello-svc

### The following commands list all Endpoint objects on the cluster and then describes the Endpoint object called "hello-svc"

kubectl get epkubectl describe ep hello-svc

Page 30: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 31: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 32: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 33: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 34: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 35: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 36: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 37: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 38: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 39: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 40: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 41: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:
Page 42: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

CREATING DEPLOYMENTCreate deploy.yml with following contentapiVersion: extensions/v1beta1kind: Deploymentmetadata:name: jenkins-deploy

spec:replicas: 2minReadySeconds: 2strategy:

type: RollingUpdaterollingUpdate:maxUnavailable: 1maxSurge: 1

template:metadata:labels:app: jenkinsspec:containers:- name: jenkins-podimage: jenkinsports:- containerPort: 8080

Page 43: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

CREATING DEPLOYMENTkubectl create -f deploy.yml

kubectl describe deploy jenkins-deploy

kubectl get rs

kubectl describe rs

Page 44: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

ROLLING UPDATE TO THE DEPLOYMENTkubectl apply -f deploy.yml --record

kubectl rollout status deployments jenkins-deploy

kubectl get deploy jenkins-deploy

kubectl rollout history deployments jenkins-deploy

kubectl get rs

Page 45: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers:

UNDO ROLLED UPDATEkubectl describe deploy jenkins-deploy

kubectl rollout undo deployment jenkins-deploy --to-

revision=1

kubectl get deploy

kubectl rollout status deployments jenkins-deploy

Page 46: kubernetes - Direct DevOps from QualityThought · STEPS TO CREATE PODS Create a Sample Pod i.e file with pod.yml apiVersion: v1 kind: Pod metadata: name: hello-pod spec: containers: