Skip to content

Commit

Permalink
✨ Cherry pick enable-sync-lables to 0.13 (#515)
Browse files Browse the repository at this point in the history
* sync labels from klusterlet to all agent resources (#475)

Signed-off-by: Zhiwei Yin <zyin@redhat.com>

* add enable-sync-labels flag to klusterlet operator (#505)

Signed-off-by: Zhiwei Yin <zyin@redhat.com>

* fix issue that pull secret and ns are synced labels when enable-sync-labels is disabled (#511)

Signed-off-by: Zhiwei Yin <zyin@redhat.com>

---------

Signed-off-by: Zhiwei Yin <zyin@redhat.com>
  • Loading branch information
zhiweiyin318 authored Jun 13, 2024
1 parent c41fe8c commit 353a850
Show file tree
Hide file tree
Showing 43 changed files with 571 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: open-cluster-management:{{ .KlusterletName }}-registration:addon-management
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# Allow agent to get/list/watch/create/delete/update/patch secrets.
- apiGroups: [""]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: open-cluster-management:{{ .KlusterletName }}-registration:agent
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# Allow agent to get/list/watch nodes
# list nodes to calculates the capacity and allocatable resources of the managed cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-registration:addon-management
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-registration:agent
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ kind: ServiceAccount
metadata:
name: {{ .RegistrationServiceAccount }}
namespace: {{ .KlusterletNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
imagePullSecrets:
- name: open-cluster-management-image-pull-credentials
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:execution
labels:
open-cluster-management.io/aggregate-to-work: "true"
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# Allow agent to get/list/watch/create/delete crds.
- apiGroups: ["apiextensions.k8s.io"]
Expand Down
6 changes: 6 additions & 0 deletions manifests/klusterlet/managed/klusterlet-work-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:agent
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# Allow agent to managed appliedmanifestworks
- apiGroups: ["work.open-cluster-management.io"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:aggregate
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:execution-admin
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:execution
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:agent
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ kind: ServiceAccount
metadata:
name: {{ .WorkServiceAccount }}
namespace: {{ .KlusterletNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
imagePullSecrets:
- name: open-cluster-management-image-pull-credentials
11 changes: 10 additions & 1 deletion manifests/klusterlet/management/klusterlet-agent-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ metadata:
namespace: {{ .AgentNamespace }}
labels:
app: klusterlet-agent
createdBy: klusterlet
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
spec:
replicas: {{ .Replica }}
selector:
Expand All @@ -17,6 +21,11 @@ spec:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
app: klusterlet-agent
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
spec:
{{if .HubApiServerHostAlias }}
hostAliases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-registration:addon-management
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# Allow agent to get/list/watch/create/delete/update/patch secrets, registration agent needs secret permission for an
# arbitrary namespace to create hub-kubeconfig secret for an addon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-registration:addon-management
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ metadata:
namespace: {{ .AgentNamespace }}
labels:
app: klusterlet-registration-agent
createdBy: klusterlet
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
spec:
replicas: {{ .Replica }}
selector:
Expand All @@ -17,6 +21,11 @@ spec:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
app: klusterlet-registration-agent
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
spec:
{{if .HubApiServerHostAlias }}
hostAliases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ kind: Role
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-registration:agent
namespace: {{ .AgentNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# leader election needs to operate configmaps and leases
- apiGroups: [""]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ kind: RoleBinding
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-registration:agent
namespace: kube-system
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ kind: RoleBinding
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-registration:agent
namespace: {{ .AgentNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ kind: ServiceAccount
metadata:
name: {{ .RegistrationServiceAccount }}
namespace: {{ .AgentNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
imagePullSecrets:
- name: open-cluster-management-image-pull-credentials
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ kind: Role
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}:extension-apiserver
namespace: kube-system
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
- apiGroups: [""]
resources: ["configmaps"]
Expand Down
11 changes: 10 additions & 1 deletion manifests/klusterlet/management/klusterlet-work-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ metadata:
namespace: {{ .AgentNamespace }}
labels:
app: klusterlet-manifestwork-agent
createdBy: klusterlet
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
spec:
replicas: {{ .Replica }}
selector:
Expand All @@ -17,6 +21,11 @@ spec:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
app: klusterlet-manifestwork-agent
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
spec:
{{if .HubApiServerHostAlias }}
hostAliases:
Expand Down
6 changes: 6 additions & 0 deletions manifests/klusterlet/management/klusterlet-work-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ kind: Role
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-work:agent
namespace: {{ .AgentNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
rules:
# leader election needs to operate configmaps and leases
- apiGroups: [""]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ kind: RoleBinding
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-work:agent
namespace: kube-system
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ kind: RoleBinding
metadata:
name: open-cluster-management:management:{{ .KlusterletName }}-work:agent
namespace: {{ .AgentNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ kind: ServiceAccount
metadata:
name: {{ .WorkServiceAccount }}
namespace: {{ .AgentNamespace }}
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
imagePullSecrets:
- name: open-cluster-management-image-pull-credentials
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-registration-operator:operator-kube111
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: open-cluster-management:{{ .KlusterletName }}-work:agent-kube111
labels:
{{ if gt (len .Labels) 0 }}
{{ range $key, $value := .Labels }}
{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Loading

0 comments on commit 353a850

Please sign in to comment.