Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support scheduling gates in integration tests #2149

Merged
merged 6 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/actions/deploy-klt-on-cluster-scheduling-gates/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: "Deploy Keptn Lifecycle Toolkit on GH cluster"
odubajDT marked this conversation as resolved.
Show resolved Hide resolved
description: "Creates a Kind cluster and deploys Keptn Lifecycle Toolkit"
inputs:
kind-version:
required: false
description: "Version of kind that should be used"
# renovate: datasource=github-releases depName=kubernetes-sigs/kind
default: "v0.18.0"
k8s-version:
required: false
description: "Kubernetes that should be used"
odubajDT marked this conversation as resolved.
Show resolved Hide resolved
# renovate: datasource=github-releases depName=kubernetes/kubernetes
default: "v1.27.3"
runtime_tag:
description: "Tag for the runner image"
required: true
cluster-name:
required: false
description: "Name of the kind cluster"
default: "test-cluster"
runs:
using: "composite"
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: '**/go.sum'
check-latest: true

- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ~/download/artifacts

- name: "Create single kind Cluster"
uses: helm/[email protected]
with:
cluster_name: ${{ inputs.cluster-name }}
version: ${{ inputs.kind-version }}
node_image: "kindest/node:${{ inputs.k8s-version }}"
kubectl_version: ${{ inputs.k8s-version }}

- name: Import images in k3d
shell: bash
run: |
cd ~/download/artifacts
for image in $(ls | grep image.tar);
do
echo "Importing image: $image"
kind load image-archive $image/$image -n ${{ inputs.cluster-name }}
done

- name: Install lifecycle-toolkit with helm
env:
RELEASE_REGISTRY: "localhost:5000/keptn"
shell: bash
run: |
echo "Installing KLT using helm"
odubajDT marked this conversation as resolved.
Show resolved Hide resolved
helm version
helm install -n keptn-lifecycle-toolkit-system --create-namespace toolkit ./helm/chart \
--set schedulingGatesEnabled=true \
--set lifecycleOperator.manager.imagePullPolicy=Never \
--set lifecycleOperator.manager.image.tag=${{ inputs.runtime_tag }} \
--set lifecycleOperator.manager.image.repository="localhost:5000/keptn/lifecycle-operator" \
--set metricsOperator.manager.imagePullPolicy=Never \
--set metricsOperator.manager.env.enableKeptnAnalysis="true" \
--set metricsOperator.manager.image.tag=${{ inputs.runtime_tag }} \
--set metricsOperator.manager.image.repository="localhost:5000/keptn/metrics-operator" \
--set lifecycleOperator.manager.env.functionRunnerImage=localhost:5000/keptn/deno-runtime:${{ inputs.runtime_tag }} \
--set lifecycleOperator.manager.env.pythonRunnerImage=localhost:5000/keptn/python-runtime:${{ inputs.runtime_tag }} \
--set certificateOperator.manager.imagePullPolicy=Never \
--set certificateOperator.manager.image.tag=${{ inputs.runtime_tag }} \
--set certificateOperator.manager.image.repository="localhost:5000/keptn/certificate-operator" \
--debug --wait --timeout 1m
3 changes: 3 additions & 0 deletions .github/scripts/.helm-tests/default/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6753,6 +6753,7 @@ rules:
- get
- list
- watch
- update
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -7915,6 +7916,8 @@ spec:
value: "0"
- name: OPTIONS_CONTROLLER_LOG_LEVEL
value: "0"
- name: SCHEDULING_GATES_ENABLED
value: "false"
- name: KUBERNETES_CLUSTER_DOMAIN
value: cluster.local
image: ghcr.io/keptn/lifecycle-operator:v0.8.2
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,43 @@ jobs:
with:
name: logs-integration-tests-${{ inputs.helm-install }}
path: .github/scripts/logs

run-integration-test-scheduling-gates:
name: Run Integration Tests Scheduling Gates
if: ${{ inputs.helm-install == true }}
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup cluster
uses: ./.github/actions/deploy-klt-on-cluster-scheduling-gates
with:
runtime_tag: ${{ inputs.runtime_tag }}

- name: Install and expose Prometheus
uses: ./.github/actions/deploy-prometheus-on-cluster

- name: Download KUTTL
env:
BASE_URL: "https://github.com/kudobuilder/kuttl/releases"
run: |
curl -fL "${BASE_URL}/download/${{ env.KUTTL_VERSION }}/kubectl-kuttl_${KUTTL_VERSION#v}_linux_x86_64" -o kubectl-kuttl
chmod +x kubectl-kuttl
mv kubectl-kuttl /usr/local/bin

- name: Run Integration Tests
working-directory: .
run: make integration-test-scheduling-gates && make integration-test

- name: Create reports
if: always()
working-directory: ./.github/scripts
run: ./create-reports-full.sh

- name: Upload cluster logs
if: always()
uses: actions/upload-artifact@v3
with:
name: logs-integration-tests-scheduling-gates
path: .github/scripts/logs
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ integration-test-local: install-prometheus
kubectl kuttl test --start-kind=false ./test/testmetrics/ --config=kuttl-test-local.yaml
kubectl kuttl test --start-kind=false ./test/testcertificate/ --config=kuttl-test-local.yaml

.PHONY: integration-test-scheduling-gates #these tests should run on a real cluster!
integration-test-scheduling-gates: # to run a single test by name use --test eg. --test=expose-keptn-metric
kubectl kuttl test --start-kind=false ./test/scheduling-gates/ --config=kuttl-test.yaml

.PHONY: integration-test-scheduling-gates-local #these tests should run on a real cluster!
integration-test-scheduling-gates-local: install-prometheus
kubectl kuttl test --start-kind=false ./test/scheduling-gates/ --config=kuttl-test-local.yaml

.PHONY: load-test
load-test:
kubectl apply -f ./test/load/assets/templates/namespace.yaml
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ helm repo update
helm upgrade --install keptn klt/klt -n keptn-lifecycle-toolkit-system --create-namespace --wait
```

### Installation without scheduler

Keptn installed on Kubernetes cluster running Kubernetes >= 1.26
does not need scheduler for a proper functionality.
With introduction
of [Pod scheduling gates](https://kubernetes.io/blog/2022/12/26/pod-scheduling-readiness-alpha/)
Keptn can use this feature to substitute the functionality of Keptn scheduler.

As this functionality is still disabled by default, it can be enabled by setting up
the correct helm values.
This will lead to Keptn installation without scheduler and
odubajDT marked this conversation as resolved.
Show resolved Hide resolved
with scheduling gates feature enablement.
odubajDT marked this conversation as resolved.
Show resolved Hide resolved

Use the following command sequence
to install Keptn with scheduling gates enabled:

```shell
helm repo add klt https://charts.lifecycle.keptn.sh
helm repo update
helm upgrade --install keptn klt/klt -n keptn-lifecycle-toolkit-system --set schedulingGatesEnabled=true --create-namespace --wait
```

> **Note**
Please be aware that scheduling gates functionality in Kubernetes is enabled by default
in Kubernetes >= 1.27.
To use it with Kubernetes 1.26, you need to enable it on your cluster.

## More information

For more info about Keptn, please see our
Expand Down
9 changes: 5 additions & 4 deletions helm/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ as well as the concept of application health checks

### Global

| Name | Description | Value |
| ------------------------- | -------------------------------------- | --------------- |
| `kubernetesClusterDomain` | overrides domain.local | `cluster.local` |
| `imagePullSecrets` | global value for image registry secret | `[]` |
| Name | Description | Value |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| `kubernetesClusterDomain` | overrides domain.local | `cluster.local` |
| `imagePullSecrets` | global value for image registry secret | `[]` |
| `schedulingGatesEnabled` | enables the scheduling gates in lifecycle-operator. This feature is available in alpha version from K8s 1.27 or 1.26 enabling the alpha version | `false` |
3 changes: 2 additions & 1 deletion helm/chart/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@


## @section Global
## Current available parameters: kubernetesClusterDomain, imagePullSecrets
## Current available parameters: kubernetesClusterDomain, imagePullSecrets, schedulingGatesEnabled
## @param kubernetesClusterDomain overrides domain.local
## @param imagePullSecrets global value for image registry secret
## @param schedulingGatesEnabled enables the scheduling gates in lifecycle-operator. This feature is available in alpha version from K8s 1.27 or 1.26 enabling the alpha version
Loading
Loading