diff --git a/changelog/v0.30.1/custom-operator-namespace.yaml b/changelog/v0.30.1/custom-operator-namespace.yaml new file mode 100644 index 000000000..ad1be8974 --- /dev/null +++ b/changelog/v0.30.1/custom-operator-namespace.yaml @@ -0,0 +1,7 @@ +changelog: + - type: NEW_FEATURE + issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/9491 + resolvesIssue: false + description: > + Allows setting a optional operator namespace on the operator that will be used when applying the + deployment, service account, and service for said operator. diff --git a/codegen/model/chart.go b/codegen/model/chart.go index e4543fafb..c3b219d80 100644 --- a/codegen/model/chart.go +++ b/codegen/model/chart.go @@ -65,6 +65,9 @@ type JsonSchema struct { type Operator struct { Name string + // (Optional) If set, the operator deployment, service, and service account will use this namespace + Namespace string + // (Optional) To change the name referenced in the values file. If not specified a camelcase version of name is used ValuesFileNameOverride string diff --git a/codegen/templates/chart/operator-deployment.yamltmpl b/codegen/templates/chart/operator-deployment.yamltmpl index dee7699e9..655f34d16 100644 --- a/codegen/templates/chart/operator-deployment.yamltmpl +++ b/codegen/templates/chart/operator-deployment.yamltmpl @@ -15,6 +15,7 @@ Expressions evaluating SKv2 Config use "[[" and "]]" [[- $customDeploymentAnnotations := $operator.Deployment.CustomDeploymentAnnotations -]] [[- $customServiceLabels := $operator.Service.CustomLabels -]] [[- $customServiceAnnotations := $operator.Service.CustomAnnotations ]] +[[- $customNamespace := $operator.Namespace ]] {{- $[[ $operatorVar ]] := [[ (opVar $operator) ]]}} --- @@ -49,7 +50,11 @@ metadata: [[ $key ]]: [[ $value ]] [[- end ]] name: [[ $operator.Name ]] + [[- if $customNamespace ]] + namespace: [[ $customNamespace ]] + [[- else ]] namespace: {{ .Release.Namespace }} + [[- end ]] spec: selector: matchLabels: @@ -177,7 +182,11 @@ metadata: {{- end }} {{- end}} name: [[ $operator.Name ]] - namespace: {{ $.Release.Namespace }} + [[- if $customNamespace ]] + namespace: [[ $customNamespace ]] + [[- else ]] + namespace: {{ .Release.Namespace }} + [[- end ]] {{- end }} @@ -200,7 +209,11 @@ metadata: [[ $key ]]: [[ $value ]] [[- end ]] name: [[ $operator.Name ]] - namespace: {{ $.Release.Namespace }} + [[- if $customNamespace ]] + namespace: [[ $customNamespace ]] + [[- else ]] + namespace: {{ .Release.Namespace }} + [[- end ]] spec: selector: app: [[ $operator.Name ]] diff --git a/codegen/test/chart-envvars/templates/deployment.yaml b/codegen/test/chart-envvars/templates/deployment.yaml index e034ceae5..40aa452dc 100644 --- a/codegen/test/chart-envvars/templates/deployment.yaml +++ b/codegen/test/chart-envvars/templates/deployment.yaml @@ -111,7 +111,7 @@ metadata: {{- end }} {{- end}} name: painter - namespace: {{ $.Release.Namespace }} + namespace: {{ .Release.Namespace }} {{- end }} diff --git a/codegen/test/chart-no-desc/templates/deployment.yaml b/codegen/test/chart-no-desc/templates/deployment.yaml index 34c4de1e6..e0a1cb765 100644 --- a/codegen/test/chart-no-desc/templates/deployment.yaml +++ b/codegen/test/chart-no-desc/templates/deployment.yaml @@ -184,7 +184,7 @@ metadata: {{- end }} {{- end}} name: painter - namespace: {{ $.Release.Namespace }} + namespace: {{ .Release.Namespace }} {{- end }} diff --git a/codegen/test/chart-sidecar/templates/deployment.yaml b/codegen/test/chart-sidecar/templates/deployment.yaml index 7b9c5d259..76a2878c9 100644 --- a/codegen/test/chart-sidecar/templates/deployment.yaml +++ b/codegen/test/chart-sidecar/templates/deployment.yaml @@ -156,7 +156,7 @@ metadata: {{- end }} {{- end}} name: painter - namespace: {{ $.Release.Namespace }} + namespace: {{ .Release.Namespace }} {{- end }} diff --git a/codegen/test/chart/templates/deployment.yaml b/codegen/test/chart/templates/deployment.yaml index 34c4de1e6..e0a1cb765 100644 --- a/codegen/test/chart/templates/deployment.yaml +++ b/codegen/test/chart/templates/deployment.yaml @@ -184,7 +184,7 @@ metadata: {{- end }} {{- end}} name: painter - namespace: {{ $.Release.Namespace }} + namespace: {{ .Release.Namespace }} {{- end }} diff --git a/codegen/test/name_override_chart/templates/deployment.yaml b/codegen/test/name_override_chart/templates/deployment.yaml index 911ba1fcf..f48d7a388 100644 --- a/codegen/test/name_override_chart/templates/deployment.yaml +++ b/codegen/test/name_override_chart/templates/deployment.yaml @@ -113,7 +113,7 @@ metadata: {{- end }} {{- end}} name: painter-original-name - namespace: {{ $.Release.Namespace }} + namespace: {{ .Release.Namespace }} {{- end }}