kubectl
kubectl get
kubectl get nodes
OR
kubectl get pods/deployments/svc/events/networkpolicy -n <namespace> #OR --all-namespaces
Get a list of items in JSON:
kubectl get deployments/daemonset/sts -n sre-monitoring -o json | jq '.items[].spec.template.spec.containers[] | {name: .name, requests: .resources.requests, limits: .resources.limits}'
kubectl describe
kubectl describe pod/svc <service-name> -n <namespace>
- Verify the Updated DaemonSet
kubectl describe daemonset cadvisor -n utils
kubectl logs
kubectl logs <pod-name> -n <namespace>
real-time monitoring:
kubectl logs -f <pod-name> -n <namespace>
View Logs for a Specific Container in the Pod:
kubectl logs <pod-name> -c <container-name> -n <namespace>
Filter Logs for Errors:
kubectl logs <pod-name> -n <namespace> | grep -i error
kubectl exec
Exec into the Pod:
kubectl exec -it <pod-name> -n <namespace> -- /bin/bash
kubectl apply
kubectl apply -f <policy-file>.yaml
kubectl top
kubectl top <node-name>
kubectl top <pod-name> -n <namespace> #can be used with --containers
kubectl edit
- Manually Edit the DaemonSet (if necessary)
kubectl edit daemonset cadvisor -n utils
kubectl scale
Stop of a StatefulSet
work
kubectl scale statefulset <NAME> --replicas=0 -n <NAMESPACE>
kubectl delete
Delete PVC
kubectl delete pvc <NAME> -n <NAMESPACE>
kubectl auth
Check what you to be able to:
kubectl auth can-i patch statefulset -n <NAMESPACE>
kubectl auth can-i delete pvc -n <NAMESPACE>
kubectl auth can-i get secret -n <NAMESPACE>
kubectl auth can-i get pod -n <NAMESPACE>
kubectl auth can-i create configmap -n <NAMESPACE>