3

I want to create a pod using kubectl CLI which will mount hostpath /etc/os-release inside pod container and display content of /etc/os-release file. Is is possible to do it in using one-liner kubectl command?

1 Answer 1

6
kubectl run -i --rm busybox --image=busybox --overrides='{
               "apiVersion": "v1",
               "spec": {
                  "containers": [
                     {
                        "image": "busybox",
                        "name": "busybox",
                        "command": ["cat", "/etc/os-release"],
                        "resources": {},
                        "volumeMounts": [
                           {
                              "mountPath": "/etc/os-release",
                              "name": "release"
                           }
                        ]
                     }
                  ],
                  "volumes": [
                     {
                        "name": "release",
                        "hostPath": {
                           "path": "/etc/os-release",
                           "type": "File"
                        }
                     }
                  ],
                  "dnsPolicy": "ClusterFirst",
                  "restartPolicy": "Never"
               },
               "status": {}
            }'
NAME=Buildroot
VERSION=2019.02.10
ID=buildroot
VERSION_ID=2019.02.10
PRETTY_NAME="Buildroot 2019.02.10"
pod "busybox" deleted

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.