From a3b60ccf4c7a609b87ef58c30139f889b447a18a Mon Sep 17 00:00:00 2001 From: Piotr Icikowski Date: Fri, 18 Nov 2022 01:38:07 +0100 Subject: [PATCH] feat(helmChart): add Helm chart --- dist/chart/goosymock/.helmignore | 23 +++ dist/chart/goosymock/Chart.yaml | 19 +++ dist/chart/goosymock/templates/NOTES.txt | 33 +++++ dist/chart/goosymock/templates/_helpers.tpl | 51 +++++++ .../chart/goosymock/templates/deployment.yaml | 139 ++++++++++++++++++ .../goosymock/templates/ingress-admin.yaml | 61 ++++++++ .../goosymock/templates/ingress-content.yaml | 61 ++++++++ .../goosymock/templates/service-admin.yaml | 21 +++ .../goosymock/templates/service-content.yaml | 21 +++ dist/chart/goosymock/values.yaml | 128 ++++++++++++++++ 10 files changed, 557 insertions(+) create mode 100644 dist/chart/goosymock/.helmignore create mode 100644 dist/chart/goosymock/Chart.yaml create mode 100644 dist/chart/goosymock/templates/NOTES.txt create mode 100644 dist/chart/goosymock/templates/_helpers.tpl create mode 100644 dist/chart/goosymock/templates/deployment.yaml create mode 100644 dist/chart/goosymock/templates/ingress-admin.yaml create mode 100644 dist/chart/goosymock/templates/ingress-content.yaml create mode 100644 dist/chart/goosymock/templates/service-admin.yaml create mode 100644 dist/chart/goosymock/templates/service-content.yaml create mode 100644 dist/chart/goosymock/values.yaml diff --git a/dist/chart/goosymock/.helmignore b/dist/chart/goosymock/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/dist/chart/goosymock/.helmignore @@ -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/ diff --git a/dist/chart/goosymock/Chart.yaml b/dist/chart/goosymock/Chart.yaml new file mode 100644 index 0000000..4d0352f --- /dev/null +++ b/dist/chart/goosymock/Chart.yaml @@ -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: + - http://github.com/Icikowski/GoosyMock +maintainers: + - name: Piotr Icikowski + url: https://icikowski.pl diff --git a/dist/chart/goosymock/templates/NOTES.txt b/dist/chart/goosymock/templates/NOTES.txt new file mode 100644 index 0000000..141c29f --- /dev/null +++ b/dist/chart/goosymock/templates/NOTES.txt @@ -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 }} diff --git a/dist/chart/goosymock/templates/_helpers.tpl b/dist/chart/goosymock/templates/_helpers.tpl new file mode 100644 index 0000000..e33163f --- /dev/null +++ b/dist/chart/goosymock/templates/_helpers.tpl @@ -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 }} diff --git a/dist/chart/goosymock/templates/deployment.yaml b/dist/chart/goosymock/templates/deployment.yaml new file mode 100644 index 0000000..5365faf --- /dev/null +++ b/dist/chart/goosymock/templates/deployment.yaml @@ -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 }} diff --git a/dist/chart/goosymock/templates/ingress-admin.yaml b/dist/chart/goosymock/templates/ingress-admin.yaml new file mode 100644 index 0000000..1bb860e --- /dev/null +++ b/dist/chart/goosymock/templates/ingress-admin.yaml @@ -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 }} diff --git a/dist/chart/goosymock/templates/ingress-content.yaml b/dist/chart/goosymock/templates/ingress-content.yaml new file mode 100644 index 0000000..cd46452 --- /dev/null +++ b/dist/chart/goosymock/templates/ingress-content.yaml @@ -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 }} diff --git a/dist/chart/goosymock/templates/service-admin.yaml b/dist/chart/goosymock/templates/service-admin.yaml new file mode 100644 index 0000000..41549b6 --- /dev/null +++ b/dist/chart/goosymock/templates/service-admin.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "goosymock.fullname" . }}-admin + labels: + {{- include "goosymock.labels" . | nindent 4 }} +spec: + type: {{ .Values.goosyMock.adminApi.service.type }} + ports: + - port: {{ .Values.goosyMock.adminApi.service.port }} + targetPort: admin-http + protocol: TCP + name: http + {{- if .Values.goosyMock.adminApi.ssl.enabled }} + - port: {{ .Values.goosyMock.adminApi.service.securedPort }} + targetPort: admin-https + protocol: TCP + name: https + {{- end }} + selector: + {{- include "goosymock.selectorLabels" . | nindent 4 }} diff --git a/dist/chart/goosymock/templates/service-content.yaml b/dist/chart/goosymock/templates/service-content.yaml new file mode 100644 index 0000000..15d09f0 --- /dev/null +++ b/dist/chart/goosymock/templates/service-content.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "goosymock.fullname" . }} + labels: + {{- include "goosymock.labels" . | nindent 4 }} +spec: + type: {{ .Values.goosyMock.contentService.service.type }} + ports: + - port: {{ .Values.goosyMock.contentService.service.port }} + targetPort: content-http + protocol: TCP + name: http + {{- if .Values.goosyMock.contentService.ssl.enabled }} + - port: {{ .Values.goosyMock.contentService.service.securedPort }} + targetPort: content-https + protocol: TCP + name: https + {{- end }} + selector: + {{- include "goosymock.selectorLabels" . | nindent 4 }} diff --git a/dist/chart/goosymock/values.yaml b/dist/chart/goosymock/values.yaml new file mode 100644 index 0000000..607d1b9 --- /dev/null +++ b/dist/chart/goosymock/values.yaml @@ -0,0 +1,128 @@ +overrides: + name: "" + fullName: "" + + # Overrides the image repository whose default is "ghcr.io" + repository: "" + # Overrides the image name whose default is "icikowski/goosymock" + image: "" + # Overrides the image tag whose default is the chart appVersion + tag: "" + +image: + pullPolicy: IfNotPresent + pullSecrets: [] + +goosyMock: + # Logging configuration + logLevel: info + prettyLog: false + + # Maximum payload size (in megabytes) + maxPayloadSize: 64 + + # Admin API Service configuration + adminApi: + port: 8081 + + # Secured connection configuration + # If enabled, the Kubernetes Secret with TLS certificate and + # secret key for Kubernetes service name must be present in + # deployment namespace and it's name must be provided below + ssl: + enabled: false + port: 8444 + secretName: "" + + # Kubernetes Service configuration + service: + type: ClusterIP + port: 80 + securedPort: 443 + + # Content Service configuration + contentService: + port: 8080 + + # Secured connection configuration + # If enabled, the Kubernetes Secret with TLS certificate and + # secret key for Kubernetes service name must be present in + # deployment namespace and it's name must be provided below + ssl: + enabled: false + port: 8443 + secretName: "" + + # Kubernetes Service configuration + service: + type: ClusterIP + port: 80 + securedPort: 443 + + # Health probes configuration + health: + port: 8888 + +# Ingress configuration for Admin API Service and Content Service +ingress: + adminApi: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: admin.example.com + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - admin.example.com + contentService: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: content.example.com + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - content.example.com + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}