Skip to content

Commit

Permalink
feat(helmChart): add Helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Icikowski committed Nov 18, 2022
1 parent 0429054 commit a3b60cc
Show file tree
Hide file tree
Showing 10 changed files with 557 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dist/chart/goosymock/.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/
19 changes: 19 additions & 0 deletions dist/chart/goosymock/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: goosymock
description: GPTS - Fully functional API was never an option
keywords:
- testing
- mocking
- test service
- test tools
- api mocking
type: application
version: 0.1.0
appVersion: "0.1.0"
home: https://icikowski.github.io/GoosyMock
icon: https://github.com/Icikowski/GoosyMock/raw/master/images/icon-dark.png
sources:
- https://github.com/Icikowski/GoosyMock
maintainers:
- name: Piotr Icikowski
url: https://icikowski.pl
33 changes: 33 additions & 0 deletions dist/chart/goosymock/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
GoosyMock - Fully functional API was never an option

Service installed successfully! Check out the documentation (https://icikowski.github.io/GoosyMock) and start using the app.

Ways to access the application:
1. Admin API:
- via {{ .Values.goosyMock.adminApi.service.type }} service:
HTTP on port {{ .Values.goosyMock.adminApi.service.port }}
{{- if .Values.goosyMock.adminApi.ssl.enabled }}
HTTPS on port {{ .Values.goosyMock.adminApi.service.securedPort }}
{{- end }}
{{- if .Values.ingress.adminApi.enabled }}
- via Ingress:
{{- range $host := .Values.ingress.adminApi.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- end }}
2. Content Service:
- via {{ .Values.goosyMock.contentService.service.type }} service:
HTTP on port {{ .Values.goosyMock.contentService.service.port }}
{{- if .Values.goosyMock.contentService.ssl.enabled }}
HTTPS on port {{ .Values.goosyMock.contentService.service.securedPort }}
{{- end }}
{{- if .Values.ingress.contentService.enabled }}
- via Ingress:
{{- range $host := .Values.ingress.contentService.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- end }}
51 changes: 51 additions & 0 deletions dist/chart/goosymock/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "goosymock.name" -}}
{{- default .Chart.Name .Values.overrides.name | 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 "goosymock.fullname" -}}
{{- if .Values.overrides.fullName }}
{{- .Values.overrides.fullName | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.overrides.name }}
{{- 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 "goosymock.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "goosymock.selectorLabels" -}}
app.kubernetes.io/name: {{ include "goosymock.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
139 changes: 139 additions & 0 deletions dist/chart/goosymock/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "goosymock.fullname" . }}
labels:
{{- include "goosymock.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "goosymock.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "goosymock.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.overrides.repository | default "ghcr.io" }}/{{ .Values.overrides.image | default "icikowski/goosymock" }}:{{ .Values.overrides.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if or .Values.goosyMock.adminApi.ssl.enabled .Values.goosyMock.contentService.ssl.enabled }}
volumeMounts:
{{- if .Values.goosyMock.adminApi.ssl.enabled }}
- name: admin-ssl
mountPath: /var/ssl/admin
readOnly: true
{{- end }}
{{- if .Values.goosyMock.contentService.ssl.enabled }}
- name: content-ssl
mountPath: /var/ssl/content
readOnly: true
{{- end }}
{{- end }}
env:
- name: GM_LOG_LEVEL
value: {{ .Values.goosyMock.logLevel | default "info" | quote }}
- name: GM_PRETTY_LOG
value: {{ .Values.goosyMock.prettyLog | default "false" | quote }}
- name: GM_ADMIN_API_PORT
value: {{ .Values.goosyMock.adminApi.port | default "8081" | quote }}
- name: GM_ADMIN_API_SECURED_PORT
value: {{ .Values.goosyMock.adminApi.ssl.port | default "8444" | quote }}
- name: GM_ADMIN_API_SSL_ENABLED
value: {{ .Values.goosyMock.adminApi.ssl.enabled | default "false" | quote }}
- name: GM_ADMIN_API_TLS_CERT_PATH
value: /var/ssl/admin/tls.crt
- name: GM_ADMIN_API_TLS_KEY_PATH
value: /var/ssl/admin/tls.key
- name: GM_CONTENT_PORT
value: {{ .Values.goosyMock.contentService.port | default "8080" | quote }}
- name: GM_CONTENT_SECURED_PORT
value: {{ .Values.goosyMock.contentService.ssl.port | default "8443" | quote }}
- name: GM_CONTENT_SSL_ENABLED
value: {{ .Values.goosyMock.contentService.ssl.enabled | default "false" | quote }}
- name: GM_CONTENT_TLS_CERT_PATH
value: /var/ssl/content/tls.crt
- name: GM_CONTENT_TLS_KEY_PATH
value: /var/ssl/content/tls.key
- name: GM_HEALTH_PROBES_PORT
value: {{ .Values.goosyMock.health.port | default "8888" | quote }}
- name: GM_MAX_PAYLOAD_SIZE
value: {{ .Values.goosyMock.maxPayloadSize | default "64" | quote }}
ports:
- name: content-http
containerPort: {{ .Values.goosyMock.contentService.port }}
protocol: TCP
{{- if .Values.goosyMock.contentService.ssl.enabled }}
- name: content-https
containerPort: {{ .Values.goosyMock.contentService.ssl.port }}
protocol: TCP
{{- end }}
- name: admin-http
containerPort: {{ .Values.goosyMock.adminApi.port }}
protocol: TCP
{{- if .Values.goosyMock.adminApi.ssl.enabled }}
- name: admin-https
containerPort: {{ .Values.goosyMock.adminApi.ssl.port }}
protocol: TCP
{{- end }}
- name: health
containerPort: {{ .Values.goosyMock.health.port }}
protocol: TCP
startupProbe:
httpGet:
path: /live
port: health
failureThreshold: 6
periodSeconds: 5
initialDelaySeconds: 5
livenessProbe:
httpGet:
path: /live
port: health
failureThreshold: 3
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: health
failureThreshold: 3
periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.goosyMock.adminApi.ssl.enabled .Values.goosyMock.contentService.ssl.enabled }}
volumes:
{{- if .Values.goosyMock.adminApi.ssl.enabled }}
- name: admin-ssl
secret:
secretName: {{ .Values.goosyMock.adminApi.ssl.secretName | required "Kubernetes TLS Secret name with Admin API certificate must be provided!" }}
{{- end }}
{{- if .Values.goosyMock.contentService.ssl.enabled }}
- name: content-ssl
secret:
secretName: {{ .Values.goosyMock.contentService.ssl.secretName | required "Kubernetes TLS Secret name with Content Service certificate must be provided!" }}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions dist/chart/goosymock/templates/ingress-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.adminApi.enabled -}}
{{- $fullName := include "goosymock.fullname" . -}}
{{- $svcPort := .Values.goosyMock.adminApi.service.port -}}
{{- if and .Values.ingress.adminApi.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.adminApi.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.adminApi.annotations "kubernetes.io/ingress.class" .Values.ingress.adminApi.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}-admin
labels:
{{- include "goosymock.labels" . | nindent 4 }}
{{- with .Values.ingress.adminApi.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.adminApi.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.adminApi.className }}
{{- end }}
{{- if .Values.ingress.adminApi.tls }}
tls:
{{- range .Values.ingress.adminApi.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.adminApi.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}-admin
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}-admin
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions dist/chart/goosymock/templates/ingress-content.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.contentService.enabled -}}
{{- $fullName := include "goosymock.fullname" . -}}
{{- $svcPort := .Values.goosyMock.contentService.service.port -}}
{{- if and .Values.ingress.contentService.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.contentService.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.contentService.annotations "kubernetes.io/ingress.class" .Values.ingress.contentService.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "goosymock.labels" . | nindent 4 }}
{{- with .Values.ingress.contentService.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.contentService.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.contentService.className }}
{{- end }}
{{- if .Values.ingress.contentService.tls }}
tls:
{{- range .Values.ingress.contentService.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.contentService.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit a3b60cc

Please sign in to comment.