Standardize the naming conventions for karmada system roles

Signed-off-by: zhzhuang-zju <m17799853869@163.com>
This commit is contained in:
zhzhuang-zju 2024-11-19 19:06:28 +08:00
parent 7ac890f834
commit 26103ecdff
5 changed files with 32 additions and 28 deletions

View File

@ -4,13 +4,8 @@
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
annotations:
# refer to https://kubernetes.io/docs/reference/access-authn-authz/rbac/#auto-reconciliation
# and https://kubernetes.io/docs/reference/access-authn-authz/rbac/#kubectl-auth-reconcile
rbac.authorization.kubernetes.io/autoupdate: "true"
labels: labels:
# refer to https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings karmada.io/bootstrapping: rbac-defaults
kubernetes.io/bootstrapping: rbac-defaults
# used to aggregate rules to view clusterrole # used to aggregate rules to view clusterrole
rbac.authorization.k8s.io/aggregate-to-view: "true" rbac.authorization.k8s.io/aggregate-to-view: "true"
name: karmada-view name: karmada-view
@ -73,13 +68,8 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
annotations:
# refer to https://kubernetes.io/docs/reference/access-authn-authz/rbac/#auto-reconciliation
# and https://kubernetes.io/docs/reference/access-authn-authz/rbac/#kubectl-auth-reconcile
rbac.authorization.kubernetes.io/autoupdate: "true"
labels: labels:
# refer to https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings karmada.io/bootstrapping: rbac-defaults
kubernetes.io/bootstrapping: rbac-defaults
# used to aggregate rules to view clusterrole # used to aggregate rules to view clusterrole
rbac.authorization.k8s.io/aggregate-to-edit: "true" rbac.authorization.k8s.io/aggregate-to-edit: "true"
name: karmada-edit name: karmada-edit

View File

@ -16,7 +16,9 @@ data:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: karmada:bootstrap-signer-clusterinfo labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:bootstrap-signer-clusterinfo
namespace: kube-public namespace: kube-public
rules: rules:
- apiGroups: - apiGroups:
@ -32,12 +34,14 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: karmada:bootstrap-signer-clusterinfo labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:bootstrap-signer-clusterinfo
namespace: kube-public namespace: kube-public
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: karmada:bootstrap-signer-clusterinfo name: system:karmada:bootstrap-signer-clusterinfo
subjects: subjects:
- apiGroup: rbac.authorization.k8s.io - apiGroup: rbac.authorization.k8s.io
kind: User kind: User
@ -47,7 +51,9 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: karmada:agent-bootstrap labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:agent-bootstrap
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: ClusterRole kind: ClusterRole
@ -61,7 +67,9 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: karmada:agent-autoapprove-bootstrap labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:agent-autoapprove-bootstrap
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: ClusterRole kind: ClusterRole
@ -75,7 +83,9 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: karmada:agent-autoapprove-certificate-rotation labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:agent-autoapprove-certificate-rotation
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: ClusterRole kind: ClusterRole
@ -89,6 +99,8 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:agent name: system:karmada:agent
rules: rules:
- apiGroups: - apiGroups:
@ -176,6 +188,8 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
labels:
karmada.io/bootstrapping: rbac-defaults
name: system:karmada:agent name: system:karmada:agent
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io

View File

@ -23,7 +23,7 @@ data:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: karmada:bootstrap-signer-clusterinfo name: system:karmada:bootstrap-signer-clusterinfo
namespace: kube-public namespace: kube-public
{{- if "karmada.commonLabels" }} {{- if "karmada.commonLabels" }}
labels: labels:
@ -42,7 +42,7 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: karmada:bootstrap-signer-clusterinfo name: system:karmada:bootstrap-signer-clusterinfo
namespace: kube-public namespace: kube-public
{{- if "karmada.commonLabels" }} {{- if "karmada.commonLabels" }}
labels: labels:
@ -51,7 +51,7 @@ metadata:
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: karmada:bootstrap-signer-clusterinfo name: system:karmada:bootstrap-signer-clusterinfo
subjects: subjects:
- apiGroup: rbac.authorization.k8s.io - apiGroup: rbac.authorization.k8s.io
kind: User kind: User
@ -60,7 +60,7 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: karmada:agent-bootstrap name: system:karmada:agent-bootstrap
{{- if "karmada.commonLabels" }} {{- if "karmada.commonLabels" }}
labels: labels:
{{- include "karmada.commonLabels" . | nindent 4 }} {{- include "karmada.commonLabels" . | nindent 4 }}
@ -77,7 +77,7 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: karmada:agent-autoapprove-bootstrap name: system:karmada:agent-autoapprove-bootstrap
{{- if "karmada.commonLabels" }} {{- if "karmada.commonLabels" }}
labels: labels:
{{- include "karmada.commonLabels" . | nindent 4 }} {{- include "karmada.commonLabels" . | nindent 4 }}
@ -94,7 +94,7 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: karmada:agent-autoapprove-certificate-rotation name: system:karmada:agent-autoapprove-certificate-rotation
{{- if "karmada.commonLabels" }} {{- if "karmada.commonLabels" }}
labels: labels:
{{- include "karmada.commonLabels" . | nindent 4 }} {{- include "karmada.commonLabels" . | nindent 4 }}

View File

@ -29,13 +29,13 @@ const (
// KarmadaAgentBootstrapperClusterRoleName defines the name of the auto-bootstrapped ClusterRole for letting someone post a CSR // KarmadaAgentBootstrapperClusterRoleName defines the name of the auto-bootstrapped ClusterRole for letting someone post a CSR
KarmadaAgentBootstrapperClusterRoleName = "system:node-bootstrapper" KarmadaAgentBootstrapperClusterRoleName = "system:node-bootstrapper"
// KarmadaAgentBootstrap defines the name of the ClusterRoleBinding that lets Karmada Agent post CSRs // KarmadaAgentBootstrap defines the name of the ClusterRoleBinding that lets Karmada Agent post CSRs
KarmadaAgentBootstrap = "karmada:agent-bootstrap" KarmadaAgentBootstrap = "system:karmada:agent-bootstrap"
// KarmadaAgentGroup defines the group of Karmada Agent // KarmadaAgentGroup defines the group of Karmada Agent
KarmadaAgentGroup = "system:nodes" KarmadaAgentGroup = "system:nodes"
// KarmadaAgentAutoApproveBootstrapClusterRoleBinding defines the name of the ClusterRoleBinding that makes the csrapprover approve agent CSRs // KarmadaAgentAutoApproveBootstrapClusterRoleBinding defines the name of the ClusterRoleBinding that makes the csrapprover approve agent CSRs
KarmadaAgentAutoApproveBootstrapClusterRoleBinding = "karmada:agent-autoapprove-bootstrap" KarmadaAgentAutoApproveBootstrapClusterRoleBinding = "system:karmada:agent-autoapprove-bootstrap"
// KarmadaAgentAutoApproveCertificateRotationClusterRoleBinding defines name of the ClusterRoleBinding that makes the csrapprover approve agent auto rotated CSRs // KarmadaAgentAutoApproveCertificateRotationClusterRoleBinding defines name of the ClusterRoleBinding that makes the csrapprover approve agent auto rotated CSRs
KarmadaAgentAutoApproveCertificateRotationClusterRoleBinding = "karmada:agent-autoapprove-certificate-rotation" KarmadaAgentAutoApproveCertificateRotationClusterRoleBinding = "system:karmada:agent-autoapprove-certificate-rotation"
// CSRAutoApprovalClusterRoleName defines the name of the auto-bootstrapped ClusterRole for making the csrapprover controller auto-approve the CSR // CSRAutoApprovalClusterRoleName defines the name of the auto-bootstrapped ClusterRole for making the csrapprover controller auto-approve the CSR
CSRAutoApprovalClusterRoleName = "system:certificates.k8s.io:certificatesigningrequests:nodeclient" CSRAutoApprovalClusterRoleName = "system:certificates.k8s.io:certificatesigningrequests:nodeclient"
// KarmadaAgentSelfCSRAutoApprovalClusterRoleName is a role for automatic CSR approvals for automatically rotated agent certificates // KarmadaAgentSelfCSRAutoApprovalClusterRoleName is a role for automatic CSR approvals for automatically rotated agent certificates

View File

@ -34,7 +34,7 @@ import (
const ( const (
// BootstrapSignerClusterRoleName sets the name for the ClusterRole that allows access to ConfigMaps in the kube-public ns // BootstrapSignerClusterRoleName sets the name for the ClusterRole that allows access to ConfigMaps in the kube-public ns
BootstrapSignerClusterRoleName = "karmada:bootstrap-signer-clusterinfo" BootstrapSignerClusterRoleName = "system:karmada:bootstrap-signer-clusterinfo"
) )
// CreateBootstrapConfigMapIfNotExists creates the kube-public ConfigMap if it doesn't exist already // CreateBootstrapConfigMapIfNotExists creates the kube-public ConfigMap if it doesn't exist already