role_binding.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from kubernetes.client import V1ObjectMeta, V1RoleBinding, V1RoleRef, V1Subject
  10. from materialize.cloudtest import DEFAULT_K8S_NAMESPACE
  11. from materialize.cloudtest.k8s.api.k8s_role_binding import K8sRoleBinding
  12. class AdminRoleBinding(K8sRoleBinding):
  13. def __init__(self, namespace: str = DEFAULT_K8S_NAMESPACE) -> None:
  14. super().__init__(namespace)
  15. metadata = V1ObjectMeta(name="admin-binding")
  16. role_ref = V1RoleRef(
  17. api_group="rbac.authorization.k8s.io", kind="ClusterRole", name="admin"
  18. )
  19. subjects = [V1Subject(kind="ServiceAccount", name="default")]
  20. self.role_binding = V1RoleBinding(
  21. api_version="rbac.authorization.k8s.io/v1",
  22. kind="RoleBinding",
  23. metadata=metadata,
  24. role_ref=role_ref,
  25. subjects=subjects,
  26. )