3 min read
When we don't have the Pod's resources correctly configured we might face the need of moving a Pod to a different node. Although we could change the nodeSelector or adjust the resources to that it gets scheduled on a different node, it might urge us to fix an issue. To do so we can use kubectl drain
At the end of the day what we want it really is "drain the node of that kind of Pods". As kind of by product the node ends up being cordoned so we are sure the Pod won't be scheduled again on the same node.
25/10/2021
Read more...2 min read
If we need to investigate why a container keeps restarting, a good place to start is taking a look at the logs when it crashes. Since Kubernetes will automatically restart a failed container, if we use kubectl logs we will get the logs of the restarted container instead of the one that have crashed:
$ kubectl logs ampa-7d98c84675-dpzjw -c ampa
[2021-10-15 14:20:41 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2021-10-15 14:20:41 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2021-10-15 14:20:41 +0000] [1] [INFO] Using worker: sync
[2021-10-15 14:20:41 +0000] [8] [INFO] Booting worker with pid: 8
How can we retrieve the logs of the previous container?
18/10/2021
Read more...2 min read
On a Kubernetes cluster we might have deprecated versions of the object, so after updating it we might end up with something not properly working:
$ kubectl api-resources | grep Ingress\$
ingresses ing extensions/v1beta1 true Ingress
ingresses ing networking.k8s.io/v1 true Ingress
23/09/2021
Read more...2 min read
If we need to take a look at the resources of a Kubernetes cluster, by using kubectl get all we won't be able to see all the resources. Most notably, it won't list Ingress objects. You can take a look at this issue for kubectl for the details but we won't be able to get all the resources using this command, we'll have to install the get-all krew plugin
14/09/2021
Read more...2 min read
To be able to modify a Kubernetes object we can use kubectl edit to do it interactively. It can come handy if we need to test values but it makes it harder to automate it. If we need a way to change a Kubernetes object using a non-interactive command, kubectl patch is the best option for us.
18/08/2021
Read more...