Skip to content

Commit

Permalink
API readiness probe and service tests (#39)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tico24 authored Feb 3, 2021
1 parent 7b28cdf commit 91e181d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 18 deletions.
2 changes: 1 addition & 1 deletion charts/sorry-cypress/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
37 changes: 21 additions & 16 deletions charts/sorry-cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 | `""` |
Expand All @@ -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. | `""` |
Expand Down
3 changes: 3 additions & 0 deletions charts/sorry-cypress/ci/latest-image-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ api:
pullPolicy: Always
tag: "latest"

readinessProbe:
enabled: true

dashboard:
image:
repository: agoldis/sorry-cypress-dashboard
Expand Down
10 changes: 10 additions & 0 deletions charts/sorry-cypress/templates/deployment-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 20 additions & 1 deletion charts/sorry-cypress/templates/test/test-connections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
8 changes: 8 additions & 0 deletions charts/sorry-cypress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}

Expand Down

0 comments on commit 91e181d

Please sign in to comment.