Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Labels are not added when using SubnamespaceAnchor manifest #323

Closed
aboncok opened this issue Aug 22, 2023 · 2 comments
Closed

Labels are not added when using SubnamespaceAnchor manifest #323

aboncok opened this issue Aug 22, 2023 · 2 comments

Comments

@aboncok
Copy link

aboncok commented Aug 22, 2023

Hi,
As with all other Kubernetes resources, I was expecting to see defined labels on the created subnamespaces too.
Take following manifest for example:

apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata:
  name: app3
  namespace: hnc-child1
  labels:
    name: app3
    env: hnc-child1

Checking the created namespace:
kubectl describe ns app3
It shows me this:

Name:         app3
Labels:       app3.tree.hnc.x-k8s.io/depth=0
              hnc-child1.tree.hnc.x-k8s.io/depth=1
              hnc-test.tree.hnc.x-k8s.io/depth=2
              hnc.x-k8s.io/included-namespace=true
              kubernetes.io/metadata.name=app3
Annotations:  hnc.x-k8s.io/subnamespace-of: hnc-child1
Status:       Active

No resource quota.

No LimitRange resource.

The label is missing.
Labels are an important component in controlling access and managing resources.
Would it be possible to add handling these?

@adrianludwin
Copy link
Contributor

Instead of this:

apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata:
  name: app3
  namespace: hnc-child1
  labels: # these are the labels on the anchor itself, not the child namespace
    name: app3
    env: hnc-child1

You should use this:

apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata:
  name: app3
  namespace: hnc-child1
spec:
  labels: # these are the labels that will be created on the child namespace, not the anchor
    name: app3
    env: hnc-child1

That is: the anchor spec defines which labels should appear on the newly created namespace. The anchor can have its own labels and annotations, which are separate from those that appear on the subnamespace. This is the same as the template in a Deployment (i.e. here). Does that make sense?

@aboncok
Copy link
Author

aboncok commented Sep 15, 2023

Thanks @adrianludwin , it does. I'll close this ticket.

@aboncok aboncok closed this as completed Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants