how to pass a namespace to a subject in a rolebinding in kubernetes

I have the following manifest:

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: my-psp-rb
roleRef:
  kind: Role
  name: psp-role
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: Group
  name: system:serviceaccounts:${NAMESPACE}

I would like to deploy this manifest as follows: kubectl apply -f psp-rb.yaml -n some_namespace in a way that the name in the subject is dynamically set. I know that ${NAMESPACE} is not allowed, so I am looking for a way on how to do this. I looked into this but I am not a huge fan of installing dependencies only for passing variables to a manifest (plus I agree variables shouldn't be used in this context). Maybe there is a kubernetesy way to do this?

Upvotes: 0

Views: 514

Answers (1)

coderanger
coderanger

Reputation: 54247

Copying down from comments and confirming, this is not a thing kubectl supports. It's very simple :)

Upvotes: 1

Related Questions