From 3dbe34541e0d6ddb50af9070640a6ac7302bd952 Mon Sep 17 00:00:00 2001 From: liechtinat Date: Thu, 8 Sep 2022 15:54:23 +0200 Subject: [PATCH] feat!(helm): refactor helm chart - Group app settings below `config` key - Group deployment settings below `deployment` key - Fix hardcoded replicaCount Signed-off-by: nathanael.liechti@post.ch --- .../kubeinvaders/templates/deployment.yaml | 48 ++++++++----- .../templates/servicemonitor.yaml | 2 +- helm-charts/kubeinvaders/values.yaml | 72 +++++++++---------- 3 files changed, 62 insertions(+), 60 deletions(-) diff --git a/helm-charts/kubeinvaders/templates/deployment.yaml b/helm-charts/kubeinvaders/templates/deployment.yaml index eb8858e..ad97883 100644 --- a/helm-charts/kubeinvaders/templates/deployment.yaml +++ b/helm-charts/kubeinvaders/templates/deployment.yaml @@ -8,7 +8,7 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} spec: - replicas: 1 + replicas: {{ .Values.deployment.replicaCount }} selector: matchLabels: app.kubernetes.io/name: kubeinvaders @@ -20,48 +20,58 @@ spec: app.kubernetes.io/instance: {{ .Release.Name }} spec: serviceAccountName: kubeinvaders - {{- if .Values.securityContext }} - securityContext: {{- toYaml .Values.securityContext | nindent 8 }} + {{- with .Values.deployment.securityContext }} + securityContext: + {{- toYaml . | nindent 8 }} {{- end }} containers: - env: {{- if .Values.ingress.enabled }} - name: ENDPOINT - value: {{ required ".Values.ingress.hostName is required if Ingress are enabled" .Values.ingress.hostName }} + value: {{ required ".Values.ingress.hostName is required if Ingress is enabled" .Values.ingress.hostName }} {{- else }} - name: ENDPOINT - value: {{ required ".Values.route_host is required if Ingress are disabled" .Values.route_host }} + value: {{ required ".Values.route_host is required if Ingress is disabled" .Values.route_host }} {{- end }} - name: NAMESPACE - value: {{ .Values.target_namespace }} - {{- if .Values.extraEnv }} -{{ toYaml .Values.extraEnv | indent 10 }} + value: {{ .Values.config.target_namespace }} + - name: ALIENPROXIMITY + value: {{ .Values.config.alienProximity }} + - name: HITSLIMIT + value: {{ .Values.config.hitsLimit }} + - name: UPDATETIME + value: {{ .Values.config.updateTime }} + {{- if .Values.deployment.extraEnv }} +{{ toYaml .Values.deployment.extraEnv | indent 10 }} {{- end }} name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} + image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}" + imagePullPolicy: {{ .Values.deployment.image.pullPolicy }} ports: - name: http containerPort: 8080 protocol: TCP - {{- with .Values.resources }} + {{- with .Values.deployment.resources }} resources: + {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.extraVolumeMounts }} + {{- with .Values.deployment.extraVolumeMounts }} volumeMounts: + {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.nodeSelector }} + {{- with .Values.deployment.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with.Values.extraVolumes }} + {{- with.Values.deployment.extraVolumes }} volumes: + {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} + {{- with .Values.deployment.affinity }} affinity: {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: + {{- end }} + {{- with .Values.deployment.tolerations }} + tolerations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} diff --git a/helm-charts/kubeinvaders/templates/servicemonitor.yaml b/helm-charts/kubeinvaders/templates/servicemonitor.yaml index 6dcba55..0461f71 100644 --- a/helm-charts/kubeinvaders/templates/servicemonitor.yaml +++ b/helm-charts/kubeinvaders/templates/servicemonitor.yaml @@ -16,4 +16,4 @@ spec: matchLabels: app.kubernetes.io/name: kubeinvaders app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/helm-charts/kubeinvaders/values.yaml b/helm-charts/kubeinvaders/values.yaml index 3656057..e95d1cb 100644 --- a/helm-charts/kubeinvaders/values.yaml +++ b/helm-charts/kubeinvaders/values.yaml @@ -1,9 +1,17 @@ -# Default namespace target -target_namespace: "default" - # Default values for kubeinvaders. # This is a YAML-formatted file. # Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +config: + # target_namespace where kubeinvaders should be allowed to kill pods + target_namespace: "default" + alienProximity: 10 + hitsLimit: 1 + updateTime: 0.5 + rbac: # Specifies whether RBAC resources should be created create: true @@ -21,22 +29,33 @@ clusterRole: # true, a name based on fullname is generated name: kubeinvaders -replicaCount: 1 - -image: - repository: luckysideburn/kubeinvaders - tag: v1.9 - pullPolicy: Always - -nameOverride: "" -fullnameOverride: "" +deployment: + replicaCount: 1 + image: + repository: luckysideburn/kubeinvaders + tag: v1.9 + pullPolicy: Always + extraEnv: [] + # - name: FOO + # value: "BAR" + extraVolumes: [] + # - name: tmp + # emptyDir: {} + extraVolumeMounts: [] + # - name: tmp + # mountPath: /usr/local/openresty + resources: {} + nodeSelector: {} + tolerations: [] + securityContext: {} service: type: ClusterIP port: 8080 ingress: - enabled: true + enabled: false + legacyIngress: false annotations: nginx.ingress.kubernetes.io/ssl-redirect: "true" hostName: "" @@ -45,32 +64,5 @@ ingress: # Use route_host only if ingress is disabled route_host: "" -legacyIngress: false - -extraEnv: [] -# extraEnv: -# - name: ALIENPROXIMITY -# value: "10" -# - name: HITSLIMIT -# value: "1" -# - name: UPDATETIME -# value: "0.5" - -extraVolumes: [] - # - name: tmp - # emptyDir: {} - -extraVolumeMounts: [] - # - name: tmp - # mountPath: /usr/local/openresty - -resources: {} -nodeSelector: {} -tolerations: [] -securityContext: {} - # runAsUser: 999 - # runAsGroup: 999 - # fsGroup: 999 - serviceMonitor: enabled: false