Skip to content

Instantly share code, notes, and snippets.

@magickatt
Last active April 19, 2024 21:25
Show Gist options
  • Save magickatt/2b4332b01ef7dd0f3b2bc7fc7b3c0953 to your computer and use it in GitHub Desktop.
Save magickatt/2b4332b01ef7dd0f3b2bc7fc7b3c0953 to your computer and use it in GitHub Desktop.
Convert an existing namespace to a subnamespace using the Hierarchical Namespace Controller
PARENT_NAMESPACE=pizzeria
CHILD_NAMESPACE=pepperoni
$ kubectl annotate namespace $CHILD_NAMESPACE \
hnc.x-k8s.io/subnamespace-of=$PARENT_NAMESPACE
# namespace/pepperoni annotated
$ cat <<EOF | kubectl apply -f -
apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata:
namespace: $PARENT_NAMESPACE
name: $CHILD_NAMESPACE
EOF
# subnamespaceanchor.hnc.x-k8s.io/pepperoni created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment