Skip to content

Instantly share code, notes, and snippets.

@sahajamit
Forked from WintersMichael/patch_configmap.sh
Created August 13, 2019 04:34
Show Gist options
  • Save sahajamit/8e2ecb045c29b8df1358ade594457d4f to your computer and use it in GitHub Desktop.
Save sahajamit/8e2ecb045c29b8df1358ade594457d4f to your computer and use it in GitHub Desktop.
Patch / update a configmap from inside Kubernetes using curl
KUBE_TOKEN=$(</var/run/secrets/kubernetes.io/serviceaccount/token)
NAMESPACE=myapp-dev
CONFIGMAP_NAME=testconfig
curl -sSk \
-X PATCH \
-d @- \
-H "Authorization: Bearer $KUBE_TOKEN" \
-H 'Accept: application/json' \
-H'Content-Type: application/strategic-merge-patch+json' \
https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/$NAMESPACE/configmaps/$CONFIGMAP_NAME <<'EOF'
{
"kind": "ConfigMap",
"apiVersion": "v1",
"data": {
"foo": "bar"
}
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment