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

ci: add helm to install action #738

Merged
merged 5 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 16 additions & 2 deletions .github/actions/deploy-klt-on-cluster/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ inputs:
required: false
description: "Name of the kind cluster"
default: "test-cluster"

helm-install:
required: false
type: boolean
description: "Install KLT via helm instead of manifest if true"
# renovate: datasource=github-releases depName=kubernetes-sigs/kind
default: false
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -52,9 +57,11 @@ runs:
kind load image-archive $image/$image -n ${{ inputs.cluster-name }}
done

- name: Install lifecycle-toolkit
- name: Install lifecycle-toolkit with manifests
if: ${{ inputs.helm-install == 'false' }}
shell: bash
run: |
echo "Installing KLT using manifests"
sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/g' ~/download/artifacts/keptn-lifecycle-operator-manifest-test/release.yaml
sed -i 's/ghcr.keptn.sh\/keptn\/functions-runtime:.*/localhost:5000\/keptn\/functions-runtime:${{ inputs.functions_runtime_tag }}/g' ~/download/artifacts/keptn-lifecycle-operator-manifest-test/release.yaml
kubectl create namespace keptn-lifecycle-toolkit-system
Expand All @@ -64,3 +71,10 @@ runs:
kubectl apply -f ~/download/artifacts/scheduler-manifest-test
kubectl rollout status deployment keptn-scheduler -n keptn-lifecycle-toolkit-system -w
kubectl rollout status deployment klc-controller-manager -n keptn-lifecycle-toolkit-system -w

- name: Install lifecycle-toolkit with helm
if: ${{ inputs.helm-install == 'true' }}
shell: bash
run: |
echo "Installing KLT using helm"
helm upgrade --install -n keptn-lifecycle-toolkit-system --create-namespace toolkit ~/download/artifacts/keptn-lifecycle-toolkit.tgz --debug --wait --timeout 1m
148 changes: 148 additions & 0 deletions .github/workflows/helm-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Helm-test
on:
schedule:
- cron: '0 3 * * 1' # run tests at 1 AM (UTC), every monday (1)
workflow_dispatch:

env:
GO_VERSION: "~1.19"
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_VERSION: "v0.9.2"
ENVTEST_K8S_VERSION: "1.24.2"
SCHEDULER_COMPATIBLE_K8S_VERSION: "v0.24.3"
defaults:
run:
shell: bash

jobs:
prepare_ci_run:
name: Prepare CI Run
runs-on: ubuntu-22.04
outputs:
GIT_SHA: ${{ steps.extract_branch.outputs.GIT_SHA }}
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }}
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }}
DATETIME: ${{ steps.get_datetime.outputs.DATETIME }}
BUILD_TIME: ${{ steps.get_datetime.outputs.BUILD_TIME }}
NON_FORKED_AND_NON_ROBOT_RUN: ${{ steps.get_run_type.outputs.NON_FORKED_AND_NON_ROBOT_RUN }}

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Extract branch name
id: extract_branch
uses: keptn/gh-action-extract-branch-name@main

- name: Get current date and time
id: get_datetime
run: |
DATETIME=$(date +'%Y%m%d%H%M')
BUILD_TIME=$(date -u "+%F_%T")
echo "DATETIME=$DATETIME" >> "$GITHUB_OUTPUT"
echo "BUILD_TIME=$BUILD_TIME" >> "$GITHUB_OUTPUT"

- name: Get workflow run type
id: get_run_type
run: |
NON_FORKED_AND_NON_ROBOT_RUN=${{ ( github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' ) && ( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository ) }}
echo "github.actor != 'renovate[bot]' = ${{ github.actor != 'renovate[bot]' }}"
echo "github.actor != 'dependabot[bot]' = ${{ github.actor != 'dependabot[bot]' }}"
echo "github.event_name == 'push' = ${{ github.event_name == 'push' }}"
echo "github.event.pull_request.head.repo.full_name == github.repository = ${{ github.event.pull_request.head.repo.full_name == github.repository }}"
echo "NON_FORKED_AND_NON_ROBOT_RUN = $NON_FORKED_AND_NON_ROBOT_RUN"
echo "NON_FORKED_AND_NON_ROBOT_RUN=$NON_FORKED_AND_NON_ROBOT_RUN" >> "$GITHUB_OUTPUT"

build_image:
name: Build Docker Image
needs: prepare_ci_run
runs-on: ubuntu-22.04
env:
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }}
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
RELEASE_REGISTRY: "localhost:5000/keptn"
strategy:
matrix:
config:
- name: "keptn-lifecycle-operator"
folder: "operator/"
- name: "scheduler"
folder: "scheduler/"
- name: "functions-runtime"
folder: "functions-runtime/"
- name: "klt-cert-manager"
folder: "klt-cert-manager/"
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cache build tools
id: cache-build-tools
uses: actions/cache@v3
with:
path: ./${{ matrix.config.folder }}bin
key: build-tools-${{ github.ref_name }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker Image
uses: docker/build-push-action@v3
with:
context: ${{ matrix.config.folder }}
platforms: linux/amd64
target: production
tags: |
${{ env.RELEASE_REGISTRY }}/${{ matrix.config.name }}:dev-${{ env.DATETIME }}
build-args: |
GIT_HASH=${{ env.GIT_SHA }}
RELEASE_VERSION=dev-${{ env.DATETIME }}
BUILD_TIME=${{ env.BUILD_TIME }}
CONTROLLER_TOOLS_VERSION=${{ env.CONTROLLER_TOOLS_VERSION }}
SCHEDULER_COMPATIBLE_K8S_VERSION=${{ env.SCHEDULER_COMPATIBLE_K8S_VERSION }}
builder: ${{ steps.buildx.outputs.name }}
push: false
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.config.name }}
cache-to: type=gha,scope=${{ github.ref_name }}-${{ matrix.config.name }}
outputs: type=docker,dest=/tmp/${{ matrix.config.name }}-image.tar

- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.name }}-image.tar
path: /tmp/${{ matrix.config.name }}-image.tar


build_helm_chart:
name: Build Helm Chart
needs: [ prepare_ci_run, build_image ]
runs-on: ubuntu-22.04
env:
RELEASE_REGISTRY: "localhost:5000/keptn"
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Generate helm charts
run: |
make helm-package RELEASE_REGISTRY=${{ env.RELEASE_REGISTRY }} TAG=dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/g' ./helm/chart/templates/rendered.yaml
sed -i 's/ghcr.keptn.sh\/keptn\/functions-runtime:.*/localhost:5000\/keptn\/functions-runtime dev-${{ needs.prepare_ci_run.outputs.DATETIME }}/g' ./helm/chart/templates/rendered.yaml
rm -r ./helm/chart/charts

- name: Upload KLT helm charts archive
uses: actions/upload-artifact@v3
with:
name: keptn-lifecycle-toolkit.tgz
path: ./helm/chart/*

integration_tests:
name: Integration Tests
needs: [ build_helm_chart ]
with:
functions_runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
helm-install: true
uses: ./.github/workflows/integration-test.yml
5 changes: 5 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
description: "Tag for the functions runner image"
type: "string"
required: true
helm-install:
description: "Decides wheter to install via helm"
type: "boolean"
default: false
env:
GO_VERSION: "~1.19"
# renovate: datasource=github-tags depName=kudobuilder/kuttl
Expand All @@ -26,6 +30,7 @@ jobs:
uses: ./.github/actions/deploy-klt-on-cluster
with:
functions_runtime_tag: ${{ inputs.functions_runtime_tag }}
helm-install: ${{ inputs.helm-install }}

- name: Download KUTTL
run: |
Expand Down
8 changes: 1 addition & 7 deletions operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
control-plane: controller-manager
name: system
---

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down