Skip to content

Instantly share code, notes, and snippets.

@myshkin5
Created March 7, 2019 17:28
Show Gist options
  • Save myshkin5/f5ff7cbcb1231265d4dbde632dd1cabb to your computer and use it in GitHub Desktop.
Save myshkin5/f5ff7cbcb1231265d4dbde632dd1cabb to your computer and use it in GitHub Desktop.
Create a mutating configmap

mutating-configmap

Steps to reproduce a changing configmap mounted as a volume to see the effects on a running pod.

Steps

  1. Create the initial config map:
    kubectl create configmap my-cm --from-file configmap.txt --dry-run --output yaml | \
       grep -v creationTimestamp | \
       kubectl apply -f -
    Note: Above removes the creation timestamp so that subsequent applies don't trigger a change to the configmap.
  2. Launch a simple pod with the configmap mounted as a volume:
    kubectl apply -f pod.yaml
  3. Shell into the pod (may have to wait for it to come up):
    kubectl exec -it my-pod -- /bin/sh
  4. Monitor the contents of the configmap file:
    while $(true); do echo $(date) $(md5sum /etc/my-cm-volume/configmap.txt); sleep 1; done
  5. Mutate the contents of the file.
  6. Apply the configmap again (redo step 1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment