forked from jhong40/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
189 lines (150 loc) · 5.39 KB
/
notes
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/etc/hostname
kubemaster
/etc/hosts
127.0.0.1 kubemaster
Host-only Network
Adapter 2 for Host-Only network
/etc/fstab #comment out swap or swap -a
kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=172.16.110.73
kubeadm join 172.16.110.73:6443 --token f64rrh.pxva1wccuqhjo8gh \
--discovery-token-ca-cert-hash sha256:282c3908b7f102a45233760a0a6937bb0287dc95a5f77417e97393e25b146e8d
export KUBECONFIG=/etc/kubernetes/admin.conf
master - 172.16.110.73
node1 - 172.16.110.75
node2 - 172.16.110.113
kubectl run nginx --image=nginx #create a deployment nginx
kubectl get pods
kubectl get pods -o wide
kubectl describe pods
kubectl create -f pod-def.yml
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
myapp-pod 1/1 Running 0 78s 192.168.205.193 kubenode1 <none> <none>
nginx-6db489d4b7-mwz8w 1/1 Running 0 11m 192.168.35.66 kubenode2 <none> <none>
kubectl create -f rs-def.yml
kubectl get rs #kubectl get replicaset
kubectl describe rs
kubectl delete rs frontend #rs or replicaset
kubectl create -f rc-def.yml
kubectl get rc #kubectl get replicationcontroller
kubectl describe rc
kubectl create -f dp-def.yml
kubectl get deployments
kubectl apply -f dp-def.yml
kubectl set image deploy/myapp-deployment nginx=nginx:1.9.1
kubectl describe deployment
kubectl rollout status deployment/myapp-deployment
kubectl rollout history deployment/myapp-deployment
kubectl rollout undo deployment/myapp-deployment
kubectl get rs new-rs -o yaml #creates yml out of the existing rs
kubectl scale rs new-rs --replicas=5
root@kubemaster:~# kubectl create -f dp-def.yml --record
deployment.apps/myapp-deployment created
root@kubemaster:~# kubectl rollout history deployment/myapp-deployment
deployment.apps/myapp-deployment
REVISION CHANGE-CAUSE
1 kubectl create --filename=dp-def.yml --record=true
#scale
1. replicas: 6 (3-init)
kubectl replace -f rs-def.yml
2. kubectl scale --replicas=6 -f rs-def.yml #add scale parm and the same yml file
3. kubectl scale --replicas=6 replicaset myapp-replicaset
# cat pod-def.yml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
root@kubemaster:~# cat rs-def.yml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-rs
labels:
app: myapp
type: front-end
spec:
replicas: 3
selector:
matchLabels:
type: front-end
template:
metadata:
labels:
app: myapp-pod
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
root@kubemaster:~# cat rc-def.yml
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp-rc
labels:
app: myapp
type: front-end
spec:
replicas: 3
template:
metadata:
labels:
app: myapp-pod
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
root@kubemaster:~# cat dp-def.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
labels:
app: myapp
type: front-end
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: nginx-container
image: nginx
---------------------------------------------------------------------------------------------
root@kubemaster:~# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-deployment-544f87f4f-mttjb 1/1 Running 0 4m7s
myapp-deployment-544f87f4f-r2k2h 1/1 Running 0 4m11s
myapp-deployment-544f87f4f-tjts5 1/1 Running 0 4m11s
myapp-deployment-685ddbd974-kccd4 0/1 ImagePullBackOff 0 90s
myapp-deployment-685ddbd974-nq85k 0/1 ImagePullBackOff 0 90s
root@kubemaster:~# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-55754f75c-qvjf8 1/1 Running 3 3d2h
calico-node-gbnc2 1/1 Running 11 3d2h
calico-node-hstz2 1/1 Running 11 3d2h
calico-node-tk442 1/1 Running 8 3d2h
coredns-5644d7b6d9-rsvj5 0/1 CrashLoopBackOff 90 3d2h
coredns-5644d7b6d9-z5ffn 0/1 CrashLoopBackOff 90 3d2h
etcd-kubemaster 1/1 Running 6 3d2h
kube-apiserver-kubemaster 1/1 Running 11 3d2h
kube-controller-manager-kubemaster 1/1 Running 16 3d2h
kube-proxy-2bg8x 1/1 Running 3 3d2h
kube-proxy-jhlpm 1/1 Running 12 3d2h
kube-proxy-nrdjt 1/1 Running 3 3d2h
kube-scheduler-kubemaster 1/1 Running 14 3d2h
# kubectl edit pod myapp-deployment-748f65c8f7-5rbtq