Need nsenter in Daemonset

  alpine, daemonset, docker, kubernetes

I recently found this articel from Luc Juggery.

In this articel you get a docker container

docker run --privileged --pid=host -it alpine:3.8 nsenter -t 1 -m -u -n -i sh

which I need, but as a Kubernetes Daemonset.
So I tried the following:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: test
  labels:
    k8s-app: test
spec:
  selector:
    matchLabels:
      name: test
  template:
    metadata:
      labels:
        name: pia
    spec:
      hostPID: true
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: alpine
        image: alpine:3.8
        command: ['sh','-c','nsenter -t 1 -m -u -n -i sh']
        privileged: true

But it just doesn’t work. kubectl logs doesn’t say anything. I tried different commands, like

1.) command: ['nsenter -t 1 -m -u -n -i sh']
2.) command: ['nsenter'] 
    args: ['-t 1 -m -u -n -i sh']
3.) command: ['nsenter -t 1 -m -u -n -i']
4.) command: ['nsenter'] 
    args: ['-t 1 -m -u -n -i']

but nothing works and kubectl logs doesn’t say anything.
Has anyone an Idea?

Source: Docker Questions

LEAVE A COMMENT