From 2e3926094d12101899f9e86d84ccca95d44e0a2f Mon Sep 17 00:00:00 2001 From: pvannierop Date: Mon, 18 Nov 2024 15:57:09 +0100 Subject: [PATCH 1/3] Add mockserver charts --- charts/radar-mockserver/.helmignore | 4 + charts/radar-mockserver/Chart.yaml | 16 ++ charts/radar-mockserver/README.md | 63 +++++++ .../charts/mockserver-5.15.0.tgz | Bin 0 -> 5922 bytes charts/radar-mockserver/requirements.lock | 6 + .../radar-mockserver/templates/configmap.yaml | 17 ++ charts/radar-mockserver/values.yaml | 55 ++++++ external/mockserver/.helmignore | 4 + external/mockserver/Chart.yaml | 24 +++ external/mockserver/README.md | 171 ++++++++++++++++++ external/mockserver/requirements.yaml | 0 external/mockserver/templates/NOTES.txt | 52 ++++++ external/mockserver/templates/_helpers.tpl | 22 +++ external/mockserver/templates/deployment.yaml | 115 ++++++++++++ external/mockserver/templates/ingress.yaml | 52 ++++++ .../mockserver/templates/service-test.yaml | 17 ++ external/mockserver/templates/service.yaml | 39 ++++ external/mockserver/values.yaml | 51 ++++++ 18 files changed, 708 insertions(+) create mode 100644 charts/radar-mockserver/.helmignore create mode 100644 charts/radar-mockserver/Chart.yaml create mode 100644 charts/radar-mockserver/README.md create mode 100644 charts/radar-mockserver/charts/mockserver-5.15.0.tgz create mode 100644 charts/radar-mockserver/requirements.lock create mode 100644 charts/radar-mockserver/templates/configmap.yaml create mode 100644 charts/radar-mockserver/values.yaml create mode 100644 external/mockserver/.helmignore create mode 100644 external/mockserver/Chart.yaml create mode 100644 external/mockserver/README.md create mode 100644 external/mockserver/requirements.yaml create mode 100644 external/mockserver/templates/NOTES.txt create mode 100644 external/mockserver/templates/_helpers.tpl create mode 100644 external/mockserver/templates/deployment.yaml create mode 100644 external/mockserver/templates/ingress.yaml create mode 100644 external/mockserver/templates/service-test.yaml create mode 100644 external/mockserver/templates/service.yaml create mode 100644 external/mockserver/values.yaml diff --git a/charts/radar-mockserver/.helmignore b/charts/radar-mockserver/.helmignore new file mode 100644 index 00000000..11d183e2 --- /dev/null +++ b/charts/radar-mockserver/.helmignore @@ -0,0 +1,4 @@ +# 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 diff --git a/charts/radar-mockserver/Chart.yaml b/charts/radar-mockserver/Chart.yaml new file mode 100644 index 00000000..c2ccf10d --- /dev/null +++ b/charts/radar-mockserver/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +name: radar-mockserver +version: "0.1.0" +appVersion: "5.15.0" +description: Chart to deploy MockServer to Kubernetes. MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). +maintainers: + - email: pim@thehyve.nl + name: Pim van Nierop + url: https://www.thehyve.nl/experts/pim-van-nierop + - email: nivethika@thehyve.nl + name: Nivethika Mahasivam + url: https://www.thehyve.nl/experts/nivethika-mahasivam +dependencies: + - name: mockserver + version: 5.15.0 + repository: file://../../external/mockserver diff --git a/charts/radar-mockserver/README.md b/charts/radar-mockserver/README.md new file mode 100644 index 00000000..6447b782 --- /dev/null +++ b/charts/radar-mockserver/README.md @@ -0,0 +1,63 @@ + + +# radar-mockserver + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![AppVersion: 5.15.0](https://img.shields.io/badge/AppVersion-5.15.0-informational?style=flat-square) + +Chart to deploy MockServer to Kubernetes. MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| Pim van Nierop | | | +| Nivethika Mahasivam | | | + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| file://../../external/mockserver | mockserver | 5.15.0 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| expectations | list | `[]` | | +| mockserver.replicaCount | int | `1` | | +| mockserver.releasenameOverride | string | `""` | | +| mockserver.app.logLevel | string | `"INFO"` | | +| mockserver.app.serverPort | string | `"1080"` | | +| mockserver.app.mountedConfigMapName | string | `"mockserver-config"` | | +| mockserver.app.mountedLibsConfigMapName | string | `"mockserver-config"` | | +| mockserver.app.propertiesFileName | string | `"mockserver.properties"` | | +| mockserver.app.readOnlyRootFilesystem | bool | `false` | | +| mockserver.app.serviceAccountName | string | `"default"` | | +| mockserver.app.runAsUser | int | `65534` | | +| mockserver.image.repository | string | `"mockserver"` | | +| mockserver.image.snapshot | bool | `false` | | +| mockserver.image.pullPolicy | string | `"IfNotPresent"` | | +| mockserver.service.annotations | object | `{}` | | +| mockserver.service.clusterIP | string | `""` | | +| mockserver.service.externalIPs | list | `[]` | | +| mockserver.service.loadBalancerIP | string | `""` | | +| mockserver.service.loadBalancerSourceRanges | list | `[]` | | +| mockserver.service.type | string | `"NodePort"` | | +| mockserver.service.port | int | `1080` | | +| mockserver.service.nodePort | string | `""` | | +| mockserver.service.test.image | string | `"radial/busyboxplus:curl"` | | +| mockserver.ingress.enabled | bool | `false` | | +| mockserver.ingress.className | string | `""` | | +| mockserver.ingress.annotations | object | `{}` | | +| mockserver.ingress.hosts[0].host | string | `"mockserver.local"` | | +| mockserver.ingress.hosts[0].paths[0].path | string | `"/"` | | +| mockserver.ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | +| mockserver.ingress.tls | list | `[]` | | +| mockserver.podAnnotations | object | `{}` | | +| mockserver.resources | object | `{}` | | +| mockserver.nodeSelector | object | `{}` | | +| mockserver.tolerations | list | `[]` | | +| mockserver.affinity | object | `{}` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.8.1](https://github.com/norwoodj/helm-docs/releases/v1.8.1) diff --git a/charts/radar-mockserver/charts/mockserver-5.15.0.tgz b/charts/radar-mockserver/charts/mockserver-5.15.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..4c91a3d3b845a9ffd8b2f860651297a28f498e8d GIT binary patch literal 5922 zcmV+-7v1O|iwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PKBzQzJLhc>bPG(Lb|yi@EjKu)C0R{kVEKAQvtyxPau6qEaBw zv~2~=Xfo26^^yJVPw8c5G~@9L31RQ@psHQlGc9$u)aq`vS|Z}XoxpU8Y4>nKQt8h~ z#J+gi((CnlyYJrV&t9)r|J>f)-u+_x-QM=z_Rj8ZZ}*Gd_S?6+dtX5BiRox8nUEy? zqW7C|)tUP*DI}raVJaw(`!L=1NRkvk-}~F|{hk-12vV9z{Y=XUNDd(;jL+Z$5AH6t z_^5~9WJ642lqh^~Utvs!3V~OLGNQ8STCorW1 zzP`E|08jPjrFk4Mim?=MpHe9?1{%XZ$&|eDK!09pa)HDlTx7#pl@!7R2O0+~3sC@p zB;_AxASXmBk22ucFOuwQSdH^ydqY({kJsOVz;~P*hz6i2fl)z2+xI3s!ahu-O#0of8j6mY{eHkBj|OUtn_qTGk}&K@ zo&}SR0`!x3?A_t)o~NPcd!1rn%{N=s>*)46>XH5KbwHw!_M?Q;y^zD_KZMdx9rsoK zD=+Ts`tTEpP=rIqdGwc3xBbspz12Jd#6)$$KNTPx!QU0AXP%W6Ji)Ux zK;5!N+V6J9R8F#??hA*(u2ZRmRe&K6?rh(=P;P~3ZLU54{CDV@5|*L(9Sp!K{r`UF zeO>?W?!0@^|IblUOc)KwA1b~+jpKvBQnOmZaCqBN}kRtsslj8BoPxXOB_kY*nl${%=&OLI^%MXqQF>sp2e=( zBXP_nQHECZ;o*}95U@;0Oiu=S2mtV-#55-CWFY!*{i7ZZ68@bq5(f^L`|wgLvI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M0BYH@x3C%WT;DYTS!@kJWt!>y z`|9}vml&NW--eDp4|^-q3~zIru7l&UxZNv180dLl@f7eQQFF6U$(Ua*>0|<{Sy3bX za|%k0y!{5jXol8}y?giew+q)1&y;m2l~2Ia6a(qZOKs1Gh%qEYi2U#@Lc+rZowrOY zuc?Z`Xp$pTN*u$5%0zo7#148yk_MA)@2$Hv?x0W}q}H;^43!f0)%e3fQeNJ3U zGnW%(Y1EP*!lM(+}D%5GuMAr+fZYDu95?@a_w{w7v@w6lDq0#q`9bo>sniu%*QNx zWQw?8(US{}F$~8aCB|VjWCA)JQVpkesFlZXt#cr?Q5cfoPCR0+siAAsZ5zW(N*>>& zC=wnEywNyravVCELSndX)UwKgDDbCJv>VQo8wZOas%_*q?-s2goc@Y3A&X>UJ;U-d z$)*kpUv;GQGqr|POAPZWcLU1S>C;$Z63^f#l3FdC+uP7US1f97u8Ce~YisRV>YOm& zYf^TM4jZiVdOB|IsK}%ATn+O|_4aI9XO1n$DeGveS1ArPHJu^&_Tp4O+kjIZ5avei z>=j;%qnM7eCbj#K7e-~!v_+aUp5d0X%;Jes^#(e>sf;79hD0#?{L1-nvm{h&39V2q7Cq@DpC`jajJCFnB6L$U_G^$@_Usk1IahizG&hmti~X&w z$Ho_yXzGOo!UF8SJv^`|u3X3k@EEqXY~wm&tj|*z-i_s2DAPc7Of}&`P}P*=@N!1Gd9k1eROtd z|J=dS{my{L0VcA@q!pd=gj@csyAj5st%Kp(6|i$K_cSY1So2;pPWINgBAQUyaB;&A z|G$u`zcp^L=z&^$OUBtKJwk>O&HjPinqV_XG2(U)&SX*6^iHU2RTWH.svc.cluster.local`, i.e. `mockserver.mockserver.svc.cluster.local` + +### Helm Delete + +To completely remove the chart: + +```bash +helm delete mockserver --purge +``` diff --git a/external/mockserver/requirements.yaml b/external/mockserver/requirements.yaml new file mode 100644 index 00000000..e69de29b diff --git a/external/mockserver/templates/NOTES.txt b/external/mockserver/templates/NOTES.txt new file mode 100644 index 00000000..428af115 --- /dev/null +++ b/external/mockserver/templates/NOTES.txt @@ -0,0 +1,52 @@ + +1. To wait until the deployment is complete run: + + kubectl rollout status deployments {{ .Release.Name }} -n {{ .Release.Namespace }} + +2. To check the status of the deployment without waiting, run the following command and confirm the `mockserver` has the `Running` status: + + kubectl get po -l release={{ .Release.Name }} -n {{ .Release.Namespace }} + +3. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} + {{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} + {{- end }} +{{- else if contains "NodePort" .Values.service.type }} + + export NODE_PORT=$(kubectl --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" get services {{ template "release.name" . }}) + export NODE_IP=$(kubectl --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address} get nodes") + export MOCKSERVER_HOST=$NODE_IP:$NODE_PORT + echo http://$MOCKSERVER_HOST + + OR + + kubectl -n {{ .Release.Namespace }} port-forward svc/mockserver 1080:1080 & + export MOCKSERVER_HOST=127.0.0.1:1080 + echo http://$MOCKSERVER_HOST +{{- else if contains "LoadBalancer" .Values.service.type }} + + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "release.name" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "release.name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') + export MOCKSERVER_HOST=$SERVICE_IP:{{ .Values.service.port }} + echo http://$MOCKSERVER_HOST + + OR + + kubectl -n {{ .Release.Namespace }} port-forward svc/mockserver 1080:1080 & + export MOCKSERVER_HOST=127.0.0.1:1080 + echo http://$MOCKSERVER_HOST +{{- else if contains "ClusterIP" .Values.service.type }} + + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "release.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + kubectl port-forward $POD_NAME {{ .Values.service.port }}:{{ .Values.service.port }} -n {{ .Release.Namespace }} & + sleep 1 && export MOCKSERVER_HOST=127.0.0.1:{{ .Values.service.port }} + echo http://$MOCKSERVER_HOST + + OR + + kubectl -n {{ .Release.Namespace }} port-forward svc/mockserver 1080:1080 & + export MOCKSERVER_HOST=127.0.0.1:1080 + echo http://$MOCKSERVER_HOST +{{- end }} diff --git a/external/mockserver/templates/_helpers.tpl b/external/mockserver/templates/_helpers.tpl new file mode 100644 index 00000000..fbc04b73 --- /dev/null +++ b/external/mockserver/templates/_helpers.tpl @@ -0,0 +1,22 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* Chart name truncated at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} +{{- define "chart.name" -}} + {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* Release name truncated at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} +{{- define "release.name" -}} + {{- if .Values.releasenameOverride -}} + {{- .Values.releasenameOverride | trunc 63 | trimSuffix "-" -}} + {{- else if .Values.fullnameOverride -}} + {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} + {{- else -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" -}} + {{- end -}} +{{- end -}} + +{{/* Create chart name and version as used by the chart label. */}} +{{- define "chart.name_version" -}} + {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/external/mockserver/templates/deployment.yaml b/external/mockserver/templates/deployment.yaml new file mode 100644 index 00000000..ef4e766f --- /dev/null +++ b/external/mockserver/templates/deployment.yaml @@ -0,0 +1,115 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "release.name" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} + chart: {{ template "chart.name_version" . }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} + template: + metadata: +{{- if .Values.podAnnotations }} + # Allows custom annotations to be specified + annotations: +{{ toYaml .Values.podAnnotations | indent 8 }} +{{- end }} + name: {{ template "release.name" . }} + labels: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} + spec: + serviceAccountName: {{ .Values.app.serviceAccountName }} + containers: + - name: {{ template "release.name" . }} + image: {{ if .Values.image.repositoryNameAndTag }}{{ .Values.image.repositoryNameAndTag }}{{- else }}{{ .Values.image.repository }}/mockserver:mockserver-{{- if .Values.image.snapshot }}snapshot{{- else }}{{ .Chart.AppVersion }}{{- end }}{{- end }} +{{- if .Values.image.snapshot }} + imagePullPolicy: Always +{{- else }} + imagePullPolicy: {{ .Values.image.pullPolicy }} +{{- end }} + securityContext: +{{- if .Values.app.runAsUser }} + runAsUser: {{ .Values.app.runAsUser }} +{{- end }} + readOnlyRootFilesystem: {{ .Values.app.readOnlyRootFilesystem }} + allowPrivilegeEscalation: false + ports: + - name: serviceport + containerPort: {{ .Values.app.serverPort }} + protocol: TCP + readinessProbe: + tcpSocket: + port: serviceport + initialDelaySeconds: 2 + periodSeconds: 2 + successThreshold: 1 + failureThreshold: 10 + livenessProbe: + tcpSocket: + port: serviceport + initialDelaySeconds: 10 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 10 + env: + - name: MOCKSERVER_LOG_LEVEL + value: {{ .Values.app.logLevel | quote }} + - name: SERVER_PORT + value: {{ .Values.app.serverPort | quote }} +{{- if .Values.app.proxyRemoteHost }} + - name: PROXY_REMOTE_HOST + value: {{ .Values.app.proxyRemoteHost | quote }} +{{- end }} +{{- if .Values.app.proxyRemotePort }} + - name: PROXY_REMOTE_PORT + value: {{ .Values.app.proxyRemotePort | quote }} +{{- end }} +{{- if .Values.app.jvmOptions }} + - name: JVM_OPTIONS + value: {{ .Values.app.jvmOptions | quote }} +{{- end }} +{{- if .Values.app.mountConfigMap }} + - name: MOCKSERVER_PROPERTY_FILE + value: /config/{{ .Values.app.propertiesFileName }} +{{- end }} + volumeMounts: + - name: config-volume + mountPath: /config +{{- if .Values.app.mountedLibsConfigMapName}} + - name: libs-volume + mountPath: /libs +{{- end}} +{{- if .Values.resources }} + resources: +{{ toYaml .Values.resources | indent 12 }} +{{- end }} + volumes: + - name: config-volume + configMap: + name: {{ .Values.app.mountedConfigMapName }} + optional: true +{{- if .Values.app.mountedLibsConfigMapName}} + - name: libs-volume + configMap: + name: {{ .Values.app.mountedLibsConfigMapName }} + optional: true +{{- end}} +{{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} +{{- end }} +{{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} +{{- end }} +{{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} +{{- end }} diff --git a/external/mockserver/templates/ingress.yaml b/external/mockserver/templates/ingress.yaml new file mode 100644 index 00000000..e18c68f6 --- /dev/null +++ b/external/mockserver/templates/ingress.yaml @@ -0,0 +1,52 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "release.name" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ template "release.name" . }} + labels: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} + chart: {{ template "chart.name_version" . }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.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/external/mockserver/templates/service-test.yaml b/external/mockserver/templates/service-test.yaml new file mode 100644 index 00000000..59276fdc --- /dev/null +++ b/external/mockserver/templates/service-test.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ template "release.name" . }}-service-test" + labels: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} + chart: {{ template "chart.name_version" . }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: curl + image: {{ .Values.service.test.image}} + command: ['curl'] + args: ['-v', '-s', '-X', 'PUT', '{{ template "release.name" . }}:{{ .Values.service.port }}/status'] + restartPolicy: Never diff --git a/external/mockserver/templates/service.yaml b/external/mockserver/templates/service.yaml new file mode 100644 index 00000000..95dd1d76 --- /dev/null +++ b/external/mockserver/templates/service.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "release.name" . }} +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end }} + labels: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} + chart: {{ template "chart.name_version" . }} +spec: + type: {{ .Values.service.type }} +{{- if .Values.service.clusterIP }} + clusterIP: {{ .Values.service.clusterIP | quote }} +{{- end }} +{{- if .Values.service.externalIPs }} + externalIPs: +{{ toYaml .Values.service.externalIPs | indent 4 }} +{{- end }} +{{- if .Values.service.loadBalancerIP }} + loadBalancerIP: "{{ .Values.service.loadBalancerIP }}" +{{- end }} +{{- if .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }} +{{- end }} + ports: + - name: serviceport + protocol: TCP + targetPort: serviceport + port: {{ .Values.service.port }} + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + selector: + app: {{ template "chart.name" . }} + release: {{ .Release.Name }} diff --git a/external/mockserver/values.yaml b/external/mockserver/values.yaml new file mode 100644 index 00000000..89213319 --- /dev/null +++ b/external/mockserver/values.yaml @@ -0,0 +1,51 @@ +replicaCount: 1 + +releasenameOverride: "" + +app: + logLevel: "INFO" + serverPort: "1080" + mountedConfigMapName: "mockserver-config" + mountedLibsConfigMapName: "mockserver-config" + propertiesFileName: "mockserver.properties" + readOnlyRootFilesystem: false + serviceAccountName: default + runAsUser: 65534 + +image: + repository: mockserver + snapshot: false + pullPolicy: IfNotPresent + +service: + annotations: {} + clusterIP: "" + externalIPs: [] + loadBalancerIP: "" + loadBalancerSourceRanges: [] + type: NodePort + port: 1080 + nodePort: "" + test: + image: radial/busyboxplus:curl + +ingress: + enabled: false + className: "" + annotations: {} + hosts: + - host: mockserver.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + +podAnnotations: {} + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 54572b9aff1acb0ce2ef24c00ac4a8ce201a0db8 Mon Sep 17 00:00:00 2001 From: pvannierop Date: Tue, 19 Nov 2024 16:43:41 +0100 Subject: [PATCH 2/3] Make failure message of helm-lint more informative --- .github/workflows/lint-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 54818501..b63501dc 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -31,7 +31,7 @@ jobs: run: | CHANGES=$(git diff --stat charts) if [ -n "${CHANGES}" ]; then - printf "README is not up to date with helm-docs. Following mismatches are detected:\n$CHANGES\n" + printf "README is not up to date with helm-docs. Following mismatches are detected:\n$(git diff charts)\n" exit 1 fi From df0dab515adea72002fb5073071d566dc26c2ab4 Mon Sep 17 00:00:00 2001 From: pvannierop Date: Tue, 19 Nov 2024 16:47:20 +0100 Subject: [PATCH 3/3] Add update strategy for mockserver --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 1930618f..5ff4edab 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,13 @@ update-minio: @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) @echo "" +update-mockserver: + @echo "Updating mockserver" + @helm repo add mockserver https://www.mock-server.com + @rm -rf external/$(patsubst update-%,%,$@) + @helm pull -d external --untar mockserver/$(patsubst update-%,%,$@) + @echo "" + update-mongodb: @echo "Updating mongodb" @helm repo add bitnami https://charts.bitnami.com/bitnami