Auto-generated namespace in (Cluster)RoleBindings #877
Unanswered
cschmatzler
asked this question in
Q&A
Replies: 1 comment
-
Hello! local k = import 'k.libsonnet';
local tk = import 'tk';
{
sa:
k.core.v1.serviceAccount.new('sample')
+ k.core.v1.serviceAccount.metadata.withNamespace(
tk.env.spec.namespace // IMPORTANT !!!
),
role:
k.rbac.v1.role.new('sample-role')
+ k.rbac.v1.role.withRules([
k.rbac.v1.policyRule.withApiGroups(['apps'])
+ k.rbac.v1.policyRule.withResources(['deployments'])
+ k.rbac.v1.policyRule.withVerbs(['get']),
]),
bind:
k.rbac.v1.roleBinding.new('sample-role-bind')
+ k.rbac.v1.roleBinding.withSubjects([
k.rbac.v1.subject.fromServiceAccount(self.sa),
])
+ k.rbac.v1.roleBinding.bindRole(self.role),
} You may have already resolved this, but I hope this information is helpful! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
According to the Tanka documentation:
That works great, and creates all resources, including serviceaccounts, in that spec.json namespace.
When creating a RoleBinding, the
subject
option requires a namespace to be set. How do I get that in there? Right now, I'm adding an extra namespace option to the jsonnet config, but that kinda defeats the purpose of Tanka adding it automatically.Is there a way to refer to that spec.json namespace inside a RoleBinding subject?
Beta Was this translation helpful? Give feedback.
All reactions