Skip to content

Commit

Permalink
Minor fixes, extra labels, optional secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Friedhoff committed Nov 6, 2023
1 parent 24facba commit 8e7328e
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 20 deletions.
2 changes: 2 additions & 0 deletions apigateway/helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
{{- if .Values.secrets.generateAdminSecret }}
2. Get the admin password:
{{- $name := (printf "%s%s" (include "common.names.fullname" .) "-admin-password") }}
echo "Admin Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ $name }} -o jsonpath="{.data.password}" | base64 --decode)"
{{- end }}
7 changes: 7 additions & 0 deletions apigateway/helm/templates/_helper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,11 @@ Build the tls secret name, which holds the jks trust and keystore for API Gatewa
*/}}
{{- define "apigateway.elastictls" -}}
{{- default (printf "%s%s" (include "common.names.fullname" .) "-es-tls-secret") .Values.elasticsearch.tlsSecretName }}
{{- end }}

{{/*
Build the admin secret name, which holds the Administrator password
*/}}
{{- define "apigateway.adminsecret" -}}
{{- default (printf "%s%s" (include "common.names.fullname" .) "-admin-password") .Values.apigw.adminSecretName }}
{{- end }}
14 changes: 8 additions & 6 deletions apigateway/helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ metadata:
name: {{ include "common.names.fullname" . }}-config
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
data:
config-sources.yml: |
sources:
Expand Down Expand Up @@ -64,12 +67,11 @@ data:
{{ $key }}: {{ (tpl $value $) }}
{{- end }}
{{- end }}
{{ if .Values.apigw.applicationProperties -}}
application.properties: |
{{- nindent 6 .Values.applicationProperties }}
application.properties: |
{{- printf "%s" (tpl .Values.apigw.applicationProperties .) | nindent 4 }}
{{ else -}}
application.properties: |
user.Administrator.password=$env{ADMINISTRATOR_PASSWORD}
application.properties: |
user.Administrator.password=$env{ADMINISTRATOR_PASSWORD}
{{- end}}
6 changes: 6 additions & 0 deletions apigateway/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
Expand All @@ -39,6 +42,9 @@ spec:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "common.labels.matchLabels" . | nindent 8 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
15 changes: 14 additions & 1 deletion apigateway/helm/templates/elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
version: {{ .Values.elasticsearch.version }}
{{- if .Values.elasticsearch.image }}
Expand Down Expand Up @@ -50,7 +54,16 @@ spec:
{{- if not .Values.elasticsearch.defaultNodeSet.memoryMapping }}
node.store.allow_mmap: false
{{- end }}
podTemplate:
podTemplate:
metadata:
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 12 }}
{{- end }}
annotations:
{{- with .Values.elasticsearch.defaultNodeSet.annotations -}}
{{ toYaml . | nindent 12 }}
{{- end }}
spec:
initContainers:
{{- if and .Values.elasticsearch.defaultNodeSet.setMaxMapCount .Values.elasticsearch.defaultNodeSet.memoryMapping }}
Expand Down
3 changes: 3 additions & 0 deletions apigateway/helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ metadata:
name: {{ include "common.names.fullname" $ }}- {{- $name }}
labels:
{{- $labels | nindent 4 }}
{{- with $.Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
9 changes: 9 additions & 0 deletions apigateway/helm/templates/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ spec:
elasticsearchRef:
name: {{ include "common.names.fullname" . }}
podTemplate:
metadata:
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with .Values.kibana.annotations -}}
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: kibana
Expand Down
5 changes: 4 additions & 1 deletion apigateway/helm/templates/license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ metadata:
name: {{ include "common.names.fullname" . }}-license
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/resource-policy: keep
data:
licensekey:
{{ .Values.license | toYaml }}
Expand Down
4 changes: 3 additions & 1 deletion apigateway/helm/templates/nginx-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ metadata:
name: {{ include "common.names.fullname" . }}-nginx-conf
labels:
{{- include "common.labels.standard" . | nindent 4 }}

{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
data:
nginx.conf: |
user nginx;
Expand Down
6 changes: 6 additions & 0 deletions apigateway/helm/templates/nginx-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ kind: Deployment
metadata:
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
name: {{ include "common.names.fullname" . }}-nginx
spec:
replicas: 1
Expand All @@ -41,6 +44,9 @@ spec:
labels:
app: nginx
{{- include "common.labels.standard" . | nindent 8 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: nginx
Expand Down
3 changes: 3 additions & 0 deletions apigateway/helm/templates/nginx-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ metadata:
name: {{ include "common.names.fullname" . }}-nginx-svc
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.serviceType }}
ports:
Expand Down
22 changes: 21 additions & 1 deletion apigateway/helm/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
# * limitations under the License.
# *
# */
{{- if .Values.secrets.generateElasticSecrets -}}
{{- $name := (printf "%s%s" (include "apigateway.elasticsecret" .) "-es") }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $name }}
annotations:
helm.sh/resource-policy: keep
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
type: kubernetes.io/basic-auth
stringData:
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $name ) | default dict }}
Expand All @@ -41,6 +46,10 @@ metadata:
name: {{ $name }}
annotations:
helm.sh/resource-policy: keep
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
type: kubernetes.io/basic-auth
stringData:
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $name ) | default dict }}
Expand All @@ -59,23 +68,34 @@ metadata:
name: {{ $name }}
annotations:
helm.sh/resource-policy: keep
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
type: Opaque
stringData:
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $name ) | default dict }}
{{- $secretData := (get $secretObj "data") | default dict }}
{{- $password := get $secretData "password" | b64dec | default (randAlphaNum 12) }}
password: {{ $password }}
{{- end }}
{{- if .Values.secrets.generateAdminSecret }}
---
{{- $name := (printf "%s%s" (include "common.names.fullname" .) "-admin-password") }}
{{- $name := (include "apigateway.adminsecret" .) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $name }}
annotations:
helm.sh/resource-policy: keep
labels:
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
type: Opaque
stringData:
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $name ) | default dict }}
{{- $secretData := get $secretObj "data" | default dict }}
{{- $password := get $secretData "password" | b64dec | default (randAlphaNum 12) }}
password: {{ $password | quote }}
{{- end -}}
9 changes: 9 additions & 0 deletions apigateway/helm/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ metadata:
name: {{ include "common.names.fullname" . }}-rt
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.serviceType }}
ports:
Expand All @@ -42,6 +45,9 @@ metadata:
name: {{ include "common.names.fullname" . }}-admin
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.serviceType }}
ports:
Expand All @@ -61,6 +67,9 @@ metadata:
name: {{ include "common.names.fullname" . }}-ui
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.serviceType }}
sessionAffinity: ClientIP
Expand Down
Loading

0 comments on commit 8e7328e

Please sign in to comment.