spinnaker mount volume from configmap in read/write mode (0666)

2/27/2019

Spinnaker mounts volumes like this:

apiVersion: v1
kind: Pod
metadata:
  ...
spec:
  containers:
    ...
  volumes:
  - configMap:
      defaultMode: 420
      items:
      - key: config
        path: config
      name: kubectl-k8s-integration
    name: "1551221025832"
  - ...

I need the config file to be writeble by everyone so that I can use kubectl config use-context in the container, ie I need defaultMode to be 666 instead of 420. There doesn't seem to be place in the Spinnaker GUI to set this when defining volumes. What am I missing?

-- Oliver
kubernetes
spinnaker

1 Answer

2/27/2019

Based on https://github.com/spinnaker/spinnaker/issues/2118, it is not possible.

My workaround: I configure spinnaker to mount the configmap volume to a different filename, and added code to the container that automatically copies to the expected folder; the copy has write-access.

E.g. say my configmap has a key named "config", and I was previously mounting the configmap as /home/user/.kube, so .kube/config was the file with permission 420 instead of 666. Well I now mount it as /home/user/root.kube, and the container does the equivalent of cp -r /home/user/root.kube /home/user/.kube when it starts. Now /home/user/.kube/config is writable by user.

-- Oliver
Source: StackOverflow