Commit dfc53d76 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Merge branch 'auto-deploy-image-add-startup-probes' into 'master'

Add startup probes to protect slow starting containers

Closes #134

See merge request gitlab-org/cluster-integration/auto-deploy-image!288
parents c357ab86 ed36a3e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
apiVersion: v1
description: GitLab's Auto-deploy Helm Chart
name: auto-deploy-app
version: 2.33.0
version: 2.34.0
icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png
+9 −0
Original line number Diff line number Diff line
@@ -87,6 +87,15 @@
| readinessProbe.timeoutSeconds | # of seconds after which the readiness probe times out. | `3`                                |
| readinessProbe.probeType     | Type of [readiness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes) to use. | `httpGet`
| readinessProbe.command       | Commands for use with probe type 'exec'. | `{}`
| startupProbe.enabled         | If true, enables startup probe. | `/`                                |
| startupProbe.path            | Path to access on the HTTP server on periodic probe of container startup. | `/`                                |
| startupProbe.scheme          | Scheme to access the HTTP server (HTTP or HTTPS). | `HTTP`                                |
| startupProbe.initialDelaySeconds | # of seconds after the container has started before startup probes are initiated. | `5`                                |
| startupProbe.timeoutSeconds  | # of seconds after which the startup probe times out. | `3`                                |
| startupProbe.failureThreshold | # of times, Kubernetes will retry failed probes before giving up. | `30`                                |
| startupProbe.periodSeconds  | How often (in seconds) to perform the probe. | `10`                                |
| startupProbe.probeType      | Type of [startup probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes) to use. | `httpGet`
| startupProbe.command        | Commands for use with probe type 'exec'. | `{}`
| postgresql.managed            | If true, this will provision a managed Postgres instance via crossplane.            | `false`                             |
| postgresql.managedClassSelector            | This will allow provisioning a Postgres instance based on label selectors via Crossplane, eg: `managedClassSelector.matchLabels.stack: gitlab`. The `postgresql.managed` value should be true as well for this to be honoured. [Crossplane Configuration](https://docs.gitlab.com/ee/user/clusters/applications.html#crossplane)            | `{}`                             |
| podDisruptionBudget.enabled   |             | `false`                            |
+20 −0
Original line number Diff line number Diff line
@@ -174,6 +174,26 @@ spec:
{{- end }}
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
{{- if .Values.startupProbe.enabled }}
        startupProbe:
{{- if eq .Values.startupProbe.probeType "httpGet" }}
          httpGet:
            path: {{ .Values.startupProbe.path }}
            scheme: {{ .Values.startupProbe.scheme }}
            port: {{ .Values.startupProbe.port | default .Values.service.internalPort }}
{{- else if eq .Values.startupProbe.probeType "tcpSocket" }}
          tcpSocket:
            port: {{ .Values.startupProbe.port | default .Values.service.internalPort }}
{{- else if eq .Values.startupProbe.probeType "exec" }}
          exec:
            command:
{{ toYaml .Values.startupProbe.command | indent 14 }}
{{- end }}
          initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
          failureThreshold: {{ .Values.startupProbe.failureThreshold }}
          periodSeconds: {{ .Values.startupProbe.periodSeconds }}
{{- end }}
        resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.persistence.enabled }}
+29 −1
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ func TestDeploymentTemplate(t *testing.T) {
		})
	}

	// deployment livenessProbe, and readinessProbe tests
	// deployment livenessProbe, readinessProbe, and startupProbe tests
	for _, tc := range []struct {
		CaseName string
		Release  string
@@ -404,12 +404,14 @@ func TestDeploymentTemplate(t *testing.T) {

		ExpectedLivenessProbe  *coreV1.Probe
		ExpectedReadinessProbe *coreV1.Probe
		ExpectedStartupProbe *coreV1.Probe
	}{
		{
			CaseName:               "defaults",
			Release:                "production",
			ExpectedLivenessProbe:  defaultLivenessProbe(),
			ExpectedReadinessProbe: defaultReadinessProbe(),
			ExpectedStartupProbe: nil,
		},
		{
			CaseName: "custom liveness probe",
@@ -429,6 +431,7 @@ func TestDeploymentTemplate(t *testing.T) {
				TimeoutSeconds:      15,
			},
			ExpectedReadinessProbe: defaultReadinessProbe(),
			ExpectedStartupProbe: nil,
		},
		{
			CaseName: "custom readiness probe",
@@ -448,6 +451,30 @@ func TestDeploymentTemplate(t *testing.T) {
				InitialDelaySeconds: 5,
				TimeoutSeconds:      3,
			},
			ExpectedStartupProbe: nil,
		},
		{
			CaseName: "custom startup probe",
			Release:  "production",
			Values: map[string]string{
				"startupProbe.enabled": "true",
				"startupProbe.port": "2345",
			},
			ExpectedLivenessProbe: defaultLivenessProbe(),
			ExpectedReadinessProbe: defaultReadinessProbe(),
			ExpectedStartupProbe: &coreV1.Probe{
				Handler: coreV1.Handler{
					HTTPGet: &coreV1.HTTPGetAction{
						Path:   "/",
						Port:   intstr.FromInt(2345),
						Scheme: coreV1.URISchemeHTTP,
					},
				},
				InitialDelaySeconds: 5,
				TimeoutSeconds:      3,
				FailureThreshold:    30,
				PeriodSeconds:       10,
			},
		},
	} {
		t.Run(tc.CaseName, func(t *testing.T) {
@@ -472,6 +499,7 @@ func TestDeploymentTemplate(t *testing.T) {

			require.Equal(t, tc.ExpectedLivenessProbe, deployment.Spec.Template.Spec.Containers[0].LivenessProbe)
			require.Equal(t, tc.ExpectedReadinessProbe, deployment.Spec.Template.Spec.Containers[0].ReadinessProbe)
			require.Equal(t, tc.ExpectedStartupProbe, deployment.Spec.Template.Spec.Containers[0].StartupProbe)
		})
	}

+9 −0
Original line number Diff line number Diff line
@@ -114,6 +114,15 @@ readinessProbe:
  timeoutSeconds: 3
  scheme: "HTTP"
  probeType: "httpGet"
startupProbe:
  enabled: false
  path: "/"
  initialDelaySeconds: 5
  timeoutSeconds: 3
  failureThreshold: 30
  periodSeconds: 10
  scheme: "HTTP"
  probeType: "httpGet"

#hostAliases:
#- ip: X.X.X.X