-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.txt
176 lines (167 loc) · 7.1 KB
/
commands.txt
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
kubectl get pods -n kube-system
kubectl run nginx --image nginx
kubectl run redis --image redis --dry-run=client -o yaml > pod.yaml
kubectl get pods
kubectl create -f pod-definition.yml
kubectl describe pod my-pod
kubectl delete pod my-pod
kubectl edit pod redis
kubectl apply -f pod.yml
kubectl get replicationcontroller
kubectl get replicationset
kubectl replace -f replicaset-definition.yml
kubectl scale --replicas=6 replicaset-definition.yml
kubectl scale --replicas=6 replicaset myapp-replicaset
kubectl delete replicaset my-replicaset
kubectl get deployments
kubectl get all
kubectl run nginx --image=nginx --dry-run=client -o yaml
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml
kubectl get pods --namespace=kube-system
kubectl get pods --all-namespaces
kubectl config set-context $(kubectl config current-context) --namespace=dev
kubectl get services
kubectl get svc
kubectl delete service my-service
kubectl expose deployment nginx --port 80
kubectl set image deployment nginx nginx=nginx:1.18
kubectl apply -f file.yaml
kubectl replace --force -f nginx.yaml
kubectl create service nodeport nginx --tcp=80:80 --node-port=30080 --dry-run=client -o yaml
kubectl expose pod nginx --port=80 --name nginx-service --type=NodePort --dry-run=client -o yaml
kubectl run redis --image=redis:alpine -l tier=db
kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml
kubectl create service clusterip redis-service --tcp=6379:6379
kubectl create deployment webapp --image=kodekloud/webapp-color --replicas=3
kubectl run custom-nginx --image=nginx --port=8080
kubectl create namespace dev-ns
kubectl create deployment redis-deploy --namespace=dev-ns --image=redis --replicas=2
kubectl run httpd --image=httpd:alpine --port=80 --expose
kubectl -n kube-system get pods
kubectl get pods --selector app=App1
kubectl get pods --selector env=dev
kubectl get all --selector env=prod
kubectl get pods --selector env=prod,bu=finance,tier=frontend # and selector
kubectl get pods --selector env=prod;bu=finance;tier=frontend # or selector
kubectl get pods --show-labels #shows all pods labels
kubectl get pods -l env=dev
kubectl get pods -l env=dev --no-headers | wc -l
kubectl taint nodes node-name key=value:taint-effect #(taint-effect = NoSchedule|PreferNoSchedule|NoExecute)
kubectl taint nodes node01 spray=mortein:NoSchedule
kubectl describe node kubemaster | grep -i taint
kubectl taint nodes controlplane node-role.kubernetes.io/master:NoSchedule-
kubectl explain pod --recursive | grep -A5 tolerations # to get pod definition properties
kubectl label nodes <node-name> key=value
kubectl get nodes node01 --show-labels
kubectl get deployment blue -o yaml
kubectl get daemonsets
kubectl get ds
ps -ef | grep kubelet
grep -i static /var/lib/kubelet/config.yaml
kubectl run static-busybox --image=busybox --command sleep 1000 --restart=Never --dry-run=client > static-busybox.yaml
kubectl get events
kubectl top node #requires metrics-api
kubectl top pod #requires metrics-api
kubectl create -f . # executes all *.yaml from present directory
watch "kubectl top node"
kubectl logs -f podName
kubectl logs -f podName containerName
kubectl rollout status deployment/myapp-deployment
kubectl rollout history deployment/myapp-deployment
kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
kubectl rollout undo deployment/myapp-deployment
kubectl create configmap app-config --from-literal=APP_COLOR=blue --from-literal=APP_MOD=prod
kubectl create configmap app-config --from-file=app_config.properties
kubectl create -f config-map.yml
kubectl get configmaps
kubectl get cm
kubectl explain pods --recursive | less
kubectl explain pods --recursive | grep A8 envFrom
kubectl create secret generic app-secret --from-literal=DB_HOST=mysql
kubectl create secret generic app-secret --from-file=secret.properties
kubectl get secrets
kubectl describe secret my-secret
kube-controller-manager --pod-eviction-timeout=5m0s
kubectl drain node-1 # moves pods to different nodes
kubectl uncordon node-1 #allows to schedule pods on node-1
kubectl cordon node-2 # unschedulable
kubectl drain node01 --ignore-daemonsets
kubectl drain node01 --ignore-daemonsets --force
kubeadm upgrade plan
kubeadm upgrade apply
apt-get upgrade -y kubeadm=1.12.0-00
kubeadm upgrade apply v1.12.0
apt-get upgrade -y kubelet=1.12.0-00
kubeadm token list
kubectl version --short
kubeadm version
kubectl get all --all-namespaces -o yaml > all-deploy-services.yaml
kubectl create serviceaccount sa1
kubectl get serviceaccount
kubectl get csr
kubectl certificate approve jane
kubectl certificate deny agent-x
kubectl get csr jane -o yaml
curl https://mykube:6443/api/v1/pods --key admin.key --cert admin.crt --cacert ca.crt
kubectl get pods --server my-kube-playground:6443 --client-key admin.key --client-certificate admin.crt --certificate-authority ca.crt
kubectl get pods --kubeconfig kube.config #default location - $HOME/.kube/config
kubectl config view
kubectl config use-context prod-user@production
kubectl config --kubeconfig=/root/my-kube-config use-context research
kubectl config -h
kubectl proxy # starts proxy to access the cluster, starts on port 8001
kubectl get roles
kubectl get roles --all-namespaces
kubectl describe role kube-proxy -n kube-system
kubectl get rolebindings
kubectl describe role developer
kubectl describe rolebinding devuser-developer-binding
kubectl auth can-i create deployments
kubectl auth can-i delete nodes
kubectl auth can-i create deployments --as dev-user
kubectl auth can-i create pods --as dev-user
kubectl auth can-i create pods --as dev-user -n test
kubectl api-resources --namespaced=true
kubectl api-resources --namespaced=false
kubectl get clusterroles
kubectl get clusterrolebindings
kubectl create secret docker-registry regcred --docker-server= --docker-username= --docker-password= --docker-email=
kubectl get netpol
docker run --mount type=bind,source=/data/mysql,target=/var/lib/mysql mysql
kubectl get persistentvolumeclaim
kubectl exec webapp -- cat /log/app.log
ip link
ip addr
ip addr add 192.168.1.10/24 dev eth0
ip route
ip route add 192.168.1.0/24 via 192.168.2.1
cat /proc/sys/net/ipv4/ip_forward
arp
netstat -plnt
route
kubectl get nodes -o wide
ip a | grep 10.0.63.12
arp node01
netstat -na | grep 2380
ifconfig -a
cat /etc/network/interfaces
netstat -natulp | grep kube-scheduler
ip r
ps -aux | grep kubelet
ls /opt/cni/bin
ls /etc/cni/net.d #tells us what cni is configured
ls /etc/cni/net.d
kube-proxy --proxy-mode [userspace | iptables | ipvs ] ...
kube-api-server --service-cluster-ip-range ipNet
kubelet get service
iptables -L -t net | grep db-service
cat /var/log/kube-proxy.log
kubectl logs pod kube-proxy-l8xtj -n kube-system
cat /etc/coredns/Corefile
cat /etc/resolv.conf
host web-service
host 10-244-2-5
host 10-244-2-5.default.pod.cluster.local
kubectl describe cm coredns -n kube-system
kubectl run busybox --image=busybox --comand sleep 1000 --dry-run=client -o yaml > pod.yaml # add nodeName in spec to run it on a particular node, then run "kubectl exec -it busybox -- sh" to access the container
kubectl -n ingress-space expose deployment ingress-controller --name ingress --port 80 --targetPort 80 --type NodePort --dry-run=client -o yaml > ingress-service.yaml