The node had condition: [DiskPressure] causing pod eviction in k8s in azure/aks

So how do I get an overview of storage consumption on the worker nodes without SSH access?

You can create privileged pod like following:

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: privileged-pod
  name: privileged-pod
spec:
  hostIPC: true
  hostNetwork: true
  hostPID: true
  containers:
  - args:
    - sleep
    - "9999"
    image: centos:7
    name: privileged-pod
    volumeMounts:
    - name: host-root-volume
      mountPath: /host
      readOnly: true
  volumes:
  - name: host-root-volume
    hostPath:
      path: /

and then exec to it:

kubectl exec -it privileged-pod -- chroot /host

and then you have access to the whole node, just like you would have using ssh.

Note: In case your k8s user has attached pod-security-policy you may not be able to do this, if changeing hostIPC, hostNetwork and hostPID is disallowed.

You also need to make sure that the pod gets scheduled on specific node that you want to have acccess to. Use .spec.nodeName: <name> to acheive it.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top