Skip to content

Instantly share code, notes, and snippets.

@WintersMichael
Created February 7, 2018 16:38
Show Gist options
  • Save WintersMichael/739b03750861fb368af5d2e5c96b21cd to your computer and use it in GitHub Desktop.
Save WintersMichael/739b03750861fb368af5d2e5c96b21cd 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