-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes
95 lines (72 loc) · 3.2 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
CHEAT SHEET
https://kubernetes.io/docs/reference/kubectl/cheatsheet/
https://linuxacademy.com/site-content/uploads/2019/04/Kubernetes-Cheat-Sheet_07182019.pdf
kubectl get all
(Section 5): list all objects that you’ve created. Pods at first, later,
ReplicaSets, Deployments and Services
kubectl apply –f <yaml file>
(Section 5): either creates or updates resources depending on the
contents of the yaml file
kubectl apply –f .
(Section 7): apply all yaml files found in the current directory
kubectl describe pod <name of pod>
(Section 5): gives full information about the specified pod
kubectl exec –it <pod name> <command>
(Section 5): execute the specified command in the pod’s container.
Doesn’t work well in Cygwin.
kubectl get (pod | po | service | svc | rs | replicaset | deployment |
deploy)
(Section 6): get all pods or services. Later in the course, replicasets and
deployments.
kubectl get po --show-labels
(Section 6): get all pods and their labels
kubectl get po --show-labels -l {name}={value}
(Section 6): get all pods matching the specified name:value pair
kubectl delete po <pod name>
(Section 8): delete the named pod. Can also delete svc, rs, deploy
kubectl delete po --all
(Section 8): delete all pods (also svc, rs, deploy)
Deployment Management
kubectl rollout status deploy <name of deployment>
(Section 9): get the status of the named deployment
kubectl rollout history deploy <name of deployment>
(Section 9): get the previous versions of the deployment
kubectl rollout undo deploy <name of deployment>
(Section 9): go back one version in the deployment. Also optionally --
to-revision=<revision number>
We recommend this is used only in stressful emergency situations! Your
YAML will now be out of date with the live deployment!
Create deployment
kubectl run myautoscale --image=httpd --port=80 --labels=app=myautoscale
Autoscale deployment
kubectl autoscale deploy myautoscale --min=2 --max=6
kubectl scale --current-replicas=2 --replicas=1 deploy/myautoscale
kubectl scale --replicas=12 deploy/myautoscale
https://stackoverflow.com/questions/40366192/kubernetes-how-to-make-deployment-to-update-image
refresh container image imperatively thru command
kubectl set image <object type>/<name of object> <name of container>=<name of container image with tag>
kubectl set image deployment/nginxDeployment webserver=nginx:1.3.1
livenessProbe
readynessProbe
configMaps
create configmap from config file
kubectl create configmap <name of configmap> --from-file=<name of config file>
kubectl create configmap nginx-config --from-file=nginx.conf
Udemy k8s course
https://github.com/wardviaene/kubernetes-course
Richard Chesterwood
https://github.com/DickChesterwood/k8s-fleetman
Generate YAML file from kubectl
https://www.reddit.com/r/kubernetes/comments/eu97sn/yaml_generator/
Replicaset commands
k create -f replicaset.yaml
k get replicaset
k delete replicaset myapp-rpl
k replace -f replicast.yaml
k scale --replicas=6 -f replicaset.yaml
k scale --replicas=6 replicaset rs-app
## refresh / restart deployment pods with new changes
kubectl rollout restart deployment yourDeploymentName
## oc adm commands
oc adm policy add-scc-to-user <scc type> -z <name of service account>
oc adm policy add-scc-to-user nonroot -z default