From fee5a7074640c2fa3f072570e7613d7fd7e657cb Mon Sep 17 00:00:00 2001 From: DavidSpek Date: Tue, 16 May 2023 11:17:23 +0200 Subject: [PATCH] update deepcopy and crd Signed-off-by: DavidSpek --- pkg/apis/acid.zalan.do/v1/crds.go | 252 ++++++++++++++++++ .../acid.zalan.do/v1/zz_generated.deepcopy.go | 10 + pkg/util/config/config.go | 1 + 3 files changed, 263 insertions(+) diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 558a03f0f..a8650c37a 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -363,6 +363,132 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{ }, }, }, + "livenessProbe": { + Description: "Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: "object", + Properties: map[string]apiextv1.JSONSchemaProps{ + "exec": { + Description: "One and only one of the following should be specified. Exec specifies the action to take.", + Type: "object", + Properties: map[string]apiextv1.JSONSchemaProps{ + "command": { + Description: "Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.", + Type: "array", + Items: &apiextv1.JSONSchemaPropsOrArray{ + Schema: &apiextv1.JSONSchemaProps{ + Type: "string", + }, + }, + }, + }, + }, + "failureThreshold": { + Description: "Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1.", + Type: "integer", + Format: "int32", + }, + "httpGet": { + Description: "HTTPGet specifies the http request to perform.", + Type: "object", + Required: []string{"port"}, + Properties: map[string]apiextv1.JSONSchemaProps{ + "host": { + Description: "Host name to connect to, defaults to the pod IP. You probably want to set \"Host\" in httpHeaders instead.", + Type: "string", + }, + "httpHeaders": { + Description: "Custom headers to set in the request. HTTP allows repeated headers.", + Type: "array", + Items: &apiextv1.JSONSchemaPropsOrArray{ + Schema: &apiextv1.JSONSchemaProps{ + Description: "HTTPHeader describes a custom header to be used in HTTP probes", + Type: "object", + Required: []string{"name", "value"}, + Properties: map[string]apiextv1.JSONSchemaProps{ + "name": { + Description: "The header field name", + Type: "string", + }, + "value": { + Description: "The header field value", + Type: "string", + }, + }, + }, + }, + }, + "path": { + Description: "Path to access on the HTTP server.", + Type: "string", + }, + "port": { + Description: "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + AnyOf: []apiextv1.JSONSchemaProps{ + { + Type: "integer", + }, + { + Type: "string", + }, + }, + XIntOrString: true, + }, + "scheme": { + Description: "Scheme to use for connecting to the host. Defaults to HTTP.", + Type: "string", + }, + }, + }, + "initialDelaySeconds": { + Description: "Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: "integer", + Format: "int32", + }, + "periodSeconds": { + Description: "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.", + Type: "integer", + Format: "int32", + }, + "successThreshold": { + Description: "Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.", + Type: "integer", + Format: "int32", + }, + "tcpSocket": { + Description: "TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported TODO: implement a realistic TCP lifecycle hook", + Type: "object", + Required: []string{"port"}, + Properties: map[string]apiextv1.JSONSchemaProps{ + "host": { + Description: "Optional: Host name to connect to, defaults to the pod IP.", + Type: "string", + }, + "port": { + Description: "Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + XIntOrString: true, + AnyOf: []apiextv1.JSONSchemaProps{ + { + Type: "integer", + }, + { + Type: "string", + }, + }, + }, + }, + }, + "terminationGracePeriodSeconds": { + Description: "Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.", + Type: "integer", + Format: "int64", + }, + "timeoutSeconds": { + Description: "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: "integer", + Format: "int32", + }, + }, + }, "nodeAffinity": { Type: "object", Properties: map[string]apiextv1.JSONSchemaProps{ @@ -1360,6 +1486,132 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{ }, }, }, + "liveness_probe": { + Description: "Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: "object", + Properties: map[string]apiextv1.JSONSchemaProps{ + "exec": { + Description: "One and only one of the following should be specified. Exec specifies the action to take.", + Type: "object", + Properties: map[string]apiextv1.JSONSchemaProps{ + "command": { + Description: "Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.", + Type: "array", + Items: &apiextv1.JSONSchemaPropsOrArray{ + Schema: &apiextv1.JSONSchemaProps{ + Type: "string", + }, + }, + }, + }, + }, + "failureThreshold": { + Description: "Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1.", + Type: "integer", + Format: "int32", + }, + "httpGet": { + Description: "HTTPGet specifies the http request to perform.", + Type: "object", + Required: []string{"port"}, + Properties: map[string]apiextv1.JSONSchemaProps{ + "host": { + Description: "Host name to connect to, defaults to the pod IP. You probably want to set \"Host\" in httpHeaders instead.", + Type: "string", + }, + "httpHeaders": { + Description: "Custom headers to set in the request. HTTP allows repeated headers.", + Type: "array", + Items: &apiextv1.JSONSchemaPropsOrArray{ + Schema: &apiextv1.JSONSchemaProps{ + Description: "HTTPHeader describes a custom header to be used in HTTP probes", + Type: "object", + Required: []string{"name", "value"}, + Properties: map[string]apiextv1.JSONSchemaProps{ + "name": { + Description: "The header field name", + Type: "string", + }, + "value": { + Description: "The header field value", + Type: "string", + }, + }, + }, + }, + }, + "path": { + Description: "Path to access on the HTTP server.", + Type: "string", + }, + "port": { + Description: "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + AnyOf: []apiextv1.JSONSchemaProps{ + { + Type: "integer", + }, + { + Type: "string", + }, + }, + XIntOrString: true, + }, + "scheme": { + Description: "Scheme to use for connecting to the host. Defaults to HTTP.", + Type: "string", + }, + }, + }, + "initialDelaySeconds": { + Description: "Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: "integer", + Format: "int32", + }, + "periodSeconds": { + Description: "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.", + Type: "integer", + Format: "int32", + }, + "successThreshold": { + Description: "Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.", + Type: "integer", + Format: "int32", + }, + "tcpSocket": { + Description: "TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported TODO: implement a realistic TCP lifecycle hook", + Type: "object", + Required: []string{"port"}, + Properties: map[string]apiextv1.JSONSchemaProps{ + "host": { + Description: "Optional: Host name to connect to, defaults to the pod IP.", + Type: "string", + }, + "port": { + Description: "Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + XIntOrString: true, + AnyOf: []apiextv1.JSONSchemaProps{ + { + Type: "integer", + }, + { + Type: "string", + }, + }, + }, + }, + }, + "terminationGracePeriodSeconds": { + Description: "Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.", + Type: "integer", + Format: "int64", + }, + "timeoutSeconds": { + Description: "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: "integer", + Format: "int32", + }, + }, + }, "master_pod_move_timeout": { Type: "string", }, diff --git a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go index a43c995c5..80b136fd6 100644 --- a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go +++ b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go @@ -260,6 +260,11 @@ func (in *KubernetesMetaConfiguration) DeepCopyInto(out *KubernetesMetaConfigura } } out.PodEnvironmentConfigMap = in.PodEnvironmentConfigMap + if in.LivenessProbe != nil { + in, out := &in.LivenessProbe, &out.LivenessProbe + *out = new(corev1.Probe) + (*in).DeepCopyInto(*out) + } return } @@ -832,6 +837,11 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.LivenessProbe != nil { + in, out := &in.LivenessProbe, &out.LivenessProbe + *out = new(corev1.Probe) + (*in).DeepCopyInto(*out) + } if in.InitContainersOld != nil { in, out := &in.InitContainersOld, &out.InitContainersOld *out = make([]corev1.Container, len(*in)) diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 29b0b158d..352011bfd 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -61,6 +61,7 @@ type Resources struct { NodeReadinessLabel map[string]string `name:"node_readiness_label" default:""` NodeReadinessLabelMerge string `name:"node_readiness_label_merge" default:"OR"` ShmVolume *bool `name:"enable_shm_volume" default:"true"` + LivenessProbe *v1.Probe `name:"liveness_probe"` MaxInstances int32 `name:"max_instances" default:"-1"` MinInstances int32 `name:"min_instances" default:"-1"`