diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index caad7109..7be8a3b0 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -1,7 +1,9 @@ +--- apiVersion: v2 name: microservice description: A Helm chart for a microservice in Kubernetes - type: application -version: 0.1.0 -appVersion: "1.0" +version: 0.1.2 +appVersion: "0.1.2" +maintainers: + - name: Opstree Solutions diff --git a/charts/microservice/templates/_helpers.tpl b/charts/microservice/templates/_helpers.tpl new file mode 100644 index 00000000..f825ae67 --- /dev/null +++ b/charts/microservice/templates/_helpers.tpl @@ -0,0 +1,60 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* +Create a defautl fully qualified app name +It will use the release name to give the app name +*/}} + +{{- define "app.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 60 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "app.tempname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 60 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "app.fullname" -}} +{{- printf "%s-%s" ( include "app.tempname" . ) "app" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "app.labels" -}} +app: {{ include "app.tempname" . }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "app.selectorLabels" -}} +app: {{ include "app.tempname" . }} +{{- end }}% + +{{/* +service name +*/}} +{{- define "app.servicename" -}} +{{- printf "%s-%s" ( include "app.tempname" . ) "svc" | trunc 63 | trimSuffix "-" }} +{{- end }}% + +{{/* +configmap name +*/}} +{{- define "app.configmapname" -}} +{{- printf "%s-%s" ( include "app.tempname" . ) "cm" | trunc 63 | trimSuffix "-" }} +{{- end }}% diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 13f013f7..4292f925 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -1,18 +1,18 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "microservice.fullname" . }} + name: {{ include "app.fullname" . }} labels: - {{- include "microservice.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "microservice.selectorLabels" . | nindent 6 }} + {{- include "app.selectorLabels" . | nindent 6 }} template: metadata: labels: - {{- include "microservice.selectorLabels" . | nindent 8 }} + {{- include "app.selectorLabels" . | nindent 8 }} spec: containers: - name: {{ .Chart.Name }} diff --git a/charts/microservice/templates/service.yaml b/charts/microservice/templates/service.yaml index 1ace41b7..78d58947 100644 --- a/charts/microservice/templates/service.yaml +++ b/charts/microservice/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "microservice.fullname" . }} + name: {{ include "app.servicename" . }} labels: - {{- include "microservice.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: http selector: - {{- include "microservice.selectorLabels" . | nindent 4 }} + {{- include "app.selectorLabels" . | nindent 4 }} diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 67e2ed03..70374108 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,9 +1,11 @@ replicaCount: 1 +fullnameOverride: "nginx" +nameOverride: "" image: - repository: nginx # your microservice image name + repository: nginx pullPolicy: IfNotPresent - tag: "latest" # your microservice image tag + tag: "latest" service: type: ClusterIP