-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path5-Deployment
53 lines (41 loc) · 1.94 KB
/
5-Deployment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--------------------------------------------------------------------------
Deployment - this creates a replica set, offers rollback, rolling update of pods
command to create deployments - kubectl create deployment httpd-frontend --image=http:2.4-alpine --dry-run -o yaml > dep.yaml
command to create deployment - kubectl create deployment httpd-frontend --image=http:2.4-alpine
then scale using command - kubectl scale deployment --replicas=3 httpd-frontend
example yaml to create repliaction set (cat > deploy-defintion.yaml)
apiVersion: apps/v1
kind: Deployment
metadata:
name:rc-deployment(this is name of deployment)
labels:
app: my-app
costCenter: US
spec:
template:
metadata:
name:nginx-app(this is name of pod)
labels:
app: my-app
costcenter: us
user: hari
spec:
containers:
- name:nginx-container
image:nginx
replicas: 3 (this is number of replicas)
selector:
matchLabels:
app:my-app
command - kubectl create -f deploy-defintion.yaml
kubectl get deployments
kubectl get replicaset - this will show replica set created by deployment
to see all object created in kubernetes use command - kubectl get all
commands to generate yml file - https://kubernetes.io/docs/reference/kubectl/conventions/
command to update the image of a deployment - kubectl set image <deployment name> nginx=nginx:1.9.1
ROLLING UPDATES AND ROLLBACKS
to check the rollout status of a deployment use command - kubectl rollout status <deployment name>
to check the history of a rollout of a deployment use command - kubectl rollout history <deployment name>
command to update the image of a deployment - kubectl set image <deployment name> nginx=nginx:1.9.1
command to rollback to older version of deployment - kubectl rollout undo <deployment name>
--------------------------------------------------------------------------