Skip to content

Commit

Permalink
Merge pull request #4388 from monteiro-renato/patch-1
Browse files Browse the repository at this point in the history
🐛 fix: (helm/v1alpha1): Add missing prefixes in various k8s resources
  • Loading branch information
k8s-ci-robot authored Nov 25, 2024
2 parents c3b2eb9 + cd5f6b1 commit 077dea8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
14 changes: 14 additions & 0 deletions pkg/plugins/optional/helm/v1alpha/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
contentStr = strings.Replace(contentStr,
"name: metrics-reader",
fmt.Sprintf("name: %s-metrics-reader", projectName), 1)

contentStr = strings.Replace(contentStr,
"name: metrics-auth-role",
fmt.Sprintf("name: %s-metrics-auth-role", projectName), -1)
contentStr = strings.Replace(contentStr,
"name: metrics-auth-rolebinding",
fmt.Sprintf("name: %s-metrics-auth-rolebinding", projectName), 1)

if strings.Contains(contentStr, "-controller-manager") &&
strings.Contains(contentStr, "kind: ServiceAccount") &&
!strings.Contains(contentStr, "RoleBinding") {
Expand All @@ -312,6 +320,12 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
contentStr = strings.Replace(contentStr,
"name: leader-election-rolebinding",
fmt.Sprintf("name: %s-leader-election-rolebinding", projectName), 1)
contentStr = strings.Replace(contentStr,
"name: manager-role",
fmt.Sprintf("name: %s-manager-role", projectName), -1)
contentStr = strings.Replace(contentStr,
"name: manager-rolebinding",
fmt.Sprintf("name: %s-manager-rolebinding", projectName), 1)

// The generated files do not include the namespace
if strings.Contains(contentStr, "leader-election-rolebinding") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var _ machinery.Template = &ManagerDeployment{}
// ManagerDeployment scaffolds the manager Deployment for the Helm chart
type ManagerDeployment struct {
machinery.TemplateMixin
machinery.ProjectNameMixin

// DeployImages if true will scaffold the env with the images
DeployImages bool
Expand Down Expand Up @@ -57,7 +58,7 @@ func (f *ManagerDeployment) SetTemplateDefaults() error {
const managerDeploymentTemplate = `apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
name: {{ .ProjectName }}-controller-manager
namespace: {{ "{{ .Release.Namespace }}" }}
labels:
{{ "{{- include \"chart.labels\" . | nindent 4 }}" }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
name: project-v4-with-plugins-controller-manager
namespace: {{ .Release.Namespace }}
labels:
{{- include "chart.labels" . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ClusterRole
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: metrics-auth-role
name: project-v4-with-plugins-metrics-auth-role
rules:
- apiGroups:
- authentication.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ kind: ClusterRoleBinding
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: metrics-auth-rolebinding
name: project-v4-with-plugins-metrics-auth-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: metrics-auth-role
name: project-v4-with-plugins-metrics-auth-role
subjects:
- kind: ServiceAccount
name: project-v4-with-plugins-controller-manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: ClusterRole
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: manager-role
name: project-v4-with-plugins-manager-role
rules:
- apiGroups:
- ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ kind: ClusterRoleBinding
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: manager-rolebinding
name: project-v4-with-plugins-manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: manager-role
name: project-v4-with-plugins-manager-role
subjects:
- kind: ServiceAccount
name: project-v4-with-plugins-controller-manager
Expand Down

0 comments on commit 077dea8

Please sign in to comment.