Skip to content

Commit

Permalink
Fix immutable RoleBinding.roleRef
Browse files Browse the repository at this point in the history
  • Loading branch information
vpnachev committed Oct 22, 2024
1 parent c38c17c commit 4ceabc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/controller/lifecycle/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,12 +708,16 @@ func getRoleBinding(scope lakom.ScopeType, shootAccessServiceAccountName string)
Namespace: metav1.NamespaceSystem,
},
}
annotations := map[string]string{
resourcesv1alpha1.DeleteOnInvalidUpdate: "true",
}

if scope == lakom.Cluster {
return &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LakomResourceReader,
Labels: getLabels(),
Name: constants.LakomResourceReader,
Labels: getLabels(),
Annotations: annotations,
},
RoleRef: roleRef,
Subjects: subjects,
Expand All @@ -722,9 +726,10 @@ func getRoleBinding(scope lakom.ScopeType, shootAccessServiceAccountName string)

return &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LakomResourceReader,
Namespace: metav1.NamespaceSystem,
Labels: getLabels(),
Name: constants.LakomResourceReader,
Namespace: metav1.NamespaceSystem,
Labels: getLabels(),
Annotations: annotations,
},
RoleRef: roleRef,
Subjects: subjects,
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/lifecycle/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ func expectedShootRoleBinding(saName string, lakomScope lakom.ScopeType) string
return `apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
resources.gardener.cloud/delete-on-invalid-update: "true"
creationTimestamp: null
labels:
app.kubernetes.io/name: lakom
Expand All @@ -370,6 +372,8 @@ subjects:
return `apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
annotations:
resources.gardener.cloud/delete-on-invalid-update: "true"
creationTimestamp: null
labels:
app.kubernetes.io/name: lakom
Expand Down

0 comments on commit 4ceabc2

Please sign in to comment.