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

microservice/templates/_helpers.tpl #200

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions charts/microservice/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apiVersion: v2
name: microservice
fullname: microservice-application
description: A Helm chart for a microservice in Kubernetes

type: application
Expand Down
15 changes: 15 additions & 0 deletions charts/microservice/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "microservice.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "microservice.fullname" -}}
{{- printf "%s-%s" (include "microservice.name" .) .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "microservice.labels" -}}
app: {{ include "microservice.name" . }}
{{- end -}}

{{- define "microservice.selectorLabels" -}}
app: {{ include "microservice.name" . }}
{{- end -}}
15 changes: 13 additions & 2 deletions charts/microservice/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,16 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
containerPort: {{ .Values.httpPort }}
protocol: {{ .Values.protocol }}
env:
- name: MY_CONFIG_KEY
valueFrom:
configMapKeyRef:
name: {{ include "microservice.fullname" . }}-config
key: my-config-key
- name: MY_SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ include "microservice.fullname" . }}-secret
key: my-secret-key
6 changes: 6 additions & 0 deletions charts/microservice/templates/nginx-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "microservice.fullname" . }}-config
data:
my-config-key: my-config-value
7 changes: 7 additions & 0 deletions charts/microservice/templates/nginx-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "microservice.fullname" . }}-secret
type: Opaque
data:
my-secret-key: {{ "my-secret-value" | b64enc }}
4 changes: 4 additions & 0 deletions charts/microservice/templates/nginx-service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "microservice.fullname" . }}-sa
11 changes: 5 additions & 6 deletions charts/microservice/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ metadata:
labels:
{{- include "microservice.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "microservice.selectorLabels" . | nindent 4 }}
ports:
- name: http
protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.httpPort }}
23 changes: 19 additions & 4 deletions charts/microservice/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
replicaCount: 1

labels:
app: micro

selectorLabels:
app: microservice
release: stable

replicaCount: 3

image:
repository: nginx # your microservice image name
repository: nginx
tag: latest
pullPolicy: IfNotPresent
tag: "latest" # your microservice image tag

protocol: TCP

service:
type: ClusterIP
port: 80

configMap:
my-config-key: nginx-config-value

secret:
my-secret-key: nginx-secret-value
Loading