From a6e77e529e9a1b6935635d0a28deafdc6b4a38d8 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Wed, 3 Jul 2024 23:05:37 +0100 Subject: [PATCH] Changelog: - Update image version and index - Updated readme with instructions to use helm repository - Updated notes and readme with port-forward instructions - Switch to Helm v2 - Substitute WIREMOCK_OPTION by args - Cleanup _helpers.tpl - Support additional pod annotations - Update configmaps - Update service - Fix ingress - Add imagePullSecrets support - Add service account support - Add pod and container security context support - Add horizontal pod autoscaler support - Updated CI and CD pipelines Fix https://github.com/wiremock/helm-charts/issues/21 Fix https://github.com/wiremock/helm-charts/issues/22 Fix https://github.com/wiremock/helm-charts/issues/25 Fix https://github.com/wiremock/helm-charts/issues/27 Fix https://github.com/wiremock/helm-charts/issues/28 Fix https://github.com/wiremock/helm-charts/issues/34 Fix https://github.com/wiremock/helm-charts/issues/40 Close https://github.com/wiremock/helm-charts/pull/29 Close https://github.com/wiremock/helm-charts/pull/31 Close https://github.com/wiremock/helm-charts/pull/33 Close https://github.com/wiremock/helm-charts/pull/39 --- .github/workflows/cd.yaml | 10 +- .github/workflows/ci.yaml | 23 ++-- README.md | 10 ++ charts/wiremock/.helmignore | 2 + charts/wiremock/Chart.yaml | 28 ++++- charts/wiremock/README.md | 6 +- charts/wiremock/templates/NOTES.txt | 15 ++- charts/wiremock/templates/_helpers.tpl | 74 +++++++++--- .../templates/configmap-mappings.yaml | 6 +- .../templates/configmap-responses.yaml | 6 +- charts/wiremock/templates/deployment.yaml | 110 ++++++++++-------- charts/wiremock/templates/hpa.yaml | 28 +++++ charts/wiremock/templates/ingress.yaml | 65 +++++++---- charts/wiremock/templates/service.yaml | 10 +- charts/wiremock/templates/serviceaccount.yaml | 12 ++ charts/wiremock/values.yaml | 67 +++++++++-- index.yaml | 28 +++++ wiremock-1.0.0.tgz | Bin 0 -> 5393 bytes 18 files changed, 360 insertions(+), 140 deletions(-) create mode 100644 charts/wiremock/templates/hpa.yaml create mode 100644 charts/wiremock/templates/serviceaccount.yaml create mode 100644 wiremock-1.0.0.tgz diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 671d507..a0ce331 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -20,11 +20,11 @@ jobs: git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: v3.8.1 + uses: azure/setup-helm@v4 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.4.0 + uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f448c5b..7157e55 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,36 +19,39 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Helm - uses: azure/setup-helm@v1 + uses: azure/setup-helm@v3 with: - version: v3.8.1 + version: v3.14.0 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: '3.12' + check-latest: true - name: Set up chart-testing - uses: helm/chart-testing-action@v2.2.1 + uses: helm/chart-testing-action@v2.6.1 - name: Run chart-testing (list-changed) id: list-changed run: | changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) if [[ -n "$changed" ]]; then - echo "::set-output name=changed::true" + echo "changed=true" >> "$GITHUB_OUTPUT" fi - name: Run chart-testing (lint) - run: ct lint + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} - name: Create kind cluster - uses: helm/kind-action@v1.2.0 if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.8.0 - name: Run chart-testing (install) - run: ct install \ No newline at end of file + if: steps.list-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} \ No newline at end of file diff --git a/README.md b/README.md index 5acd880..5dc5511 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,16 @@ and the chart remains partially compatible with it. ## Install WireMock +Once Helm is installed, you can either add this repository with `helm repo add`: + +```bash +helm repo add wiremock https://wiremock.github.io/helm-charts +``` + +You can then run `helm upgrade --install wiremock/wiremock` to install it through the repository. + +Alternatively, you can clone the helm repo and then install it with a local reference: + ```bash helm upgrade --install ./charts/ ``` diff --git a/charts/wiremock/.helmignore b/charts/wiremock/.helmignore index f0c1319..0e8a0eb 100644 --- a/charts/wiremock/.helmignore +++ b/charts/wiremock/.helmignore @@ -14,8 +14,10 @@ *.swp *.bak *.tmp +*.orig *~ # Various IDEs .project .idea/ *.tmproj +.vscode/ diff --git a/charts/wiremock/Chart.yaml b/charts/wiremock/Chart.yaml index eff7585..f955808 100644 --- a/charts/wiremock/Chart.yaml +++ b/charts/wiremock/Chart.yaml @@ -1,8 +1,28 @@ -apiVersion: v1 -appVersion: "3.0.0.1" -description: A Helm chart for WireMock deployment on Kubernetes +apiVersion: v2 name: wiremock -version: 0.2.0 +description: A Helm chart for WireMock deployment on Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "3.8.0" + maintainers: - name: "gitkent" url: "https://github.com/gitkent" diff --git a/charts/wiremock/README.md b/charts/wiremock/README.md index c2bd208..c5b1de6 100644 --- a/charts/wiremock/README.md +++ b/charts/wiremock/README.md @@ -25,12 +25,14 @@ Setup port forwarding ```bash $ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wiremock.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") -$ kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort}} +$ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + +$ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT ``` ## Verify Wiremock deployment -To verify erifying a response using Wiremock, run +To verify a response using Wiremock, run ```bash $ curl -X POST http://127.0.0.1:8080/v1/hello diff --git a/charts/wiremock/templates/NOTES.txt b/charts/wiremock/templates/NOTES.txt index 0b79830..d67eb39 100644 --- a/charts/wiremock/templates/NOTES.txt +++ b/charts/wiremock/templates/NOTES.txt @@ -1,7 +1,9 @@ 1. 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 }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "wiremock.fullname" . }}) @@ -9,12 +11,13 @@ echo http://$NODE_IP:$NODE_PORT {{- 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 {{ include "wiremock.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wiremock.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "wiremock.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wiremock.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wiremock.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort}} + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT echo "Visit http://127.0.0.1:8080/__admin/mappings to use your application" run "curl -X POST http://127.0.0.1:8080/v1/hello" -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/wiremock/templates/_helpers.tpl b/charts/wiremock/templates/_helpers.tpl index 867b754..4af380a 100644 --- a/charts/wiremock/templates/_helpers.tpl +++ b/charts/wiremock/templates/_helpers.tpl @@ -1,10 +1,9 @@ -{{/* vim: set filetype=mustache: */}} {{/* Expand the name of the chart. */}} {{- define "wiremock.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -12,21 +11,64 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "wiremock.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 -}} +{{- 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 "wiremock.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "wiremock.labels" -}} +helm.sh/chart: {{ include "wiremock.chart" . }} +{{ include "wiremock.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "wiremock.selectorLabels" -}} +app.kubernetes.io/name: {{ include "wiremock.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "wiremock.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "wiremock.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Pod annotations +*/}} +{{- define "wiremock.podAnnotations" -}} +checksum/configMappings: {{ include (print $.Template.BasePath "/configmap-mappings.yaml") . | sha256sum }} +checksum/configResponses: {{ include (print $.Template.BasePath "/configmap-responses.yaml") . | sha256sum }} +{{- if .Values.podAnnotations }} +{{ .Values.podAnnotations }} +{{- end }} +{{- end }} + diff --git a/charts/wiremock/templates/configmap-mappings.yaml b/charts/wiremock/templates/configmap-mappings.yaml index e362267..036b39e 100644 --- a/charts/wiremock/templates/configmap-mappings.yaml +++ b/charts/wiremock/templates/configmap-mappings.yaml @@ -2,12 +2,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "wiremock.fullname" . }}-mappings-configs - namespace: {{ .Release.Namespace | quote }} labels: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - helm.sh/chart: {{ include "wiremock.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "wiremock.labels" . | nindent 4 }} data: {{- $files := .Files }} {{- range $key, $value := .Files }} diff --git a/charts/wiremock/templates/configmap-responses.yaml b/charts/wiremock/templates/configmap-responses.yaml index d5b4017..61badf2 100644 --- a/charts/wiremock/templates/configmap-responses.yaml +++ b/charts/wiremock/templates/configmap-responses.yaml @@ -2,12 +2,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "wiremock.fullname" . }}-responses-configs - namespace: {{ .Release.Namespace | quote }} labels: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - helm.sh/chart: {{ include "wiremock.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "wiremock.labels" . | nindent 4 }} data: {{- $files := .Files }} {{- range $key, $value := .Files }} diff --git a/charts/wiremock/templates/deployment.yaml b/charts/wiremock/templates/deployment.yaml index 793d71c..f12575b 100644 --- a/charts/wiremock/templates/deployment.yaml +++ b/charts/wiremock/templates/deployment.yaml @@ -3,35 +3,47 @@ kind: Deployment metadata: name: {{ include "wiremock.fullname" . }} labels: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - helm.sh/chart: {{ include "wiremock.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "wiremock.labels" . | nindent 4 }} spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} + {{- end }} selector: matchLabels: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{- include "wiremock.selectorLabels" . | nindent 6 }} template: metadata: annotations: - checksum/configMappings: {{ include (print $.Template.BasePath "/configmap-mappings.yaml") . | sha256sum }} - checksum/configResponses: {{ include (print $.Template.BasePath "/configmap-responses.yaml") . | sha256sum }} + {{- include "wiremock.podAnnotations" . | nindent 8 }} labels: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{- include "wiremock.selectorLabels" . | nindent 8 }} spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "wiremock.serviceAccountName" . }} + {{- if .Values.podSecurityContext.enabled }} + securityContext: + {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 -}} + {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- if .Values.securityContext.enabled }} + securityContext: + {{- omit .Values.securityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - {{- if .Values.env }} + {{- with .Values.env }} env: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.args }} + args: + {{- range .Values.args }} + - {{ . | quote }} {{- end }} - {{- range $key, $value := .Values.env }} - - name: {{ $key }} - value: {{ tpl $value $ | quote }} {{- end }} ports: - containerPort: {{ .Values.service.internalPort }} @@ -47,43 +59,47 @@ spec: port: {{ .Values.service.internalPort }} scheme: {{ .Values.scheme }} resources: -{{ toYaml .Values.resources | indent 12 }} + {{- toYaml .Values.resources | nindent 12 }} volumeMounts: - - mountPath: /home/wiremock/storage/mappings - name: mappings-data - - mountPath: /home/wiremock/storage/__files - name: responses-data + - mountPath: /home/wiremock/storage/mappings + name: mappings-data + - mountPath: /home/wiremock/storage/__files + name: responses-data initContainers: - - name: copy-mappings - image: "{{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}" - imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }} - command: ["bash", "-c", "cp -rf /data/mappings /home/wiremock/storage/mappings"] - volumeMounts: - - mountPath: /data/mappings - name: mappings-volume - - mountPath: /home/wiremock/storage/mappings - name: mappings-data - - name: copy-responses - image: "{{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}" - imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }} - command: ["bash", "-c", "cp -rf /data/responses /home/wiremock/storage/__files"] - volumeMounts: - - mountPath: /data/responses - name: responses-volume - - mountPath: /home/wiremock/storage/__files - name: responses-data - {{- with .Values.nodeSelector }} + - name: copy-mappings + {{- if .Values.securityContext.enabled }} + securityContext: + {{- omit .Values.securityContext "enabled" | toYaml | nindent 12 -}} + {{- end }} + image: "{{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}" + imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }} + command: ["bash", "-c", "cp -rf /data/mappings /home/wiremock/storage/mappings"] + volumeMounts: + - mountPath: /data/mappings + name: mappings-volume + - mountPath: /home/wiremock/storage/mappings + name: mappings-data + - name: copy-responses + image: "{{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}" + imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }} + command: ["bash", "-c", "cp -rf /data/responses /home/wiremock/storage/__files"] + volumeMounts: + - mountPath: /data/responses + name: responses-volume + - mountPath: /home/wiremock/storage/__files + name: responses-data + {{- with .Values.nodeSelector }} nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} tolerations: -{{ toYaml . | indent 8 }} - {{- end }} + {{- toYaml . | nindent 8 }} + {{- end }} volumes: - name: mappings-data emptyDir: {} diff --git a/charts/wiremock/templates/hpa.yaml b/charts/wiremock/templates/hpa.yaml new file mode 100644 index 0000000..48ebec6 --- /dev/null +++ b/charts/wiremock/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "wiremock.fullname" . }} + labels: + {{- include "wiremock.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "wiremock.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/wiremock/templates/ingress.yaml b/charts/wiremock/templates/ingress.yaml index d99ea9f..0abf006 100644 --- a/charts/wiremock/templates/ingress.yaml +++ b/charts/wiremock/templates/ingress.yaml @@ -1,42 +1,61 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := .Values.service.name -}} -{{- $servicePort := .Values.service.externalPort -}} -{{- $ingressPath := .Values.ingress.path -}} +{{- $fullName := include "wiremock.fullname" . -}} +{{- $svcPort := .Values.service.externalPort -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.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: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - helm.sh/chart: {{ include "wiremock.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} + {{- include "wiremock.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} annotations: -{{ toYaml . | indent 4 }} -{{- end }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: -{{- if .Values.ingress.tls }} + {{- 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 }} + {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} + {{- range .hosts }} - {{ . | quote }} - {{- end }} + {{- end }} secretName: {{ .secretName }} + {{- end }} {{- end }} -{{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} http: paths: - - path: {{ $ingressPath }} - pathType: Prefix + {{- 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: {{ $servicePort }} - {{- end }} + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/wiremock/templates/service.yaml b/charts/wiremock/templates/service.yaml index 6944b6a..834c6bd 100644 --- a/charts/wiremock/templates/service.yaml +++ b/charts/wiremock/templates/service.yaml @@ -3,17 +3,13 @@ kind: Service metadata: name: {{ include "wiremock.fullname" . }} labels: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - helm.sh/chart: {{ include "wiremock.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "wiremock.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.externalPort }} targetPort: {{ .Values.service.internalPort }} protocol: TCP - name: {{ .Values.service.name }} + name: {{ include "wiremock.fullname" . }} selector: - app.kubernetes.io/name: {{ include "wiremock.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{- include "wiremock.selectorLabels" . | nindent 4 }} diff --git a/charts/wiremock/templates/serviceaccount.yaml b/charts/wiremock/templates/serviceaccount.yaml new file mode 100644 index 0000000..3c157b3 --- /dev/null +++ b/charts/wiremock/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "wiremock.serviceAccountName" . }} + labels: + {{- include "wiremock.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/wiremock/values.yaml b/charts/wiremock/values.yaml index ca5d085..efa0b5e 100644 --- a/charts/wiremock/values.yaml +++ b/charts/wiremock/values.yaml @@ -6,7 +6,8 @@ replicaCount: 1 image: repository: wiremock/wiremock - tag: 3.2.0-3 + # Overrides the image tag whose default is the chart appVersion. + tag: 3.8.0 pullPolicy: IfNotPresent initContainer: @@ -15,29 +16,68 @@ initContainer: tag: 5 pullPolicy: Always +imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroupChangePolicy: Always + # sysctls: [] + # supplementalGroups: [] + # fsGroup: 2000 + +securityContext: {} + # seLinuxOptions: {} + # runAsUser: 1000 + # runAsGroup: 2000 + # runAsNonRoot: true + # privileged: false + # readOnlyRootFilesystem: true + # allowPrivilegeEscalation: false + # capabilities: + # drop: ["ALL"] + # seccompProfile: + # type: "RuntimeDefault" + service: - name: wiremock type: ClusterIP externalPort: 9021 internalPort: 9021 ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - path: / hosts: - - chart-example.local + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: # - chart-example.local -env: - WIREMOCK_OPTIONS: "--port=9021 --max-request-journal=1000 --local-response-templating --root-dir=/home/wiremock/storage" + +env: {} + +args: + - "--port=9021" + - "--max-request-journal=1000" + - "--local-response-templating" + - "--root-dir=/home/wiremock/storage" resources: {} # We usually recommend not to specify default resources and to leave this as a conscious @@ -45,11 +85,18 @@ resources: {} # 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 + # cpu: 100m + # memory: 128Mi # requests: - # cpu: 100m - # memory: 128Mi + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 nodeSelector: {} diff --git a/index.yaml b/index.yaml index 8092c6f..b87181d 100644 --- a/index.yaml +++ b/index.yaml @@ -1,6 +1,34 @@ apiVersion: v1 entries: wiremock: + - apiVersion: v2 + appVersion: 3.8.0 + created: "2024-07-03T21:57:38.6754555+01:00" + description: A Helm chart for WireMock deployment on Kubernetes + digest: 11791339638d47bf7b1b3ae6d6ae81f34c061c0938bc6ed9af86bd40d0e5220f + home: https://wiremock.org + icon: https://wiremock.org/images/logos/wiremock/logo_square.svg + keywords: + - wiremock + - api + - openapi + - api-testing + - rest-api + - api-mocking + maintainers: + - name: gitkent + url: https://github.com/gitkent + - name: oleg-nenashev + url: https://github.com/oleg-nenashev + name: wiremock + sources: + - https://github.com/wiremock/helm-charts + - https://github.com/wiremock/wiremock-docker + - https://github.com/wiremock/wiremock + type: application + urls: + - https://wiremock.github.io/helm-charts/wiremock-1.0.0.tgz + version: 1.0.0 - apiVersion: v1 appVersion: 3.0.0.1 created: "2023-08-30T15:32:11.9806537+02:00" diff --git a/wiremock-1.0.0.tgz b/wiremock-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..77a96ffefc85fae20a46250573de34695ece5091 GIT binary patch literal 5393 zcmV+s74GUEiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PKDHa~n6(V18y5|A)S@wqoZrLsBn$S>>zK%HFJQZCNKN&bQ@C z+2Bl*M1%n*0ERMG(f7B11z_GBJ|ru0k`<~Fkzk|IXmmFkjRt&0CB`DW>>W*s)WMv@ z?3?>8{eHiHu(xOb_WS+j-$DQR!8e1wgT2A-?*4v%_nZD;x4$#^2Kx6-NlQtUCi0v9 z7x&d1+#jTnguX|qsNh4G?Q}?z6km6P7eT)hp$a8Uw5>XXe;|t?G_nF?A>l_V@vR6i zA;N@-d5m0x;PB6Mgp#91)tQPIhcMMTQNvy@7q>vjNr#38XWLIb8j}gC9upIxieK#4 zkLs6{NDS0$(z(R>m5`Adc6`WzIzEtuc6<;Ca`%ZO)Yqsq<&%yN5|#GLA50tbLrf^w zgmRP?9VdqD3DuX#bq64otR!_p^)wv?p@@4qMBYL$ocJ6$QB$0)Xjg}GZHpl&k;)J) z9W6}@c1)4QzMTuT1~UKPM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