Skip to content

Instantly share code, notes, and snippets.

@rosenhouse
Last active September 10, 2019 05:23
Show Gist options
  • Save rosenhouse/4dd2add1aec28e783d38d11b2ed886de to your computer and use it in GitHub Desktop.
Save rosenhouse/4dd2add1aec28e783d38d11b2ed886de to your computer and use it in GitHub Desktop.
# parent.yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: some-parent
  namespace: default
data: {}
# children.yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: some-child-1
  namespace: default
  ownerReferences:
  - apiVersion: v1
    kind: ConfigMap
    name: some-parent
    uid: PARENT_UID
data: {}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: some-child-2
  namespace: default
  ownerReferences:
  - apiVersion: v1
    kind: ConfigMap
    name: some-parent
    uid: PARENT_UID
data: {}
kubectl apply -f parent.yaml
parentUID=$(kubectl get configmap/some-parent -o jsonpath='{.metadata.uid}')
kubectl apply -f <(sed "s/PARENT_UID/$parentUID/" children.yaml)
kubectl get configmaps
kubectl delete configmap some-parent
kubectl get configmaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment