Skip to content

Commit

Permalink
Merge pull request #1 from mrmuli/feature/add-helm-chart
Browse files Browse the repository at this point in the history
Feature: Add helm chart and deployment configuration.
  • Loading branch information
mrmuli authored Nov 16, 2022
2 parents 74df31a + 1edb3a7 commit 5a9bcf5
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 0 deletions.
23 changes: 23 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: configmap
repository: https://ameijer.github.io/k8s-as-helm
version: 1.0.3
digest: sha256:22e5078b73533d695ab6b67d604ccb67c54d0e4a89ac5e4379b528da176fe8c8
generated: "2022-11-16T16:52:39.291084+01:00"
14 changes: 14 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: demo
description: A demo server

type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: configmap
version: 1.0.3
repository: https://ameijer.github.io/k8s-as-helm
# - name: sealed-secrets
# version: 1.1.10
# repository: https://charts.bitnami.com/bitnami
Binary file added chart/charts/configmap-1.0.3.tgz
Binary file not shown.
62 changes: 62 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "demo.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | 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 "demo.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | 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 }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "demo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "demo.labels" -}}
helm.sh/chart: {{ include "demo.chart" . }}
{{ include "demo.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "demo.selectorLabels" -}}
app.kubernetes.io/name: {{ include "demo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "demo.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "demo.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
53 changes: 53 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "demo.fullname" . }}
labels:
{{- include "demo.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "demo.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "demo.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.ConfigMap}}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "demo.fullname" . }}
labels:
{{- include "demo.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "demo.selectorLabels" . | nindent 4 }}
44 changes: 44 additions & 0 deletions chart/values-development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
replicaCount: 1



image:
repository: josephmuli/demo-server
pullPolicy: IfNotPresent
tag: "1.0.1-dev"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

podSecurityContext: {}

securityContext: {}

config:
ConfigMap: demo-server


service:
type: ClusterIP
port: 3030

# Create a configmap with environment-specific config.
configmap:
configmapData:
SERVER_USERNAME: "development"
TEAM: "blue"

resources: {}

nodeSelector: {}

# Uncomment this to deploy this service to nodes or node pools with the defined label.
# nodeSelector:
# environment: development

tolerations: []

affinity: {}
43 changes: 43 additions & 0 deletions chart/values-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
replicaCount: 1

image:
repository: josephmuli/demo-server
pullPolicy: IfNotPresent
tag: "2.0.1"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""


podAnnotations: {}

podSecurityContext: {}

securityContext: {}

config:
ConfigMap: demo-server

service:
type: ClusterIP
port: 3030

configmap:
configmapData:
SERVER_USERNAME: "production"
TEAM: "blue"


resources: {}

nodeSelector: {}

# Uncomment this to deploy this service to nodes or node pools with the defined label.
# nodeSelector:
# environment: production

tolerations: []

affinity: {}

0 comments on commit 5a9bcf5

Please sign in to comment.