Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add the namespace resource within helm templates #1332

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions charts/gateway-helm/templates/certgen-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "eg.fullname" . }}-certgen
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
annotations:
Expand All @@ -11,6 +12,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "eg.fullname" . }}-certgen
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
annotations:
Expand All @@ -29,6 +31,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "eg.fullname" . }}-certgen
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
annotations:
Expand Down
1 change: 1 addition & 0 deletions charts/gateway-helm/templates/certgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "eg.fullname" . }}-certgen
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
annotations:
Expand Down
1 change: 1 addition & 0 deletions charts/gateway-helm/templates/envoy-gateway-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: envoy-gateway-config
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
data:
Expand Down
2 changes: 2 additions & 0 deletions charts/gateway-helm/templates/envoy-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: envoy-gateway
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: envoy-gateway
namespace: '{{ .Release.Namespace }}'
labels:
control-plane: envoy-gateway
{{- include "eg.labels" . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: envoy-gateway-metrics-service
namespace: '{{ .Release.Namespace }}'
labels:
control-plane: envoy-gateway
{{- include "eg.labels" . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/gateway-helm/templates/envoy-gateway-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: envoy-gateway
namespace: '{{ .Release.Namespace }}'
labels:
control-plane: envoy-gateway
{{- include "eg.labels" . | nindent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/gateway-helm/templates/infra-manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "eg.fullname" . }}-infra-manager
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
rules:
Expand Down Expand Up @@ -29,6 +30,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "eg.fullname" . }}-infra-manager
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
roleRef:
Expand Down
2 changes: 2 additions & 0 deletions charts/gateway-helm/templates/leader-election-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "eg.fullname" . }}-leader-election-role
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
rules:
Expand Down Expand Up @@ -41,6 +42,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "eg.fullname" . }}-leader-election-rolebinding
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
roleRef:
Expand Down
1 change: 1 addition & 0 deletions charts/gateway-helm/templates/metrics-reader-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "eg.fullname" . }}-metrics-reader
namespace: '{{ .Release.Namespace }}'
labels:
{{- include "eg.labels" . | nindent 4 }}
rules:
Expand Down
6 changes: 6 additions & 0 deletions charts/gateway-helm/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ if .Values.createNamespace }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I'm out of date, I recall it's not a good practice to put namespace in a helm chart.

Copy link
Contributor Author

@arkodg arkodg Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not, but we are using helm as the source of truth for manifest templates, in the previous release it was kustomize

  • for the common case using helm install we skip this file (createNamespace is false)
  • for the manifest generation case to support install via 1 single YAML, we rely on it

apiVersion: v1
kind: Namespace
metadata:
name: '{{ .Release.Namespace }}'
{{ end }}
1 change: 1 addition & 0 deletions charts/gateway-helm/values.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ envoyGatewayMetricsService:
protocol: TCP
targetPort: https

createNamespace: false
2 changes: 1 addition & 1 deletion tools/make/kube.mk
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ generate-manifests: helm-generate ## Generate Kubernetes release manifests.
@$(LOG_TARGET)
@$(call log, "Generating kubernetes manifests")
mkdir -p $(OUTPUT_DIR)/
helm template eg charts/gateway-helm --include-crds --set deployment.envoyGateway.imagePullPolicy=$(IMAGE_PULL_POLICY) > $(OUTPUT_DIR)/install.yaml
helm template --set createNamespace=true eg charts/gateway-helm --include-crds --set deployment.envoyGateway.imagePullPolicy=$(IMAGE_PULL_POLICY) --namespace envoy-gateway-system > $(OUTPUT_DIR)/install.yaml
@$(call log, "Added: $(OUTPUT_DIR)/install.yaml")
cp examples/kubernetes/quickstart.yaml $(OUTPUT_DIR)/quickstart.yaml
@$(call log, "Added: $(OUTPUT_DIR)/quickstart.yaml")
Expand Down