Useful shortcuts for vi editor

Showing posts with label kubernetes. Show all posts
Showing posts with label kubernetes. Show all posts

Saturday, 29 June 2019

Kubernetes label usage

e.g. namespace; kube-system

-> List labels
# kubectl get pods --all-namespaces --show-labels
# kubectl get pods -n kube-system --show-labels

-> List pods via labels
# kubectl get pods -n kube-system -l tier=control-plane

-> Describe pod/pods via labels

# kubectl describe pod -n kube-system -l component=kube-scheduler
# kubectl describe pod -n kube-system -l tier=control-plane

-> Get logs via labels
# kubectl logs -n kube-system -l component=kube-scheduler
kubectl logs -n kube-system -l tier=control-plane

-> Delete pods via labels
kubectl delete pods -n kube-system -l component=example
kubectl delete pods -n kube-system -l 'component in (example,example2)'
# kubectl delete pods -n kube-system -l 'component notin (example3, example4)'

Thursday, 3 January 2019

How to fix "connection refused" error?

Error
e.g.
The connection to the server 10.10.10.10:6443 was refused - did you specify the right host or port?

Solution
On kubernetes control nodes, try to "stop/start" docker service
# service docker restart
or
# systemctl restart docker

Thursday, 4 October 2018

How to solve "restarting/pending pod repeatedly" problem?

-> Check the pods status
e.g.
# kubectl get pods --all-namespaces
NAMESPACE     NAME                            READY     STATUS
kube-system   coredns-78fcdf6894-6ggkk        0/1       Pending
kube-system   coredns-78fcdf6894-tm52r        0/1       Pending 

-> Check the deployments
# kubectl get deployment --all-namespaces
NAMESPACE     NAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE
kube-system   coredns   2         2         2            0

-> Needs to remove the deployments related to pod and service
e.g.
# kubectl delete deployment coredns -n kube-system
deployment.extensions "coredns" deleted