From c23a13e3d7ede669de342f1ab43b656d4aa5abb2 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Wed, 12 Jan 2022 23:59:02 +0530 Subject: [PATCH 1/3] Add container lifecycle hooks in CDAPServiceSpec --- api/v1alpha1/cdapmaster_types.go | 2 + api/v1alpha1/zz_generated.deepcopy.go | 5 + .../crd/bases/cdap.cdap.io_cdapmasters.yaml | 2079 +++++++++++++++++ controllers/deployment.go | 4 +- controllers/spec.go | 6 + templates/cdap-deployment.yaml | 27 + templates/cdap-sts.yaml | 27 + 7 files changed, 2148 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/cdapmaster_types.go b/api/v1alpha1/cdapmaster_types.go index 0b1a47e1..c1928c1b 100644 --- a/api/v1alpha1/cdapmaster_types.go +++ b/api/v1alpha1/cdapmaster_types.go @@ -136,6 +136,8 @@ type CDAPServiceSpec struct { AdditionalVolumeMounts []corev1.VolumeMount `json:"additionalVolumeMounts,omitempty"` // SecurityContext overrides the security context for the service pods. SecurityContext *SecurityContext `json:"securityContext,omitempty"` + // Lifecycle is to specify Container Lifecycle hooks provided by Kubernetes for containers + Lifecycle *corev1.Lifecycle `json:"lifecycle,omitempty"` } // CDAPScalableServiceSpec defines the base specification for master services that can have more than one instance. diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index bac8b96b..f82c9c10 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -338,6 +338,11 @@ func (in *CDAPServiceSpec) DeepCopyInto(out *CDAPServiceSpec) { *out = new(SecurityContext) (*in).DeepCopyInto(*out) } + if in.Lifecycle != nil { + in, out := &in.Lifecycle, &out.Lifecycle + *out = new(v1.Lifecycle) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CDAPServiceSpec. diff --git a/config/crd/bases/cdap.cdap.io_cdapmasters.yaml b/config/crd/bases/cdap.cdap.io_cdapmasters.yaml index 48a4bf3c..da06da5b 100644 --- a/config/crd/bases/cdap.cdap.io_cdapmasters.yaml +++ b/config/crd/bases/cdap.cdap.io_cdapmasters.yaml @@ -2632,6 +2632,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -4109,6 +4298,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -5607,6 +5985,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -7080,6 +7647,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -8553,6 +9309,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -10022,6 +10967,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -11495,6 +12629,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -12968,6 +14291,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -14449,6 +15961,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -15982,6 +17683,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object @@ -17463,6 +19353,195 @@ spec: - name type: object type: array + lifecycle: + description: Lifecycle is to specify Container Lifecycle hooks provided + by Kubernetes for containers + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. The handler is not called if the container crashes or + exits. The reason for termination is passed to the handler. + The Pod''s termination grace period countdown begins before + the PreStop hooked is executed. Regardless of the outcome + of the handler, the container will eventually terminate within + the Pod''s termination grace period. Other management of the + container blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + 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. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + 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. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + 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. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object metadata: description: Metadata for the service. type: object diff --git a/controllers/deployment.go b/controllers/deployment.go index 522cf3dd..47eadffc 100644 --- a/controllers/deployment.go +++ b/controllers/deployment.go @@ -184,7 +184,7 @@ func buildStatefulSets(master *v1alpha1.CDAPMaster, name string, services Servic continue } env := addJavaMaxHeapEnvIfNotPresent(ss.Env, ss.Resources) - c := newContainerSpec(master, s, dataDir).setResources(ss.Resources).setEnv(env) + c := newContainerSpec(master, s, dataDir).setResources(ss.Resources).setEnv(env).setLifecycle(ss.Lifecycle) if s == serviceUserInterface { c = updateSpecForUserInterface(master, c) } @@ -274,7 +274,7 @@ func buildDeployment(master *v1alpha1.CDAPMaster, name string, services ServiceG continue } env := addJavaMaxHeapEnvIfNotPresent(ss.Env, ss.Resources) - c := newContainerSpec(master, s, dataDir).setResources(ss.Resources).setEnv(env) + c := newContainerSpec(master, s, dataDir).setResources(ss.Resources).setEnv(env).setLifecycle(ss.Lifecycle) if s == serviceUserInterface { c = updateSpecForUserInterface(master, c) } diff --git a/controllers/spec.go b/controllers/spec.go index 2573bb6b..ac5c99f4 100644 --- a/controllers/spec.go +++ b/controllers/spec.go @@ -45,6 +45,7 @@ type ContainerSpec struct { ResourceRequests map[string]*resource.Quantity `json:"resourceRequests,omitempty"` ResourceLimits map[string]*resource.Quantity `json:"resourceLimits,omitempty"` DataDir string `json:"dataDir,omitempty"` + Lifecycle *corev1.Lifecycle `json:"lifecycle,omitempty"` } func newContainerSpec(master *v1alpha1.CDAPMaster, name, dataDir string) *ContainerSpec { @@ -120,6 +121,11 @@ func (s *ContainerSpec) setResources(resources *corev1.ResourceRequirements) *Co return s } +func (s *ContainerSpec) setLifecycle(lifecycle *corev1.Lifecycle) *ContainerSpec { + s.Lifecycle = lifecycle + return s +} + // BaseSpec contains command fields for both StatefulSet and Deployment type BaseSpec struct { Name string `json:"name,omitempty"` diff --git a/templates/cdap-deployment.yaml b/templates/cdap-deployment.yaml index 0df3fe3c..6626def2 100644 --- a/templates/cdap-deployment.yaml +++ b/templates/cdap-deployment.yaml @@ -88,6 +88,33 @@ spec: {{if $c.ImagePullPolicy}} imagePullPolicy: {{$c.ImagePullPolicy}} {{end}} + {{if $c.Lifecycle}} + lifecycle: + {{if $c.Lifecycle.PostStart}} + postStart: + {{if $c.Lifecycle.PostStart.Exec}} + exec: + {{if $c.Lifecycle.PostStart.Exec.Command}} + command: + {{range $v := $c.Lifecycle.PostStart.Exec.Command}} + - {{$v}} + {{end}} + {{end}} + {{end}} + {{end}} + {{if $c.Lifecycle.PreStop}} + preStop: + {{if $c.Lifecycle.PreStop.Exec}} + exec: + {{if $c.Lifecycle.PreStop.Exec.Command}} + command: + {{range $v := $c.Lifecycle.PreStop.Exec.Command}} + - {{$v}} + {{end}} + {{end}} + {{end}} + {{end}} + {{end}} env: {{range $e := $c.Env }} - name: "{{$e.Name}}" diff --git a/templates/cdap-sts.yaml b/templates/cdap-sts.yaml index 71cefebc..2411e39a 100644 --- a/templates/cdap-sts.yaml +++ b/templates/cdap-sts.yaml @@ -126,6 +126,33 @@ spec: {{if $c.ImagePullPolicy}} imagePullPolicy: {{$c.ImagePullPolicy}} {{end}} + {{if $c.Lifecycle}} + lifecycle: + {{if $c.Lifecycle.PostStart}} + postStart: + {{if $c.Lifecycle.PostStart.Exec}} + exec: + {{if $c.Lifecycle.PostStart.Exec.Command}} + command: + {{range $v := $c.Lifecycle.PostStart.Exec.Command}} + - {{$v}} + {{end}} + {{end}} + {{end}} + {{end}} + {{if $c.Lifecycle.PreStop}} + preStop: + {{if $c.Lifecycle.PreStop.Exec}} + exec: + {{if $c.Lifecycle.PreStop.Exec.Command}} + command: + {{range $v := $c.Lifecycle.PreStop.Exec.Command}} + - {{$v}} + {{end}} + {{end}} + {{end}} + {{end}} + {{end}} env: {{range $e := $c.Env }} - name: "{{$e.Name}}" From ac00a79558d326fd188ccc7904bb0cf4a75bbd46 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Thu, 13 Jan 2022 15:08:52 +0530 Subject: [PATCH 2/3] Add testcases for the container lifecycle hook --- controllers/testdata/appfabric.json | 7 +++++++ controllers/testdata/cdap_master_cr.json | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/controllers/testdata/appfabric.json b/controllers/testdata/appfabric.json index 1f88e727..23c8dcf2 100644 --- a/controllers/testdata/appfabric.json +++ b/controllers/testdata/appfabric.json @@ -92,6 +92,13 @@ "privileged": false, "readOnlyRootFilesystem": false }, + "lifecycle": { + "preStop": { + "exec": { + "command": ["sh", "-c", "echo hello"] + } + } + }, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "volumeMounts": [ diff --git a/controllers/testdata/cdap_master_cr.json b/controllers/testdata/cdap_master_cr.json index aabd4e1f..37a449e4 100644 --- a/controllers/testdata/cdap_master_cr.json +++ b/controllers/testdata/cdap_master_cr.json @@ -56,7 +56,14 @@ "name": "test-persistent-storage", "mountPath": "/mnt/teststorage" } - ] + ], + "lifecycle": { + "preStop": { + "exec": { + "command": ["sh", "-c", "echo hello"] + } + } + } }, "authentication": { "metadata": { From 5423919c9c628c1a9ad0af074e95360e27c16ab1 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Fri, 14 Jan 2022 04:18:41 +0530 Subject: [PATCH 3/3] Put lifecycle hook in k8s object bypassing the template, otherwise a lot of nested fields would be needed in the template --- api/v1alpha1/cdapmaster_types.go | 3 +- .../crd/bases/cdap.cdap.io_cdapmasters.yaml | 33 ++++++++++++------- controllers/deployment.go | 10 ++++-- templates/cdap-deployment.yaml | 33 ++++--------------- templates/cdap-sts.yaml | 33 ++++--------------- 5 files changed, 44 insertions(+), 68 deletions(-) diff --git a/api/v1alpha1/cdapmaster_types.go b/api/v1alpha1/cdapmaster_types.go index c1928c1b..2f009f67 100644 --- a/api/v1alpha1/cdapmaster_types.go +++ b/api/v1alpha1/cdapmaster_types.go @@ -136,7 +136,8 @@ type CDAPServiceSpec struct { AdditionalVolumeMounts []corev1.VolumeMount `json:"additionalVolumeMounts,omitempty"` // SecurityContext overrides the security context for the service pods. SecurityContext *SecurityContext `json:"securityContext,omitempty"` - // Lifecycle is to specify Container Lifecycle hooks provided by Kubernetes for containers + // Lifecycle is to specify Container Lifecycle hooks provided by Kubernetes for containers. + // This will not be applied to the init containers as init containers do not support lifecycle. Lifecycle *corev1.Lifecycle `json:"lifecycle,omitempty"` } diff --git a/config/crd/bases/cdap.cdap.io_cdapmasters.yaml b/config/crd/bases/cdap.cdap.io_cdapmasters.yaml index da06da5b..ce2bb62a 100644 --- a/config/crd/bases/cdap.cdap.io_cdapmasters.yaml +++ b/config/crd/bases/cdap.cdap.io_cdapmasters.yaml @@ -2634,7 +2634,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -4300,7 +4301,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -5987,7 +5989,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -7649,7 +7652,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -9311,7 +9315,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -10969,7 +10974,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -12631,7 +12637,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -14293,7 +14300,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -15963,7 +15971,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -17685,7 +17694,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container @@ -19355,7 +19365,8 @@ spec: type: array lifecycle: description: Lifecycle is to specify Container Lifecycle hooks provided - by Kubernetes for containers + by Kubernetes for containers. This will not be applied to the + init containers as init containers do not support lifecycle. properties: postStart: description: 'PostStart is called immediately after a container diff --git a/controllers/deployment.go b/controllers/deployment.go index 47eadffc..98f75544 100644 --- a/controllers/deployment.go +++ b/controllers/deployment.go @@ -339,7 +339,7 @@ func buildStatefulSetsObject(spec *StatefulSpec) (*reconciler.Object, error) { if err != nil { return nil, err } - // For custom volumes and custom volume mounts, we directly pass structs from the spec to bypass the YAML templating logic. + // For container lifecycle hook, custom volumes, and custom volume mounts, we directly pass structs from the spec to bypass the YAML templating logic. k8sObj, ok := obj.Obj.(*k8s.Object) if !ok { return nil, fmt.Errorf("failed to convert object to k8s object") @@ -360,6 +360,7 @@ func buildStatefulSetsObject(spec *StatefulSpec) (*reconciler.Object, error) { if err := addVolumeMountToContainer(&statefulSetObj.Spec.Template.Spec.Containers[index], spec.Base.AdditionalVolumeMounts); err != nil { return nil, err } + setLifecycleHookForContainer(&statefulSetObj.Spec.Template.Spec.Containers[index], spec.Containers[index].Lifecycle) } return obj, nil } @@ -370,7 +371,7 @@ func buildDeploymentObject(spec *DeploymentSpec) (*reconciler.Object, error) { if err != nil { return nil, err } - // For custom volumes and volume mounts, we directly pass structs from the spec to bypass the YAML templating logic. + // For container lifecycle hook, custom volumes, and volume mounts, we directly pass structs from the spec to bypass the YAML templating logic. k8sObj, ok := obj.Obj.(*k8s.Object) if !ok { return nil, fmt.Errorf("failed to convert object to k8s object") @@ -391,6 +392,7 @@ func buildDeploymentObject(spec *DeploymentSpec) (*reconciler.Object, error) { if err := addVolumeMountToContainer(&deploymentObj.Spec.Template.Spec.Containers[index], spec.Base.AdditionalVolumeMounts); err != nil { return nil, err } + setLifecycleHookForContainer(&deploymentObj.Spec.Template.Spec.Containers[index], spec.Containers[index].Lifecycle) } return obj, nil } @@ -419,6 +421,10 @@ func addVolumeMountToContainer(container *corev1.Container, volumeMountsToAdd [] return nil } +func setLifecycleHookForContainer(container *corev1.Container, lifecycle *corev1.Lifecycle) { + container.Lifecycle = lifecycle +} + // Return a NodePort service to expose the supplied target service func buildNetworkService(master *v1alpha1.CDAPMaster, name NetworkServiceName, target ServiceName, labels map[string]string) (*NetworkServiceSpec, error) { s, err := getCDAPExternalServiceSpec(master, target) diff --git a/templates/cdap-deployment.yaml b/templates/cdap-deployment.yaml index 6626def2..a4ed238a 100644 --- a/templates/cdap-deployment.yaml +++ b/templates/cdap-deployment.yaml @@ -11,6 +11,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. +# +# +# NOTE: Some properties are highly nested and it is not feasible to pick them from the template file +# hence those are added directly in the code. +# For example, please check the method "../controllers/deployment.go#buildDeploymentObject" and see +# how container's lifecycle property is added to the k8s object. apiVersion: apps/v1 kind: Deployment metadata: @@ -88,33 +94,6 @@ spec: {{if $c.ImagePullPolicy}} imagePullPolicy: {{$c.ImagePullPolicy}} {{end}} - {{if $c.Lifecycle}} - lifecycle: - {{if $c.Lifecycle.PostStart}} - postStart: - {{if $c.Lifecycle.PostStart.Exec}} - exec: - {{if $c.Lifecycle.PostStart.Exec.Command}} - command: - {{range $v := $c.Lifecycle.PostStart.Exec.Command}} - - {{$v}} - {{end}} - {{end}} - {{end}} - {{end}} - {{if $c.Lifecycle.PreStop}} - preStop: - {{if $c.Lifecycle.PreStop.Exec}} - exec: - {{if $c.Lifecycle.PreStop.Exec.Command}} - command: - {{range $v := $c.Lifecycle.PreStop.Exec.Command}} - - {{$v}} - {{end}} - {{end}} - {{end}} - {{end}} - {{end}} env: {{range $e := $c.Env }} - name: "{{$e.Name}}" diff --git a/templates/cdap-sts.yaml b/templates/cdap-sts.yaml index 2411e39a..9e62abc1 100644 --- a/templates/cdap-sts.yaml +++ b/templates/cdap-sts.yaml @@ -11,6 +11,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. +# +# +# NOTE: Some properties are highly nested and it is not feasible to pick them from the template file +# hence those are added directly in the code. +# For example, please check the method "../controllers/deployment.go#buildStatefulSetsObject" and see +# how container's lifecycle property is added to the k8s object. apiVersion: apps/v1 kind: StatefulSet metadata: @@ -126,33 +132,6 @@ spec: {{if $c.ImagePullPolicy}} imagePullPolicy: {{$c.ImagePullPolicy}} {{end}} - {{if $c.Lifecycle}} - lifecycle: - {{if $c.Lifecycle.PostStart}} - postStart: - {{if $c.Lifecycle.PostStart.Exec}} - exec: - {{if $c.Lifecycle.PostStart.Exec.Command}} - command: - {{range $v := $c.Lifecycle.PostStart.Exec.Command}} - - {{$v}} - {{end}} - {{end}} - {{end}} - {{end}} - {{if $c.Lifecycle.PreStop}} - preStop: - {{if $c.Lifecycle.PreStop.Exec}} - exec: - {{if $c.Lifecycle.PreStop.Exec.Command}} - command: - {{range $v := $c.Lifecycle.PreStop.Exec.Command}} - - {{$v}} - {{end}} - {{end}} - {{end}} - {{end}} - {{end}} env: {{range $e := $c.Env }} - name: "{{$e.Name}}"