Skip to content

Commit

Permalink
feature expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
tde committed Feb 22, 2022
1 parent 8e47d6b commit 413fd29
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
apiVersion: v2
name: microservice
version: 0.3.1
appVersion: 0.3.1
version: 0.4.0
appVersion: 0.4.0
description: A Helm chart which provide a DRY microservice deployment mechanism
keywords:
- microservice
Expand Down
1 change: 1 addition & 0 deletions config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test configuration file
14 changes: 12 additions & 2 deletions templates/_configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
{{- define "configmap" -}}
{{- if .Values.volumes.configMaps }}
{{ $header := .Values.configFileCommonHeader | default "" }}
{{ $root := . }}
{{ range $cm := .Values.volumes.configMaps}}
{{- if $cm.data }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $cm.name }}
data:
{{- if $cm.data }}
{{- range $filename, $content := $cm.data }}
# property-like keys; each key maps to a simple value
{{ $filename }}: {{ $content }}
{{- end }}
{{- end }}
{{- end }}
{{- if $cm.files }}
{{- range $file := $cm.files }}
{{ $file.destination }}: |
{{ $header }}
{{ $root.Files.Get $file.source }}
{{- end}}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
3 changes: 3 additions & 0 deletions templates/_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ spec:
imagePullSecrets:
- name: {{ .Values.imagePullSecrets }}
{{- end }}
{{- if .Values.imageCredentials }}
- name: {{ include "microservice.name" . }}-docker-credentials
{{- end }}
{{- if .Values.serviceAccount }}
serviceAccountName: {{ .Values.serviceAccount }}
{{- end }}
Expand Down
14 changes: 12 additions & 2 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}


{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "microservice.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end }}

{{/*
Create a default fully qualified app name.
Expand All @@ -40,3 +39,14 @@ Create chart name and version as used by the chart label.
{{- define "microservice.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}



{{/*
Create docker credentials.
*/}}
{{- define "docker_credentials_tpl" }}
{{- with .Values.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}
7 changes: 3 additions & 4 deletions templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{{- $sa := .Values.serviceAccount | default "default" }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "serviceaccount" .}}
name: {{ $sa }}
namespace: {{ .Release.Namespace }}
imagePullSecrets:
- docker-credentials
---
apiVersion: v1
kind: List
Expand All @@ -30,7 +29,7 @@ items:
name: {{ .Release.Name }}-crb-{{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "serviceaccount" .}}
name: {{ $sa }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
Expand Down
4 changes: 3 additions & 1 deletion templates/secret-docker.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if .Values.imageCredentials }}
apiVersion: v1
kind: Secret
metadata:
name: docker-credentials
name: {{ include "microservice.name" . }}-docker-credentials
namespace: {{ .Release.Namespace }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "docker_credentials_tpl" . }}
{{- end }}
39 changes: 30 additions & 9 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ fullnameOverride: ""
## Secret must be manually created in the namespace.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
# imagePullSecrets: myRegistrKeySecretName
imagePullSecrets: myRegistrKeySecretName
imageCredentials:
registry: https://index.docker.io/v1/
username: username
password: password
email: [email protected]


# serviceAccount:
serviceAccount: microservice-sa
createServiceAccount: true
rbac: true

# Annotation for the Deployment
annotations: {}
Expand Down Expand Up @@ -68,7 +74,7 @@ readiness:
failureThreshold: 3

volumes:
enabled: false
enabled: true
pvc:
enabled: false
existing_claim:
Expand All @@ -79,12 +85,27 @@ volumes:
accessModes:
- ReadWriteOnce

configFileCommonHeader: commonValue
configMaps:
# - name: test
# mountPath: /test
# data:
# test.conf: |
# hello
- name: test
mountPath: /test
data:
test.conf: |
hello
- name: test-from-file
mountPath: /test2
files:
- source: config.conf
destination: application.conf
- name: test-mixed
mountPath: /test3
data:
test2.conf: |
another hello
files:
- source: config.conf
destination: application2.conf


ingress:
enabled: false
Expand Down

0 comments on commit 413fd29

Please sign in to comment.