03-Kubernetes Commands 101
03-Kubernetes Commands 101
August 2023
Aaron Kirn
Technical Leader - Cisco DNA Center
kubectl get
kubectl describe
kubectl delete
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl get
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl get
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl get
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl get
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
Basic Syntax: kubectl describe pod -n <namespace> <pod>
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
Containers:
mksserver:
Container ID:
containerd://a1238a69f61a47a21a568f20f2f36bfa90ff2447c6a15978204f3d76a93fc930
Image: catalogsvc-reg.ciscoconnectdna.com/maglev-
docker/mksserver:2.3.60
Image ID:
sha256:031527165763b4863a463b2ac45d9a68a020a10f01999fff355870bcb67b89ff
kubectl describe pod Port: 8017/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 11 Aug 2023 01:03:05 +0000
Ready: True
Restart Count: 0
kubectl describe node Limits:
cpu: 1
memory: 1Gi
Requests:
cpu: 100m
memory: 250Mi
Liveness: http-get https://:8017/api/services/mksserver/status delay=60s
timeout=10s period=30s #success=1 #failure=3
Environment:
K8S: true
......
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
api-features:
kubectl describe pod Type: ConfigMap (a volume populated by a ConfigMap)
Name: api-features
Optional: true
[…]
QoS Class: Burstable
Node-Selectors: <none>
kubectl describe node Tolerations: :NoSchedule op=Exists
node.kubernetes.io/not-ready:NoExecute op=Exists for
300s
node.kubernetes.io/unreachable:NoExecute op=Exists for
300s
Events: <none>
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
Basic Syntax: kubectl describe node <name>
$ kubectl describe node 169.254.6.66
Name: 169.254.6.66
Roles: control-plane
Labels: allAppstacks=enabled
appstack.maglev-system=enabled
[…]
Annotations: kubeadm.alpha.kubernetes.io/cri-socket: unix:///run/containerd/containerd.sock
node.alpha.kubernetes.io/ttl: 0
kubectl describe pod […]
CreationTimestamp: Thu, 10 Aug 2023 05:13:41 +0000
Taints: <none>
Unschedulable: false
Lease:
HolderIdentity: 169.254.6.66
AcquireTime: <unset>
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
Addresses:
InternalIP: 169.254.6.66
Hostname: 169.254.6.66
Capacity:
cpu: 32
[…]
Allocatable:
cpu: 30
[…]
System Info:
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl describe
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 27640m (92%) 171198m (570%)
memory 176588Mi (73%) 397033Mi (164%)
ephemeral-storage 0 (0%) 0 (0%)
hugepages-1Gi 0 (0%) 0 (0%)
hugepages-2Mi 0 (0%) 0 (0%)
kubectl describe pod Events: <none>
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl logs
kubectl exec
kubectl delete
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl logs, exec, and delete
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl logs, exec, and delete
Basic Syntax: kubectl exec -it -n <namespace> <pod> -- <command>
kubectl delete $ kubectl exec -it -n fusion postgres-0 -c postgres -- psql -d campus -U
appuser -c "select * from pkibrokerconfig;"
id | instance_version | instanceuuid | displayname | pkiconfig | authentityid
-------+------------------+------------------------+-------------+--------------------------
35035 | 0 | iostruststore-password |
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
kubectl logs, exec, and delete
kubectl delete
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
Resources
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential
Resources
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Cisco Confidential