Class: Kube::Cluster::Standard::RoleBinding
- Inherits:
-
Object
- Object
- Kube::Cluster::Standard::RoleBinding
- Defined in:
- lib/kube/cluster/standard/role_binding.rb
Overview
A RoleBinding that wires a Role to a ServiceAccount. This is just the binding resource – the Role and ServiceAccount are defined separately (and emitted together by ServiceAccountWithRole):
RoleBinding.new(role: MyRole, service_account: MyServiceAccount)
The subject namespace is left blank when the ServiceAccount has none, so the SetNamespace middleware fills it with the target namespace.
Instance Method Summary collapse
-
#initialize(role:, service_account:, name: nil, &block) ⇒ RoleBinding
constructor
A new instance of RoleBinding.
Constructor Details
#initialize(role:, service_account:, name: nil, &block) ⇒ RoleBinding
Returns a new instance of RoleBinding.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kube/cluster/standard/role_binding.rb', line 18 def initialize(role:, service_account:, name: nil, &block) name ||= role.name || service_account.name role_name = role.name || name subject = { kind: "ServiceAccount", name: service_account.name } subject[:namespace] = service_account.namespace if service_account.namespace super() do .name = name self.roleRef = { apiGroup: "rbac.authorization.k8s.io", kind: "Role", name: role_name, } self.subjects = [subject] instance_exec(&block) if block end end |