From 91e181dd68483d79bf8030973b30a441d1e417c7 Mon Sep 17 00:00:00 2001 From: Tim Collins <45351296+tico24@users.noreply.github.com> Date: Wed, 3 Feb 2021 08:03:29 +0000 Subject: [PATCH] API readiness probe and service tests (#39) * Merge connection tests into one file * Small comment in the connection test yaml to explain what's going on * Simplify the mongo ci values file to clarify what's being tested * A test to pull the 'latest' docker images rather than the version fixed to the chart * Newline to appease the linter * Futher linter pacification * Chart version increase * API readiness probe and service tests * Update readme for new values and drop default readiness thresholds a touch --- charts/sorry-cypress/Chart.yaml | 2 +- charts/sorry-cypress/README.md | 37 +++++++++++-------- .../sorry-cypress/ci/latest-image-values.yaml | 3 ++ .../templates/deployment-api.yml | 10 +++++ .../templates/test/test-connections.yaml | 21 ++++++++++- charts/sorry-cypress/values.yaml | 8 ++++ 6 files changed, 63 insertions(+), 18 deletions(-) diff --git a/charts/sorry-cypress/Chart.yaml b/charts/sorry-cypress/Chart.yaml index f3eb872..1275412 100644 --- a/charts/sorry-cypress/Chart.yaml +++ b/charts/sorry-cypress/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: sorry-cypress description: A Helm chart for Sorry Cypress type: application -version: 0.1.32 +version: 0.1.33 appVersion: 0.6.1 home: https://sorry-cypress.dev/ sources: diff --git a/charts/sorry-cypress/README.md b/charts/sorry-cypress/README.md index c659ee5..0f10d08 100644 --- a/charts/sorry-cypress/README.md +++ b/charts/sorry-cypress/README.md @@ -58,20 +58,25 @@ The following table lists the configurable parameters of the sorry-cypress chart https://sorry-cypress.dev/api#configuration -| Parameter | Description | Default | -| --------------------------- | ------------------------------------- | --------------------------- | -| `api.image.repository` | Image repository | `agoldis/sorry-cypress-api` | -| `api.image.tag` | Image tag | `latest` | -| `api.image.pullPolicy` | Image pull policy | `Always` | -| `api.resources` | Resources to initialize the container | `{}` | -| `api.podAnnotations` | Set annotations for pods | `{}` | -| `api.podLabels` | Set additional labels for pods | `{}` | -| `api.service.port` | Kubernetes service port | `4000` | -| `api.ingress.labels` | Ingress labels | `{}` | -| `api.ingress.annotations` | Ingress annotations | `{}` | -| `api.ingress.hosts[0].host` | Hostname to the service installation | `api.chart-example.local` | -| `api.ingress.hosts[0].path` | Root path to the service installation | `/` | -| `api.ingress.tls` | Ingress secrets for TLS certificates | `[]` | +| Parameter | Description | Default | +| --------------------------------------- | ----------------------------------------------------------------------------------------------- | --------------------------- | +| `api.image.repository` | Image repository | `agoldis/sorry-cypress-api` | +| `api.image.tag` | Image tag | `` | +| `api.image.pullPolicy` | Image pull policy | `Always` | +| `api.resources` | Resources to initialize the container | `{}` | +| `api.podAnnotations` | Set annotations for pods | `{}` | +| `api.podLabels` | Set additional labels for pods | `{}` | +| `api.service.port` | Kubernetes service port | `4000` | +| `api.readinessProbe.enabled` | Enables a readiness probe for the pod | `false` | +| `api.readinessProbe.periodSeconds` | How often (in seconds) to perform the probe. | `5` | +| `api.readinessProbe.timeoutSeconds` | Number of seconds after which the probe times out. | `3` | +| `api.readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | `2` | +| `api.readinessProbe.failureThreshold` | When a probe fails, Kubernetes will try `failureThreshold` times before giving up. | `5` | +| `api.ingress.labels` | Ingress labels | `{}` | +| `api.ingress.annotations` | Ingress annotations | `{}` | +| `api.ingress.hosts[0].host` | Hostname to the service installation | `api.chart-example.local` | +| `api.ingress.hosts[0].path` | Root path to the service installation | `/` | +| `api.ingress.tls` | Ingress secrets for TLS certificates | `[]` | ### Dashboard service @@ -80,7 +85,7 @@ https://sorry-cypress.dev/dashboard#configuration | Parameter | Description | Default | | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------- | | `dashboard.image.repository` | Image repository | `agoldis/sorry-cypress-dashboard` | -| `dashboard.image.tag` | Image tag | `latest` | +| `dashboard.image.tag` | Image tag | `` | | `dashboard.image.pullPolicy` | Image pull policy | `Always` | | `dashboard.resources` | Resources to initialize the container | `{}` | | `dashboard.environmentVariables.ciUrl` | Set the `CI_URL` optional environment variable to add a link to your CI tool | `""` | @@ -103,7 +108,7 @@ https://sorry-cypress.dev/director/configuration | Parameter | Description | Default | | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | | `director.image.repository` | Image repository | `agoldis/sorry-cypress-director` | -| `director.image.tag` | Image tag | `latest` | +| `director.image.tag` | Image tag | `` | | `director.image.pullPolicy` | Image pull policy | `Always` | | `director.resources` | Resources to initialize the container | `{}` | | `director.environmentVariables.allowedKeys` | Define the list of comma delimited record keys (provided to the Cypress Runner using `--key` option). Empty or not provided variable means that all record keys are allowed. | `""` | diff --git a/charts/sorry-cypress/ci/latest-image-values.yaml b/charts/sorry-cypress/ci/latest-image-values.yaml index eb83031..3858030 100644 --- a/charts/sorry-cypress/ci/latest-image-values.yaml +++ b/charts/sorry-cypress/ci/latest-image-values.yaml @@ -6,6 +6,9 @@ api: pullPolicy: Always tag: "latest" + readinessProbe: + enabled: true + dashboard: image: repository: agoldis/sorry-cypress-dashboard diff --git a/charts/sorry-cypress/templates/deployment-api.yml b/charts/sorry-cypress/templates/deployment-api.yml index e9891b7..288ee89 100644 --- a/charts/sorry-cypress/templates/deployment-api.yml +++ b/charts/sorry-cypress/templates/deployment-api.yml @@ -37,6 +37,16 @@ spec: - containerPort: 4000 resources: {{- toYaml .Values.api.resources | nindent 10 }} + {{- if .Values.api.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: /.well-known/apollo/server-health + port: 4000 + periodSeconds: {{ .Values.api.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.api.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.api.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.api.readinessProbe.failureThreshold }} + {{- end }} restartPolicy: Always serviceAccountName: "" volumes: null \ No newline at end of file diff --git a/charts/sorry-cypress/templates/test/test-connections.yaml b/charts/sorry-cypress/templates/test/test-connections.yaml index b6e8df9..d9cca17 100644 --- a/charts/sorry-cypress/templates/test/test-connections.yaml +++ b/charts/sorry-cypress/templates/test/test-connections.yaml @@ -73,4 +73,23 @@ spec: - "{{ include "sorry-cypress-helm.fullname" . }}-minio:9000/minio/login" restartPolicy: Never {{- end }} -# Note. Not testing API yet.. can't do a 'get' on that unless there's a nice secret healthz path hidden somewhere. +--- +{{- if .Values.api.readinessProbe.enabled }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "sorry-cypress-helm.fullname" . }}-test-api-connection" + labels: + app.kubernetes.io/name: "{{ include "sorry-cypress-helm.fullname" . }}-test-api-connection" + annotations: + "helm.sh/hook": test-success + "helm.sh/hook-delete-policy": hook-succeeded +spec: + containers: + - name: wget + image: busybox + command: + - wget + - '{{ include "sorry-cypress-helm.fullname" . }}-api:{{ .Values.api.service.port }}/.well-known/apollo/server-health' + restartPolicy: Never +{{- end }} \ No newline at end of file diff --git a/charts/sorry-cypress/values.yaml b/charts/sorry-cypress/values.yaml index 2015909..1163bf9 100644 --- a/charts/sorry-cypress/values.yaml +++ b/charts/sorry-cypress/values.yaml @@ -24,6 +24,14 @@ api: service: port: 4000 + # If you are using v10.0.0-beta.15 or greater, you can enable a readinessProbe for the API pods. + readinessProbe: + enabled: false + periodSeconds: 5 + timeoutSeconds: 3 + successThreshold: 2 + failureThreshold: 5 + # Set annotations for pods podAnnotations: {}