@@ -49,7 +49,7 @@ detailed config file information.
49
49
kubectl config view # Show Merged kubeconfig settings.
50
50
51
51
# use multiple kubeconfig files at the same time and view merged config
52
- KUBECONFIG=~ /.kube/config:~ /.kube/kubconfig2
52
+ KUBECONFIG=~ /.kube/config:~ /.kube/kubconfig2
53
53
54
54
kubectl config view
55
55
@@ -58,7 +58,7 @@ kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
58
58
59
59
kubectl config view -o jsonpath=' {.users[].name}' # display the first user
60
60
kubectl config view -o jsonpath=' {.users[*].name}' # get a list of users
61
- kubectl config get-contexts # display list of contexts
61
+ kubectl config get-contexts # display list of contexts
62
62
kubectl config current-context # display the current-context
63
63
kubectl config use-context my-cluster-name # set the default context to my-cluster-name
64
64
@@ -92,10 +92,10 @@ kubectl apply -f https://git.io/vPieo # create resource(s) from url
92
92
kubectl create deployment nginx --image=nginx # start a single instance of nginx
93
93
94
94
# create a Job which prints "Hello World"
95
- kubectl create job hello --image=busybox -- echo " Hello World"
95
+ kubectl create job hello --image=busybox -- echo " Hello World"
96
96
97
97
# create a CronJob that prints "Hello World" every minute
98
- kubectl create cronjob hello --image=busybox --schedule=" */1 * * * *" -- echo " Hello World"
98
+ kubectl create cronjob hello --image=busybox --schedule=" */1 * * * *" -- echo " Hello World"
99
99
100
100
kubectl explain pods # get the documentation for pod manifests
101
101
@@ -173,8 +173,8 @@ kubectl get configmap myconfig \
173
173
-o jsonpath=' {.data.ca\.crt}'
174
174
175
175
# Get all worker nodes (use a selector to exclude results that have a label
176
- # named 'node-role.kubernetes.io/master ')
177
- kubectl get node --selector=' !node-role.kubernetes.io/master '
176
+ # named 'node-role.kubernetes.io/control-plane ')
177
+ kubectl get node --selector=' !node-role.kubernetes.io/control-plane '
178
178
179
179
# Get all running pods in the namespace
180
180
kubectl get pods --field-selector=status.phase=Running
@@ -226,7 +226,7 @@ for pod in $(kubectl get po --output=jsonpath={.items..metadata.name}); do echo
226
226
227
227
``` bash
228
228
kubectl set image deployment/frontend www=image:v2 # Rolling update "www" containers of "frontend" deployment, updating the image
229
- kubectl rollout history deployment/frontend # Check the history of deployments including the revision
229
+ kubectl rollout history deployment/frontend # Check the history of deployments including the revision
230
230
kubectl rollout undo deployment/frontend # Rollback to the previous deployment
231
231
kubectl rollout undo deployment/frontend --to-revision=2 # Rollback to a specific revision
232
232
kubectl rollout status -w deployment/frontend # Watch rolling update status of "frontend" deployment until completion
@@ -318,7 +318,7 @@ kubectl run nginx --image=nginx # Run pod nginx and write it
318
318
kubectl attach my-pod -i # Attach to Running Container
319
319
kubectl port-forward my-pod 5000:6000 # Listen on port 5000 on the local machine and forward to port 6000 on my-pod
320
320
kubectl exec my-pod -- ls / # Run command in existing pod (1 container case)
321
- kubectl exec --stdin --tty my-pod -- /bin/sh # Interactive shell access to a running pod (1 container case)
321
+ kubectl exec --stdin --tty my-pod -- /bin/sh # Interactive shell access to a running pod (1 container case)
322
322
kubectl exec my-pod -c my-container -- ls / # Run command in existing pod (multi-container case)
323
323
kubectl top pod POD_NAME --containers # Show metrics for a given pod and its containers
324
324
kubectl top pod POD_NAME --sort-by=cpu # Show metrics for a given pod and sort it by 'cpu' or 'memory'
0 commit comments