From 02ce86023b3db175481b859f379cb4298d03566a Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Thu, 1 Jun 2023 10:05:16 +0200 Subject: [PATCH] feat(operator): introduce container-runtime runner (#1493) Signed-off-by: odubajDT Signed-off-by: odubajDT <93584209+odubajDT@users.noreply.github.com> Co-authored-by: Giovanni Liva --- examples/sample-app/base/container-task.yaml | 12 + examples/sample-app/version-1/app.yaml | 2 + examples/sample-app/version-2/app.yaml | 2 + examples/sample-app/version-3/app.yaml | 2 + .../v1alpha3/keptntaskdefinition_types.go | 26 +- .../keptntaskdefinition_types_test.go | 167 +++ .../v1alpha3/zz_generated.deepcopy.go | 17 +- ...fecycle.keptn.sh_keptntaskdefinitions.yaml | 1231 +++++++++++++++++ ...ifecycle_v1alpha3_keptntaskdefinition.yaml | 6 - ...1alpha3_keptntaskdefinition_container.yaml | 19 + ...cycle_v1alpha3_keptntaskdefinition_js.yaml | 10 + .../lifecycle/keptntask/container_builder.go | 65 +- .../keptntask/container_builder_test.go | 244 ++++ .../lifecycle/keptntask/job_runner_builder.go | 37 + .../keptntask/job_runner_builder_test.go | 62 + .../lifecycle/keptntask/job_utils.go | 7 +- .../lifecycle/keptntask/job_utils_test.go | 2 +- .../lifecycle/keptntask/js_builder.go | 4 +- .../lifecycle/keptntask/js_builder_test.go | 8 +- .../keptntaskdefinition/reconcile_function.go | 3 + operator/test/component/task/task_test.go | 2 +- .../taskdefinition/taskdefinition_test.go | 6 +- .../container-runtime/00-assert.yaml | 64 + .../container-runtime/00-install.yaml | 40 + .../container-runtime/00-teststep.yaml | 4 + 25 files changed, 1990 insertions(+), 52 deletions(-) create mode 100644 examples/sample-app/base/container-task.yaml create mode 100644 operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types_test.go delete mode 100644 operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition.yaml create mode 100644 operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_container.yaml create mode 100644 operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_js.yaml create mode 100644 operator/controllers/lifecycle/keptntask/container_builder_test.go create mode 100644 operator/controllers/lifecycle/keptntask/job_runner_builder.go create mode 100644 operator/controllers/lifecycle/keptntask/job_runner_builder_test.go create mode 100644 test/integration/container-runtime/00-assert.yaml create mode 100644 test/integration/container-runtime/00-install.yaml create mode 100644 test/integration/container-runtime/00-teststep.yaml diff --git a/examples/sample-app/base/container-task.yaml b/examples/sample-app/base/container-task.yaml new file mode 100644 index 0000000000..b6001490da --- /dev/null +++ b/examples/sample-app/base/container-task.yaml @@ -0,0 +1,12 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnTaskDefinition +metadata: + name: container-sleep +spec: + container: + name: testy-test + image: busybox:1.36.0 + command: + - 'sh' + - '-c' + - 'sleep 30' diff --git a/examples/sample-app/version-1/app.yaml b/examples/sample-app/version-1/app.yaml index 7358f7fbe4..ded6ef9192 100644 --- a/examples/sample-app/version-1/app.yaml +++ b/examples/sample-app/version-1/app.yaml @@ -16,3 +16,5 @@ spec: version: 0.1.1 preDeploymentEvaluations: - app-pre-deploy-eval-1 + preDeploymentTasks: + - container-sleep diff --git a/examples/sample-app/version-2/app.yaml b/examples/sample-app/version-2/app.yaml index d43ed4a004..1801433737 100644 --- a/examples/sample-app/version-2/app.yaml +++ b/examples/sample-app/version-2/app.yaml @@ -16,3 +16,5 @@ spec: version: 0.1.1 preDeploymentEvaluations: - app-pre-deploy-eval-2 + preDeploymentTasks: + - container-sleep diff --git a/examples/sample-app/version-3/app.yaml b/examples/sample-app/version-3/app.yaml index 3c33d0f0ca..3bb50a1dc5 100644 --- a/examples/sample-app/version-3/app.yaml +++ b/examples/sample-app/version-3/app.yaml @@ -14,3 +14,5 @@ spec: version: 0.1.1 - name: podtato-head-hat version: 0.1.2 + preDeploymentTasks: + - container-sleep diff --git a/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go b/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go index 95df2aef36..93b45fe139 100644 --- a/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go +++ b/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha3 import ( + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -27,7 +28,12 @@ import ( type KeptnTaskDefinitionSpec struct { // Function contains the definition for the function that is to be executed in KeptnTasks based on // the KeptnTaskDefinitions. - Function FunctionSpec `json:"function,omitempty"` + // +optional + Function *FunctionSpec `json:"function,omitempty"` + // Container contains the definition for the container that is to be used in Job based on + // the KeptnTaskDefinitions. + // +optional + Container *ContainerSpec `json:"container,omitempty"` // Retries specifies how many times a job executing the KeptnTaskDefinition should be restarted in the case // of an unsuccessful attempt. // +kubebuilder:default:=10 @@ -39,7 +45,6 @@ type KeptnTaskDefinitionSpec struct { // +kubebuilder:default:="5m" // +kubebuilder:validation:Pattern="^0|([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$" // +kubebuilder:validation:Type:=string - // +optional Timeout metav1.Duration `json:"timeout,omitempty"` } @@ -85,6 +90,7 @@ type HttpReference struct { } type ContainerSpec struct { + *v1.Container `json:",inline"` } // KeptnTaskDefinitionStatus defines the observed state of KeptnTaskDefinition @@ -125,3 +131,19 @@ type KeptnTaskDefinitionList struct { func init() { SchemeBuilder.Register(&KeptnTaskDefinition{}, &KeptnTaskDefinitionList{}) } + +func (d KeptnTaskDefinition) SpecExists() bool { + return d.IsJSSpecDefined() || d.IsContainerSpecDefined() +} + +func (d KeptnTaskDefinition) IsJSSpecDefined() bool { + return d.Spec.Function != nil +} + +func (d KeptnTaskDefinition) IsContainerSpecDefined() bool { + return d.Spec.Container != nil +} + +func (d KeptnTaskDefinition) IsVolumeMountPresent() bool { + return d.IsContainerSpecDefined() && d.Spec.Container.VolumeMounts != nil && len(d.Spec.Container.VolumeMounts) > 0 +} diff --git a/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types_test.go b/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types_test.go new file mode 100644 index 0000000000..3f141d7c2f --- /dev/null +++ b/operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types_test.go @@ -0,0 +1,167 @@ +package v1alpha3 + +import ( + "testing" + + "github.com/stretchr/testify/require" + v1 "k8s.io/api/core/v1" +) + +var jsTaskDef = &KeptnTaskDefinition{ + Spec: KeptnTaskDefinitionSpec{ + Function: &FunctionSpec{ + Inline: Inline{ + Code: "some code", + }, + }, + }, +} + +var containerTaskDef = &KeptnTaskDefinition{ + Spec: KeptnTaskDefinitionSpec{ + Container: &ContainerSpec{ + Container: &v1.Container{ + Image: "image", + }, + }, + }, +} + +func Test_SpecExists(t *testing.T) { + tests := []struct { + name string + taskDef *KeptnTaskDefinition + want bool + }{ + { + name: "js builder", + taskDef: jsTaskDef, + want: true, + }, + { + name: "container builder", + taskDef: containerTaskDef, + want: true, + }, + { + name: "empty builder", + taskDef: &KeptnTaskDefinition{ + Spec: KeptnTaskDefinitionSpec{}, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, tt.taskDef.SpecExists()) + }) + } +} + +func Test_IsJSSpecDefined(t *testing.T) { + tests := []struct { + name string + taskDef *KeptnTaskDefinition + want bool + }{ + { + name: "defined", + taskDef: jsTaskDef, + want: true, + }, + { + name: "empty", + taskDef: &KeptnTaskDefinition{}, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, tt.taskDef.IsJSSpecDefined()) + }) + } +} + +func Test_IsVolumeMountPresent(t *testing.T) { + tests := []struct { + name string + taskDef *KeptnTaskDefinition + want bool + }{ + { + name: "defined", + taskDef: &KeptnTaskDefinition{ + Spec: KeptnTaskDefinitionSpec{ + Container: &ContainerSpec{ + Container: &v1.Container{ + Image: "image", + VolumeMounts: []v1.VolumeMount{ + { + Name: "name", + MountPath: "path", + }, + }, + }, + }, + }, + }, + want: true, + }, + { + name: "empty", + taskDef: &KeptnTaskDefinition{ + Spec: KeptnTaskDefinitionSpec{ + Container: &ContainerSpec{ + Container: &v1.Container{ + Image: "image", + VolumeMounts: []v1.VolumeMount{}, + }, + }, + }, + }, + want: false, + }, + { + name: "nil", + taskDef: &KeptnTaskDefinition{ + Spec: KeptnTaskDefinitionSpec{ + Container: &ContainerSpec{ + Container: &v1.Container{ + Image: "image", + }, + }, + }, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, tt.taskDef.IsVolumeMountPresent()) + }) + } +} + +func Test_IsContainerSpecDefined(t *testing.T) { + tests := []struct { + name string + taskDef *KeptnTaskDefinition + want bool + }{ + { + name: "defined", + taskDef: containerTaskDef, + want: true, + }, + { + name: "empty", + taskDef: &KeptnTaskDefinition{}, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, tt.taskDef.IsContainerSpecDefined()) + }) + } +} diff --git a/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go b/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go index 7ee7cd41e2..cc68f44e91 100644 --- a/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go +++ b/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go @@ -24,6 +24,7 @@ package v1alpha3 import ( "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" "go.opentelemetry.io/otel/propagation" + "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -45,6 +46,11 @@ func (in *ConfigMapReference) DeepCopy() *ConfigMapReference { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerSpec) DeepCopyInto(out *ContainerSpec) { *out = *in + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(v1.Container) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSpec. @@ -909,7 +915,16 @@ func (in *KeptnTaskDefinitionList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeptnTaskDefinitionSpec) DeepCopyInto(out *KeptnTaskDefinitionSpec) { *out = *in - in.Function.DeepCopyInto(&out.Function) + if in.Function != nil { + in, out := &in.Function, &out.Function + *out = new(FunctionSpec) + (*in).DeepCopyInto(*out) + } + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(ContainerSpec) + (*in).DeepCopyInto(*out) + } if in.Retries != nil { in, out := &in.Retries, &out.Retries *out = new(int32) diff --git a/operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml b/operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml index f6be0e8b34..d88447aeef 100644 --- a/operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml +++ b/operator/config/crd/bases/lifecycle.keptn.sh_keptntaskdefinitions.yaml @@ -189,6 +189,1237 @@ spec: spec: description: Spec describes the desired state of the KeptnTaskDefinition. properties: + container: + description: Container contains the definition for the container that + is to be used in Job based on the KeptnTaskDefinitions. + properties: + args: + description: 'Arguments to the entrypoint. The container image''s + CMD is used if this is not provided. Variable references $(VAR_NAME) + are expanded using the container''s environment. If a variable + cannot be resolved, the reference in the input string will be + unchanged. Double $$ are reduced to a single $, which allows + for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references + will never be expanded, regardless of whether the variable exists + or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' + items: + type: string + type: array + command: + description: 'Entrypoint array. Not executed within a shell. The + container image''s ENTRYPOINT is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container''s + environment. If a variable cannot be resolved, the reference + in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: + i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless of whether + the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' + items: + type: string + type: array + env: + description: List of environment variables to set in the container. + Cannot be updated. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. If + a variable cannot be resolved, the reference in the input + string will be unchanged. Double $$ are reduced to a single + $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless + of whether the variable exists or not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.ephemeral-storage) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: List of sources to populate environment variables + in the container. The keys defined within a source must be a + C_IDENTIFIER. All invalid keys will be reported as an event + when the container is starting. When a key exists in multiple + sources, the value associated with the last source will take + precedence. Values defined by an Env with a duplicate key will + take precedence. Cannot be updated. + items: + description: EnvFromSource represents the source of a set of + ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to each key + in the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + description: 'Container image name. More info: https://kubernetes.io/docs/concepts/containers/images + This field is optional to allow higher level config management + to default or override container images in workload controllers + like Deployments and StatefulSets.' + type: string + imagePullPolicy: + description: 'Image pull policy. One of Always, Never, IfNotPresent. + Defaults to Always if :latest tag is specified, or IfNotPresent + otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images' + type: string + lifecycle: + description: Actions that the management system should take in + response to container lifecycle events. Cannot be updated. + 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: 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. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + 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: Deprecated. TCPSocket is NOT supported as + a LifecycleHandler and kept for the backward compatibility. + There are no validation of this field and lifecycle + hooks will fail in runtime when tcp handler is specified. + 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 Pod''s termination grace period countdown + begins before the PreStop hook is executed. Regardless of + the outcome of the handler, the container will eventually + terminate within the Pod''s termination grace period (unless + delayed by finalizers). 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: 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. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + 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: Deprecated. TCPSocket is NOT supported as + a LifecycleHandler and kept for the backward compatibility. + There are no validation of this field and lifecycle + hooks will fail in runtime when tcp handler is specified. + 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 + 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' + properties: + exec: + description: 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 + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + 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. This will be + canonicalized upon output, so case-variant names + will be understood as the same header. + 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 + 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' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + 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. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + 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 + 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. + format: int64 + type: integer + 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' + format: int32 + type: integer + type: object + name: + description: Name of the container specified as a DNS_LABEL. Each + container in a pod must have a unique name (DNS_LABEL). Cannot + be updated. + type: string + ports: + description: List of ports to expose from the container. Not specifying + a port here DOES NOT prevent that port from being exposed. Any + port which is listening on the default "0.0.0.0" address inside + a container will be accessible from the network. Modifying this + array with strategic merge patch may corrupt the data. For more + information See https://github.com/kubernetes/kubernetes/issues/108255. + Cannot be updated. + items: + description: ContainerPort represents a network port in a single + container. + properties: + containerPort: + description: Number of port to expose on the pod's IP address. + This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port to. + type: string + hostPort: + description: Number of port to expose on the host. If specified, + this must be a valid port number, 0 < x < 65536. If HostNetwork + is specified, this must match ContainerPort. Most containers + do not need this. + format: int32 + type: integer + name: + description: If specified, this must be an IANA_SVC_NAME + and unique within the pod. Each named port in a pod must + have a unique name. Name for the port that can be referred + to by services. + type: string + protocol: + default: TCP + description: Protocol for port. Must be UDP, TCP, or SCTP. + Defaults to "TCP". + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + description: 'Periodic probe of container service readiness. Container + will be removed from service endpoints if the probe fails. Cannot + be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: 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 + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + 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. This will be + canonicalized upon output, so case-variant names + will be understood as the same header. + 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 + 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' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + 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. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + 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 + 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. + format: int64 + type: integer + 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' + format: int32 + type: integer + type: object + resources: + description: 'Compute Resources required by this container. Cannot + be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate. \n This field is immutable. It can only be + set for containers." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute + resources required. If Requests is omitted for a container, + it defaults to Limits if that is explicitly specified, otherwise + to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + securityContext: + description: 'SecurityContext defines the security options the + container should be run with. If set, the fields of SecurityContext + override the equivalent fields of PodSecurityContext. More info: + https://kubernetes.io/docs/tasks/configure-pod-container/security-context/' + properties: + allowPrivilegeEscalation: + description: 'AllowPrivilegeEscalation controls whether a + process can gain more privileges than its parent process. + This bool directly controls if the no_new_privs flag will + be set on the container process. AllowPrivilegeEscalation + is true always when the container is: 1) run as Privileged + 2) has CAP_SYS_ADMIN Note that this field cannot be set + when spec.os.name is windows.' + type: boolean + capabilities: + description: The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by the + container runtime. Note that this field cannot be set when + spec.os.name is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + type: object + privileged: + description: Run container in privileged mode. Processes in + privileged containers are essentially equivalent to root + on the host. Defaults to false. Note that this field cannot + be set when spec.os.name is windows. + type: boolean + procMount: + description: procMount denotes the type of proc mount to use + for the containers. The default is DefaultProcMount which + uses the container runtime defaults for readonly paths and + masked paths. This requires the ProcMountType feature flag + to be enabled. Note that this field cannot be set when spec.os.name + is windows. + type: string + readOnlyRootFilesystem: + description: Whether this container has a read-only root filesystem. + Default is false. Note that this field cannot be set when + spec.os.name is windows. + type: boolean + runAsGroup: + description: The GID to run the entrypoint of the container + process. Uses runtime default if unset. May also be set + in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext + takes precedence. Note that this field cannot be set when + spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: Indicates that the container must run as a non-root + user. If true, the Kubelet will validate the image at runtime + to ensure that it does not run as UID 0 (root) and fail + to start the container if it does. If unset or false, no + such validation will be performed. May also be set in PodSecurityContext. If + set in both SecurityContext and PodSecurityContext, the + value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: The UID to run the entrypoint of the container + process. Defaults to user specified in image metadata if + unspecified. May also be set in PodSecurityContext. If + set in both SecurityContext and PodSecurityContext, the + value specified in SecurityContext takes precedence. Note + that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxOptions: + description: The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a random + SELinux context for each container. May also be set in + PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext + takes precedence. Note that this field cannot be set when + spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: The seccomp options to use by this container. + If seccomp options are provided at both the pod & container + level, the container options override the pod options. Note + that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: localhostProfile indicates a profile defined + in a file on the node should be used. The profile must + be preconfigured on the node to work. Must be a descending + path, relative to the kubelet's configured seccomp profile + location. Must only be set if type is "Localhost". + type: string + type: + description: "type indicates which kind of seccomp profile + will be applied. Valid options are: \n Localhost - a + profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile + should be used. Unconfined - no profile should be applied." + type: string + required: + - type + type: object + windowsOptions: + description: The Windows specific settings applied to all + containers. If unspecified, the options from the PodSecurityContext + will be used. If set in both SecurityContext and PodSecurityContext, + the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is + linux. + properties: + gmsaCredentialSpec: + description: GMSACredentialSpec is where the GMSA admission + webhook (https://github.com/kubernetes-sigs/windows-gmsa) + inlines the contents of the GMSA credential spec named + by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: HostProcess determines if a container should + be run as a 'Host Process' container. This field is + alpha-level and will only be honored by components that + enable the WindowsHostProcessContainers feature flag. + Setting this field without the feature flag will result + in errors when validating the Pod. All of a Pod's containers + must have the same effective HostProcess value (it is + not allowed to have a mix of HostProcess containers + and non-HostProcess containers). In addition, if HostProcess + is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: The UserName in Windows to run the entrypoint + of the container process. Defaults to the user specified + in image metadata if unspecified. May also be set in + PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext + takes precedence. + type: string + type: object + type: object + startupProbe: + description: 'StartupProbe indicates that the Pod has successfully + initialized. If specified, no other probes are executed until + this completes successfully. If this probe fails, the Pod will + be restarted, just as if the livenessProbe failed. This can + be used to provide different probe parameters at the beginning + of a Pod''s lifecycle, when it might take a long time to load + data or warm a cache, than during steady-state operation. This + cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: 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 + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + 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. This will be + canonicalized upon output, so case-variant names + will be understood as the same header. + 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 + 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' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + 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. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + 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 + 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. + format: int64 + type: integer + 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' + format: int32 + type: integer + type: object + stdin: + description: Whether this container should allocate a buffer for + stdin in the container runtime. If this is not set, reads from + stdin in the container will always result in EOF. Default is + false. + type: boolean + stdinOnce: + description: Whether the container runtime should close the stdin + channel after it has been opened by a single attach. When stdin + is true the stdin stream will remain open across multiple attach + sessions. If stdinOnce is set to true, stdin is opened on container + start, is empty until the first client attaches to stdin, and + then remains open and accepts data until the client disconnects, + at which time stdin is closed and remains closed until the container + is restarted. If this flag is false, a container processes that + reads from stdin will never receive an EOF. Default is false + type: boolean + terminationMessagePath: + description: 'Optional: Path at which the file to which the container''s + termination message will be written is mounted into the container''s + filesystem. Message written is intended to be brief final status, + such as an assertion failure message. Will be truncated by the + node if greater than 4096 bytes. The total message length across + all containers will be limited to 12kb. Defaults to /dev/termination-log. + Cannot be updated.' + type: string + terminationMessagePolicy: + description: Indicate how the termination message should be populated. + File will use the contents of terminationMessagePath to populate + the container status message on both success and failure. FallbackToLogsOnError + will use the last chunk of container log output if the termination + message file is empty and the container exited with an error. + The log output is limited to 2048 bytes or 80 lines, whichever + is smaller. Defaults to File. Cannot be updated. + type: string + tty: + description: Whether this container should allocate a TTY for + itself, also requires 'stdin' to be true. Default is false. + type: boolean + volumeDevices: + description: volumeDevices is the list of block devices to be + used by the container. + items: + description: volumeDevice describes a mapping of a raw block + device within a container. + properties: + devicePath: + description: devicePath is the path inside of the container + that the device will be mapped to. + type: string + name: + description: name must match the name of a persistentVolumeClaim + in the pod + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + description: Pod volumes to mount into the container's filesystem. + Cannot be updated. + items: + description: VolumeMount describes a mounting of a Volume within + a container. + properties: + mountPath: + description: Path within the container at which the volume + should be mounted. Must not contain ':'. + type: string + mountPropagation: + description: mountPropagation determines how mounts are + propagated from the host to container and the other way + around. When not set, MountPropagationNone is used. This + field is beta in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: Mounted read-only if true, read-write otherwise + (false or unspecified). Defaults to false. + type: boolean + subPath: + description: Path within the volume from which the container's + volume should be mounted. Defaults to "" (volume's root). + type: string + subPathExpr: + description: Expanded path within the volume from which + the container's volume should be mounted. Behaves similarly + to SubPath but environment variable references $(VAR_NAME) + are expanded using the container's environment. Defaults + to "" (volume's root). SubPathExpr and SubPath are mutually + exclusive. + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + description: Container's working directory. If not specified, + the container runtime's default will be used, which might be + configured in the container image. Cannot be updated. + type: string + required: + - name + type: object function: description: Function contains the definition for the function that is to be executed in KeptnTasks based on the KeptnTaskDefinitions. diff --git a/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition.yaml b/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition.yaml deleted file mode 100644 index 5d10c28fae..0000000000 --- a/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: lifecycle.keptn.sh/v1alpha3 -kind: KeptnTaskDefinition -metadata: - name: keptntaskdefinition-sample -spec: -# TODO(user): Add fields here diff --git a/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_container.yaml b/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_container.yaml new file mode 100644 index 0000000000..a0cbfcffc0 --- /dev/null +++ b/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_container.yaml @@ -0,0 +1,19 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnTaskDefinition +metadata: + name: keptntaskdefinition-sample-container +spec: + container: + name: testy-test + image: busybox:1.36.0 + resources: + limits: + memory: "200Mi" + command: + - 'echo' + - 'Hello World!' + - '>' + - '/cache/log.txt' + volumeMounts: + - mountPath: /cache + name: logger diff --git a/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_js.yaml b/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_js.yaml new file mode 100644 index 0000000000..83a33dfc3c --- /dev/null +++ b/operator/config/samples/lifecycle_v1alpha3_keptntaskdefinition_js.yaml @@ -0,0 +1,10 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnTaskDefinition +metadata: + name: keptntaskdefinition-sample-js +spec: + function: + inline: + code: | + console.log('hello'); + retries: 2 diff --git a/operator/controllers/lifecycle/keptntask/container_builder.go b/operator/controllers/lifecycle/keptntask/container_builder.go index e550b9dfac..098db9bb61 100644 --- a/operator/controllers/lifecycle/keptntask/container_builder.go +++ b/operator/controllers/lifecycle/keptntask/container_builder.go @@ -1,46 +1,53 @@ package keptntask import ( - "reflect" - - "github.com/go-logr/logr" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" "golang.org/x/net/context" corev1 "k8s.io/api/core/v1" - "k8s.io/client-go/tools/record" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" + "k8s.io/apimachinery/pkg/api/resource" ) -// IContainerBuilder is the interface that describes the operations needed to help build job specs of a task -type IContainerBuilder interface { - // CreateContainerWithVolumes returns a job container and volumes based on the task definition spec - CreateContainerWithVolumes(ctx context.Context) (*corev1.Container, []corev1.Volume, error) +// ContainerBuilder implements container builder interface for python +type ContainerBuilder struct { + taskDef *klcv1alpha3.KeptnTaskDefinition } -// BuilderOptions contains everything needed to build the current job -type BuilderOptions struct { - client.Client - recorder record.EventRecorder - req ctrl.Request - Log logr.Logger - task *klcv1alpha3.KeptnTask - taskDef *klcv1alpha3.KeptnTaskDefinition +func NewContainerBuilder(taskDef *klcv1alpha3.KeptnTaskDefinition) *ContainerBuilder { + return &ContainerBuilder{ + taskDef: taskDef, + } } -func getContainerBuilder(options BuilderOptions) IContainerBuilder { - if isJSSpecDefined(&options.taskDef.Spec) { - builder := newJSBuilder(options) - return &builder - } - return nil +func (c *ContainerBuilder) CreateContainerWithVolumes(ctx context.Context) (*corev1.Container, []corev1.Volume, error) { + return c.taskDef.Spec.Container.Container, c.generateVolumes(), nil } -func specExists(definition *klcv1alpha3.KeptnTaskDefinition) bool { - //TODO when adding new builders add more logic here - return isJSSpecDefined(&definition.Spec) +func (c *ContainerBuilder) getVolumeSource() *corev1.EmptyDirVolumeSource { + quantity, ok := c.taskDef.Spec.Container.Resources.Limits["memory"] + if ok { + return &corev1.EmptyDirVolumeSource{ + SizeLimit: &quantity, + Medium: corev1.StorageMedium("Memory"), + } + } + + return &corev1.EmptyDirVolumeSource{ + // Default 50% of the memory of the node, max 1Gi + SizeLimit: resource.NewQuantity(1, resource.Format("Gi")), + Medium: corev1.StorageMedium("Memory"), + } } -func isJSSpecDefined(spec *klcv1alpha3.KeptnTaskDefinitionSpec) bool { - return !reflect.DeepEqual(spec.Function, klcv1alpha3.FunctionSpec{}) +func (c *ContainerBuilder) generateVolumes() []corev1.Volume { + if !c.taskDef.IsVolumeMountPresent() { + return []corev1.Volume{} + } + return []corev1.Volume{ + { + Name: c.taskDef.Spec.Container.VolumeMounts[0].Name, + VolumeSource: corev1.VolumeSource{ + EmptyDir: c.getVolumeSource(), + }, + }, + } } diff --git a/operator/controllers/lifecycle/keptntask/container_builder_test.go b/operator/controllers/lifecycle/keptntask/container_builder_test.go new file mode 100644 index 0000000000..bcdaee78c1 --- /dev/null +++ b/operator/controllers/lifecycle/keptntask/container_builder_test.go @@ -0,0 +1,244 @@ +package keptntask + +import ( + "context" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + "github.com/stretchr/testify/require" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" +) + +func TestContainerBuilder_CreateContainerWithVolumes(t *testing.T) { + tests := []struct { + name string + builder ContainerBuilder + wantContainer *v1.Container + wantVolumes []v1.Volume + }{ + { + name: "defined without volumes", + builder: ContainerBuilder{ + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + }, + }, + }, + }, + }, + wantContainer: &v1.Container{ + Image: "image", + }, + wantVolumes: []v1.Volume{}, + }, + { + name: "defined with volume", + builder: ContainerBuilder{ + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + VolumeMounts: []v1.VolumeMount{ + { + Name: "test-volume", + MountPath: "path", + }, + }, + }, + }, + }, + }, + }, + wantContainer: &v1.Container{ + Image: "image", + VolumeMounts: []v1.VolumeMount{ + { + Name: "test-volume", + MountPath: "path", + }, + }, + }, + wantVolumes: []v1.Volume{ + { + Name: "test-volume", + VolumeSource: v1.VolumeSource{ + EmptyDir: &v1.EmptyDirVolumeSource{ + SizeLimit: resource.NewQuantity(1, resource.Format("Gi")), + Medium: v1.StorageMedium("Memory"), + }, + }, + }, + }, + }, + { + name: "defined with volume and limits", + builder: ContainerBuilder{ + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + "memory": *resource.NewQuantity(100, resource.Format("Mi")), + }, + }, + VolumeMounts: []v1.VolumeMount{ + { + Name: "test-volume", + MountPath: "path", + }, + }, + }, + }, + }, + }, + }, + wantContainer: &v1.Container{ + Image: "image", + VolumeMounts: []v1.VolumeMount{ + { + Name: "test-volume", + MountPath: "path", + }, + }, + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + "memory": *resource.NewQuantity(100, resource.Format("Mi")), + }, + }, + }, + wantVolumes: []v1.Volume{ + { + Name: "test-volume", + VolumeSource: v1.VolumeSource{ + EmptyDir: &v1.EmptyDirVolumeSource{ + SizeLimit: resource.NewQuantity(100, resource.Format("Mi")), + Medium: v1.StorageMedium("Memory"), + }, + }, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + container, volumes, _ := tt.builder.CreateContainerWithVolumes(context.TODO()) + require.Equal(t, tt.wantContainer, container) + require.Equal(t, tt.wantVolumes, volumes) + }) + } +} + +func Test_GenerateVolumes(t *testing.T) { + tests := []struct { + name string + taskDef *v1alpha3.KeptnTaskDefinition + want []v1.Volume + }{ + { + name: "defined", + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + VolumeMounts: []v1.VolumeMount{ + { + Name: "name", + MountPath: "path", + }, + }, + }, + }, + }, + }, + want: []v1.Volume{ + { + Name: "name", + VolumeSource: v1.VolumeSource{ + EmptyDir: &v1.EmptyDirVolumeSource{ + SizeLimit: resource.NewQuantity(1, resource.Format("Gi")), + Medium: v1.StorageMedium("Memory"), + }, + }, + }, + }, + }, + { + name: "empty", + taskDef: &v1alpha3.KeptnTaskDefinition{}, + want: []v1.Volume{}, + }, + } + for _, tt := range tests { + builder := ContainerBuilder{ + taskDef: tt.taskDef, + } + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, builder.generateVolumes()) + }) + } +} + +func Test_GetVolumeSource(t *testing.T) { + tests := []struct { + name string + taskDef *v1alpha3.KeptnTaskDefinition + want *v1.EmptyDirVolumeSource + }{ + { + name: "not set limits", + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{}, + }, + }, + }, + }, + }, + want: &v1.EmptyDirVolumeSource{ + SizeLimit: resource.NewQuantity(1, resource.Format("Gi")), + Medium: v1.StorageMedium("Memory"), + }, + }, + { + name: "set limits", + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + "memory": *resource.NewQuantity(100, resource.Format("Mi")), + }, + }, + }, + }, + }, + }, + want: &v1.EmptyDirVolumeSource{ + SizeLimit: resource.NewQuantity(100, resource.Format("Mi")), + Medium: v1.StorageMedium("Memory"), + }, + }, + } + for _, tt := range tests { + builder := ContainerBuilder{ + taskDef: tt.taskDef, + } + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, builder.getVolumeSource()) + }) + } +} diff --git a/operator/controllers/lifecycle/keptntask/job_runner_builder.go b/operator/controllers/lifecycle/keptntask/job_runner_builder.go new file mode 100644 index 0000000000..d177c0cae6 --- /dev/null +++ b/operator/controllers/lifecycle/keptntask/job_runner_builder.go @@ -0,0 +1,37 @@ +package keptntask + +import ( + "github.com/go-logr/logr" + klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + "golang.org/x/net/context" + corev1 "k8s.io/api/core/v1" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// JobRunnerBuilder is the interface that describes the operations needed to help build job specs of a task +type JobRunnerBuilder interface { + // CreateContainerWithVolumes returns a job container and volumes based on the task definition spec + CreateContainerWithVolumes(ctx context.Context) (*corev1.Container, []corev1.Volume, error) +} + +// BuilderOptions contains everything needed to build the current job +type BuilderOptions struct { + client.Client + recorder record.EventRecorder + req ctrl.Request + Log logr.Logger + task *klcv1alpha3.KeptnTask + taskDef *klcv1alpha3.KeptnTaskDefinition +} + +func getJobRunnerBuilder(options BuilderOptions) JobRunnerBuilder { + if options.taskDef.IsJSSpecDefined() { + return NewJSBuilder(options) + } + if options.taskDef.IsContainerSpecDefined() { + return NewContainerBuilder(options.taskDef) + } + return nil +} diff --git a/operator/controllers/lifecycle/keptntask/job_runner_builder_test.go b/operator/controllers/lifecycle/keptntask/job_runner_builder_test.go new file mode 100644 index 0000000000..36f23442e1 --- /dev/null +++ b/operator/controllers/lifecycle/keptntask/job_runner_builder_test.go @@ -0,0 +1,62 @@ +package keptntask + +import ( + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + "github.com/stretchr/testify/require" + v1 "k8s.io/api/core/v1" +) + +func Test_getJobRunnerBuilder(t *testing.T) { + jsBuilderOptions := BuilderOptions{ + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Function: &v1alpha3.FunctionSpec{ + Inline: v1alpha3.Inline{ + Code: "some code", + }, + }, + }, + }, + } + containerBuilderOptions := BuilderOptions{ + taskDef: &v1alpha3.KeptnTaskDefinition{ + Spec: v1alpha3.KeptnTaskDefinitionSpec{ + Container: &v1alpha3.ContainerSpec{ + Container: &v1.Container{ + Image: "image", + }, + }, + }, + }, + } + tests := []struct { + name string + options BuilderOptions + want JobRunnerBuilder + }{ + { + name: "js builder", + options: jsBuilderOptions, + want: NewJSBuilder(jsBuilderOptions), + }, + { + name: "container builder", + options: containerBuilderOptions, + want: NewContainerBuilder(containerBuilderOptions.taskDef), + }, + { + name: "invalid builder", + options: BuilderOptions{ + taskDef: &v1alpha3.KeptnTaskDefinition{}, + }, + want: nil, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, getJobRunnerBuilder(tt.options)) + }) + } +} diff --git a/operator/controllers/lifecycle/keptntask/job_utils.go b/operator/controllers/lifecycle/keptntask/job_utils.go index 61eadf5238..8d58bb96dd 100644 --- a/operator/controllers/lifecycle/keptntask/job_utils.go +++ b/operator/controllers/lifecycle/keptntask/job_utils.go @@ -24,7 +24,7 @@ func (r *KeptnTaskReconciler) createJob(ctx context.Context, req ctrl.Request, t return err } - if specExists(definition) { + if definition.SpecExists() { jobName, err = r.createFunctionJob(ctx, req, task, definition) if err != nil { return err @@ -141,12 +141,13 @@ func (r *KeptnTaskReconciler) generateJob(ctx context.Context, task *klcv1alpha3 taskDef: definition, recorder: r.Recorder, } - builder := getContainerBuilder(builderOpt) + + builder := getJobRunnerBuilder(builderOpt) if builder == nil { return nil, controllererrors.ErrNoTaskDefinitionSpec } - container, volumes, err := builder.CreateContainerWithVolumes(ctx) + container, volumes, err := builder.CreateContainerWithVolumes(ctx) if err != nil { return nil, controllererrors.ErrCannotMarshalParams } diff --git a/operator/controllers/lifecycle/keptntask/job_utils_test.go b/operator/controllers/lifecycle/keptntask/job_utils_test.go index ec242e07e1..5d18417361 100644 --- a/operator/controllers/lifecycle/keptntask/job_utils_test.go +++ b/operator/controllers/lifecycle/keptntask/job_utils_test.go @@ -272,7 +272,7 @@ func makeTaskDefinitionWithConfigmapRef(name, namespace, configMapName string) * }, }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ ConfigMapReference: klcv1alpha3.ConfigMapReference{ Name: configMapName, }, diff --git a/operator/controllers/lifecycle/keptntask/js_builder.go b/operator/controllers/lifecycle/keptntask/js_builder.go index 5a990f4b3c..b6fb1083e8 100644 --- a/operator/controllers/lifecycle/keptntask/js_builder.go +++ b/operator/controllers/lifecycle/keptntask/js_builder.go @@ -19,8 +19,8 @@ type JSBuilder struct { options BuilderOptions } -func newJSBuilder(options BuilderOptions) JSBuilder { - return JSBuilder{ +func NewJSBuilder(options BuilderOptions) *JSBuilder { + return &JSBuilder{ options: options, } } diff --git a/operator/controllers/lifecycle/keptntask/js_builder_test.go b/operator/controllers/lifecycle/keptntask/js_builder_test.go index b935be9157..067f235aa1 100644 --- a/operator/controllers/lifecycle/keptntask/js_builder_test.go +++ b/operator/controllers/lifecycle/keptntask/js_builder_test.go @@ -22,7 +22,7 @@ func TestJSBuilder_handleParent(t *testing.T) { Namespace: "default", }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ FunctionReference: klcv1alpha3.FunctionReference{ Name: "mytaskdef", }}}, @@ -33,7 +33,7 @@ func TestJSBuilder_handleParent(t *testing.T) { Namespace: "default", }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ FunctionReference: klcv1alpha3.FunctionReference{ Name: "mytd"}, Parameters: klcv1alpha3.TaskParameters{ @@ -124,7 +124,7 @@ func TestJSBuilder_hasParams(t *testing.T) { Namespace: "default", }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ HttpReference: klcv1alpha3.HttpReference{Url: "donothing"}, Parameters: klcv1alpha3.TaskParameters{ Inline: map[string]string{"DATA2": "mydata2"}, @@ -140,7 +140,7 @@ func TestJSBuilder_hasParams(t *testing.T) { Namespace: "default", }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ HttpReference: klcv1alpha3.HttpReference{Url: "something"}, FunctionReference: klcv1alpha3.FunctionReference{ Name: "mytaskdef"}, diff --git a/operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go b/operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go index 321dda631f..6f1f612e82 100644 --- a/operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go +++ b/operator/controllers/lifecycle/keptntaskdefinition/reconcile_function.go @@ -18,6 +18,9 @@ import ( ) func (r *KeptnTaskDefinitionReconciler) reconcileFunction(ctx context.Context, req ctrl.Request, definition *klcv1alpha3.KeptnTaskDefinition) error { + if !definition.IsJSSpecDefined() { + return nil + } if definition.Spec.Function.Inline != (klcv1alpha3.Inline{}) { err := r.reconcileFunctionInline(ctx, req, definition) if err != nil { diff --git a/operator/test/component/task/task_test.go b/operator/test/component/task/task_test.go index b86997c559..883709320d 100644 --- a/operator/test/component/task/task_test.go +++ b/operator/test/component/task/task_test.go @@ -237,7 +237,7 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.Keptn Namespace: namespace, }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ ConfigMapReference: klcv1alpha3.ConfigMapReference{ Name: cmName, }, diff --git a/operator/test/component/taskdefinition/taskdefinition_test.go b/operator/test/component/taskdefinition/taskdefinition_test.go index adc55b5f84..da33ac77a6 100644 --- a/operator/test/component/taskdefinition/taskdefinition_test.go +++ b/operator/test/component/taskdefinition/taskdefinition_test.go @@ -41,7 +41,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { Namespace: namespace, }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ Inline: klcv1alpha3.Inline{ Code: "console.log(Hello);", }, @@ -90,7 +90,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { Namespace: namespace, }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ ConfigMapReference: klcv1alpha3.ConfigMapReference{ Name: "my-configmap", }, @@ -141,7 +141,7 @@ var _ = Describe("Taskdefinition", Ordered, func() { Namespace: namespace, }, Spec: klcv1alpha3.KeptnTaskDefinitionSpec{ - Function: klcv1alpha3.FunctionSpec{ + Function: &klcv1alpha3.FunctionSpec{ ConfigMapReference: klcv1alpha3.ConfigMapReference{ Name: "my-configmap-non-existing", }, diff --git a/test/integration/container-runtime/00-assert.yaml b/test/integration/container-runtime/00-assert.yaml new file mode 100644 index 0000000000..109db6ff9f --- /dev/null +++ b/test/integration/container-runtime/00-assert.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: test + name: test +status: + readyReplicas: 1 +--- +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnWorkload +metadata: + name: waiter-waiter +--- +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnWorkloadInstance +metadata: + name: waiter-waiter-0.4 +status: + currentPhase: Completed + deploymentStatus: Succeeded + postDeploymentEvaluationStatus: Succeeded + postDeploymentStatus: Succeeded + preDeploymentEvaluationStatus: Succeeded + preDeploymentStatus: Succeeded + preDeploymentTaskStatus: + - definitionName: pre-deployment-sleep + status: Succeeded + status: Succeeded +--- +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnApp +metadata: + name: waiter +--- +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnAppVersion +metadata: + name: waiter-1b899b6ce1-6b86b273 +status: + currentPhase: Completed + status: Succeeded +--- +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnTask +metadata: + annotations: + container: test +status: + status: Succeeded +--- +apiVersion: batch/v1 +kind: Job +metadata: + annotations: + container: test + keptn.sh/app: waiter + keptn.sh/version: '0.4' + keptn.sh/workload: waiter-waiter +status: + conditions: + - type: Complete + status: 'True' + succeeded: 1 diff --git a/test/integration/container-runtime/00-install.yaml b/test/integration/container-runtime/00-install.yaml new file mode 100644 index 0000000000..356aaa942f --- /dev/null +++ b/test/integration/container-runtime/00-install.yaml @@ -0,0 +1,40 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnTaskDefinition +metadata: + name: pre-deployment-sleep + annotations: + container: test +spec: + container: + name: testy-test + image: busybox:1.36.0 + command: + - 'sh' + - '-c' + - 'sleep 30' +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: test + name: test +spec: + replicas: 1 + selector: + matchLabels: + app: test + strategy: {} + template: + metadata: + labels: + app: test + annotations: + keptn.sh/workload: waiter + keptn.sh/version: "0.4" + keptn.sh/pre-deployment-tasks: pre-deployment-sleep + spec: + containers: + - image: busybox + name: busybox + command: ['sh', '-c', 'echo The app is running! && sleep infinity'] diff --git a/test/integration/container-runtime/00-teststep.yaml b/test/integration/container-runtime/00-teststep.yaml new file mode 100644 index 0000000000..ad4f1d95d5 --- /dev/null +++ b/test/integration/container-runtime/00-teststep.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1 +kind: TestStep +commands: + - script: kubectl annotate ns $NAMESPACE keptn.sh/lifecycle-toolkit='enabled'