[bitnami/apache] Lint chart

Signed-off-by: juan131 <juan@bitnami.com>
This commit is contained in:
juan131
2019-11-14 12:22:03 +01:00
parent 32ac19690c
commit 4103cdd1f2
8 changed files with 220 additions and 160 deletions

View File

@@ -23,6 +23,24 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "apache.labels" -}}
app.kubernetes.io/name: {{ include "apache.name" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "apache.matchLabels" -}}
app.kubernetes.io/name: {{ include "apache.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Return the proper Apache image name
*/}}
@@ -120,7 +138,7 @@ emptyDir: {}
{{- else if .Values.htdocsConfigMap }}
configMap:
name: {{ .Values.htdocsConfigMap }}
{{- else if .Values.htdocsPVC }}
{{- else if .Values.htdocsPVC }}
persistentVolumeClaim:
claimName: {{ .Values.htdocsPVC }}
{{- end }}
@@ -216,4 +234,17 @@ Get the httpd.conf config map name.
{{- else -}}
{{- printf "%s-httpd-conf" (include "apache.fullname" . ) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Renders a value that contains template.
Usage:
{{ include "apache.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "apache.tplValue" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}

View File

@@ -3,11 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "apache.fullname" . }}-vhosts
labels:
app.kubernetes.io/name: {{ include "apache.fullname" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
labels: {{- include "apache.labels" . | nindent 4 }}
data:
{{ (.Files.Glob "files/vhosts/*.conf").AsConfig | indent 2 }}
{{ end }}
{{ end }}

View File

@@ -3,11 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "apache.fullname" . }}-httpd-conf
labels:
app.kubernetes.io/name: {{ include "apache.fullname" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
labels: {{- include "apache.labels" . | nindent 4 }}
data:
{{ (.Files.Glob "files/httpd.conf").AsConfig | indent 2 }}
{{ end }}
{{ end }}

View File

@@ -1,26 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "apache.fullname" . }}
labels:
app.kubernetes.io/name: {{ template "apache.fullname" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
name: {{ include "apache.fullname" . }}
labels: {{- include "apache.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ template "apache.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
matchLabels: {{- include "apache.matchLabels" . | nindent 6 }}
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "apache.fullname" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if or .Values.podAnnotations .Values.metrics.enabled }}
labels: {{- include "apache.labels" . | nindent 8 }}
{{- if or .Values.podAnnotations (and .Values.metrics.enabled .Values.metrics.podAnnotations) }}
annotations:
{{- if .Values.podAnnotations }}
{{- toYaml .Values.podAnnotations | nindent 8 }}
@@ -30,15 +20,24 @@ spec:
{{- end }}
{{- end }}
spec:
{{- include "apache.imagePullSecrets" . | nindent 6 }}
{{- include "apache.imagePullSecrets" . | nindent 6 }}
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "status.localhost"
{{- if .Values.affinity }}
affinity: {{- include "apache.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{- include "apache.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{- include "apache.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.cloneHtdocsFromGit.enabled }}
initContainers:
- name: git-clone-repository
image: "{{ template "git.image" . }}"
image: {{ include "git.image" . }}
imagePullPolicy: {{ .Values.git.pullPolicy | quote }}
command:
- /bin/bash
@@ -50,7 +49,7 @@ spec:
mountPath: /app
containers:
- name: git-repo-syncer
image: "{{ template "git.image" . }}"
image: {{ include "git.image" . }}
imagePullPolicy: {{ .Values.git.pullPolicy | quote }}
command:
- /bin/bash
@@ -66,9 +65,12 @@ spec:
{{- else }}
containers:
{{- end }}
- name: "{{ template "apache.fullname" . }}"
image: "{{ template "apache.image" . }}"
- name: apache
image: {{ include "apache.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.image.debug | quote }}
ports:
- name: http
containerPort: 8080
@@ -96,7 +98,9 @@ spec:
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
resources: {{ toYaml .Values.resources | nindent 12 }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
volumeMounts:
{{- if (include "apache.useHtdocs" .) }}
- name: htdocs
@@ -131,7 +135,9 @@ spec:
port: metrics
initialDelaySeconds: 5
timeoutSeconds: 1
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- end }}
{{- end }}
volumes:
{{- if (include "apache.useHtdocs" .) }}
@@ -148,6 +154,3 @@ spec:
configMap:
name: {{ include "apache.httpdConfConfigMap" . }}
{{- end }}
{{- with .Values.affinity }}
affinity: {{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -2,12 +2,8 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "apache.fullname" . }}
labels:
app.kubernetes.io/name: {{ template "apache.fullname" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
name: {{ include "apache.fullname" . }}
labels: {{- include "apache.labels" . | nindent 4 }}
annotations:
{{- if .Values.ingress.certManager }}
kubernetes.io/tls-acme: "true"

View File

@@ -1,32 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "apache.fullname" . }}
labels:
app.kubernetes.io/name: {{ template "apache.fullname" . }}
helm.sh/chart: {{ include "apache.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
name: {{ include "apache.fullname" . }}
labels: {{- include "apache.labels" . | nindent 4 }}
annotations: {{ include "apache.tplValue" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
{{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}
{{- if (and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP))) }}
{{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
{{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http)) }}
nodePort: {{ .Values.service.nodePorts.http }}
{{- end }}
- name: https
port: {{ .Values.service.httpsPort }}
targetPort: https
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.https)))}}
{{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.https)) }}
nodePort: {{ .Values.service.nodePorts.https }}
{{- end }}
selector:
app.kubernetes.io/name: {{ template "apache.fullname" . }}
selector: {{- include "apache.matchLabels" . | nindent 4 }}