DEV Community

Radu Andra
Radu Andra

Posted on

Another method to access AKS Linux Nodes

Deploy a demonset with privileged containers to access each node

cat <<EOF > sshNode.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: privileged
spec:
  selector:
    matchLabels:
      name: privileged-container
  template:
    metadata:
      labels:
        name: privileged-container
    spec:
      containers:
      - name: busybox
        image: busybox
        resources:
          limits:
            cpu: 200m
            memory: 100Mi
          requests:
            cpu: 100m
            memory: 50Mi
        stdin: true
        securityContext:
          privileged: true
        volumeMounts:
        - name: host-root-volume
          mountPath: /host
          readOnly: false
      volumes:
      - name: host-root-volume
        hostPath:
          path: /
      hostNetwork: true
      hostPID: true
      restartPolicy: Always
EOF
Enter fullscreen mode Exit fullscreen mode

image

Bellow, I list the nodes and the pods, I see that I have 3 nodes and 3 privileged pods each one related to one specific node.
I exec into one created pod and I enter directly on the node from there I access the kubelet logs.
Exit the node by entering this command: exit

kubectl get nodes -owide
kubectl get pods -owide                                            
kubectl exec -it privileged-dr5mf chroot /host 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)