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 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 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 00000000..4c91a3d3 Binary files /dev/null and b/charts/radar-mockserver/charts/mockserver-5.15.0.tgz differ diff --git a/charts/radar-mockserver/requirements.lock b/charts/radar-mockserver/requirements.lock new file mode 100644 index 00000000..64b923d5 --- /dev/null +++ b/charts/radar-mockserver/requirements.lock @@ -0,0 +1,6 @@ +dependencies: +- name: mockserver + repository: file://../../external/mockserver + version: 5.15.0 +digest: sha256:a7efbef89dfa87228b72ddf2609d453ceeae685f1fa37cf3e43c619570f7bff6 +generated: "2024-11-19T16:23:50.13254776+01:00" diff --git a/charts/radar-mockserver/templates/configmap.yaml b/charts/radar-mockserver/templates/configmap.yaml new file mode 100644 index 00000000..67d443ff --- /dev/null +++ b/charts/radar-mockserver/templates/configmap.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + # Must be 'mockserver-config' for automount in mockserver. Do not change. + name: mockserver-config + namespace: mockserver + labels: + app: mockserver +data: + mockserver.properties: | + mockserver.maxSocketTimeout=120000 + mockserver.sslCertificateDomainName=localhost + mockserver.sslSubjectAlternativeNameIps=127.0.0.1 + mockserver.enableCORSForAPI=true + mockserver.enableCORSForAllResponses=true + mockserver.initializationJsonPath=/config/initializerJson.json + initializerJson.json: {{ .Values.expectations | toJson | quote}} diff --git a/charts/radar-mockserver/values.yaml b/charts/radar-mockserver/values.yaml new file mode 100644 index 00000000..07f15375 --- /dev/null +++ b/charts/radar-mockserver/values.yaml @@ -0,0 +1,55 @@ +# Expecations that will be passed as 'expectation json' to mockserver. +expectations: [] + +mockserver: + 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: {} diff --git a/external/mockserver/.helmignore b/external/mockserver/.helmignore new file mode 100644 index 00000000..11d183e2 --- /dev/null +++ b/external/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/external/mockserver/Chart.yaml b/external/mockserver/Chart.yaml new file mode 100644 index 00000000..dc57aef8 --- /dev/null +++ b/external/mockserver/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +name: mockserver +version: "5.15.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). +keywords: + - mocking + - mock-server + - http-mock + - http + - test + - test-server + - proxy + - http-proxy + - socks-proxy + - https-proxy +home: "http://mock-server.com" +sources: + - "https://github.com/mock-server/mockserver" + - "https://hub.docker.com/r/mockserver/mockserver" +maintainers: + - name: James D Bloom + email: jamesdbloom+mockserver@gmail.com +icon: http://mock-server.com/apple-touch-icon.png diff --git a/external/mockserver/README.md b/external/mockserver/README.md new file mode 100644 index 00000000..aeca7af0 --- /dev/null +++ b/external/mockserver/README.md @@ -0,0 +1,171 @@ +## Installing MockServer + +### Prerequisites + +- Kubernetes (i.e. [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) or [Docker for Desktop](https://www.docker.com/products/docker-desktop)) +- [Helm](https://docs.helm.sh/using_helm/#quickstart-guide) + +### Helm Install + +To run MockServer in Kubernetes the easiest way is to use the existing [MockServer helm chart](http://www.mock-server.com/mockserver-5.15.0.tgz). + +This is available by using `www.mock-server.com` as a chart repo, with the following command: + +```bash +helm upgrade --install --create-namespace --namespace mockserver mockserver http://www.mock-server.com/mockserver-5.15.0.tgz +``` + +**OR** + +If you have helm chart source folder (i.e. you have the repository cloned): + +```bash +helm upgrade --install --create-namespace --namespace mockserver mockserver helm/mockserver +``` + +The two commands above will install MockServer into a **namespace** called `mockserver` with default configuration (as per the embedded [values.yaml](https://github.com/mock-server/mockserver/blob/master/helm/mockserver/values.yaml)). +MockServer will then be available on domain name `mockserver.mockserver.svc.cluster.local`, as long as the namespace you are calling from isn't prevented (by network policy) to call the `mockserver` namespace. + +**THEN** + +To view the logs: + +```bash +kubectl -n mockserver logs --tail=100 -l app=mockserver,release=mockserver +``` + +To wait until the deployment is complete run: + +```bash +kubectl -n mockserver rollout status deployments mockserver +``` + +To check the status of the deployment without waiting, run the following command and confirm the `mockserver` has the `Running` status: + +```bash +kubectl -n mockserver get po -l release=mockserver +``` + +### Basic MockServer Configuration + +Modify the arguments used to start the docker container by setting values explicitly using `--set`, as follows: + +```bash +helm upgrade --install --create-namespace --namespace mockserver --set app.serverPort=1080 --set app.logLevel=INFO mockserver http://www.mock-server.com/mockserver-5.15.0.tgz +``` + +The following values are supported: +- `app.serverPort` (default: 1080) +- `app.logLevel` (default: INFO) +- `app.proxyRemoteHost` (no default) +- `app.proxyRemotePort` (no default) +- `app.jvmOptions` (no default) +- `image.snapshot` (default: false) - set `true` to use latest snapshot version + +For example configure a proxyRemoteHost and proxyRemotePort, as follows: + +```bash +helm upgrade --install --create-namespace --namespace mockserver --set app.serverPort=1080 --set app.proxyRemoteHost=www.mock-server.com --set app.proxyRemotePort=443 mockserver http://www.mock-server.com/mockserver-5.15.0.tgz +``` + +Double check the correct arguments have been passed to the pod, as follows: + +```bash +kubectl -n mockserver logs -l app=mockserver,release=mockserver +``` + +### Detailed MockServer Configuration + +If a configmap called `mockserver-config` exists in the same namespace this will be mapped into the MockServer container under the `mountPath` `/config`. +This configmap can be used to configure MockServer by containing a `mockserver.properties` file and other related configuration files such as a: +- [json expectation initialization](https://www.mock-server.com/mock_server/initializing_expectations.html), or +- custom [TLS CA, X.509 Certificate or Private Key](https://www.mock-server.com/mock_server/HTTPS_TLS.html#configuration) +The `mockserver.properties` file should load these additional files from the directory `/config` which is the `mountPath` for the configmap. + +See [MockServer Configuration](https://www.mock-server.com/mock_server/configuration_properties.html) for details of all configuration options. + +The mapping of the configuration configmap can be configured as follows: +- `app.mountedConfigMapName` (default: mockserver-config) - name of the configuration configmap (in the same namespace) to mount +- `app.propertiesFileName` (default: mockserver.properties) - path of the property file in the configmap + +For example: + +```bash +helm upgrade --install --create-namespace --namespace mockserver --set app.mountedConfigMapName=other-mockserver-config --set app.propertiesFileName=other-mockserver.properties mockserver helm/mockserver +``` + +An example of a helm chart to configure MockServer is [helm/mockserver-config](https://github.com/mock-server/mockserver/tree/master/helm/mockserver-config) + +### Extending MockServer Classpath + +To use [class callbacks](https://www.mock-server.com/mock_server/creating_expectations.html#button_response_class_callback) or an [expectation initializer class](https://www.mock-server.com/mock_server/initializing_expectations.html#expectation_initializer_class) the classpath for MockServer must include the specified classes. +To support adding classes to the classpath if a configmap called `mockserver-config` exists in the same namespace any jar files contained in this configmap will be added into MockServer classpath. + +The mapping of the libs configmap can be configured as follows: +- `app.mountedLibsConfigMapName` (default: mockserver-config) - name of the libs configmap (in the same namespace) to mount + +For example: + +```bash +helm upgrade --install --create-namespace --namespace mockserver --set app.mountedLibsConfigMapName=mockserver-libs mockserver helm/mockserver +``` + +### MockServer URL + +#### Local Kubernetes Cluster (i.e. [minikube](https://github.com/kubernetes/minikube), [microk8s](https://microk8s.io/)) + +If the `service` type hasn't been modified the following will provide the MockServer URL from outside the cluster. + +```bash +export NODE_PORT=$(kubectl get -n mockserver -o jsonpath="{.spec.ports[0].nodePort}" services mockserver) +export NODE_IP=$(kubectl get nodes -n mockserver -o jsonpath="{.items[0].status.addresses[0].address}") +export MOCKSERVER_HOST=$NODE_IP:$NODE_PORT +echo http://$MOCKSERVER_HOST +``` + +To test the installation the following `curl` command should return the ports MockServer is bound to: + +```bash +curl -v -X PUT http://$MOCKSERVER_HOST/status +``` + +#### Docker for Desktop + +[Docker for Desktop](https://www.docker.com/products/docker-desktop) automatically exposes **LoadBalancer** services. +On MacOS Docker for Desktop runs inside [Hyperkit](https://github.com/moby/hyperkit) so the node IP address is not reachable, therefore the only way to call services is via the exposed **LoadBalancer** service added by Docker for Desktop. + +To ensure that Docker for Desktop exposes MockServer update the service type to **LoadBalancer** using **--set service.type=LoadBalancer** and set the exposed port using **--set service.port=1080**, as follows: + +```bash +helm upgrade --install --namespace mockserver --set service.type=LoadBalancer --set service.port=1080 mockserver http://www.mock-server.com/mockserver-5.15.0.tgz +``` + +MockServer will then be reachable on **http://localhost:1080** + +For **LoadBalancer** services it is possible to query kubernetes to programmatically determine the MockServer base URL as follows: + +```bash +export SERVICE_IP=$(kubectl get svc --namespace mockserver mockserver -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') +export MOCKSERVER_HOST=$SERVICE_IP:1081 +echo http://$MOCKSERVER_HOST +``` + +#### Outside Remote Kubernetes Cluster (i.e. Azure AKS, AWS EKS, etc) + +```bash +kubectl -n mockserver port-forward svc/mockserver 1080:1080 & +export MOCKSERVER_HOST=127.0.0.1:1080 +echo http://$MOCKSERVER_HOST +``` + +#### Inside Kubernetes Cluster + +If a [DNS server](https://kubernetes.io/docs/concepts/services-networking/service/#dns) has been installed in the Kubernetes cluster the following DNS name should be available `mockserver..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: {}