From 879462dd7fe0f9b38830c4ffd3e3a7cc8b4f08de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 4 Jun 2024 18:43:33 +0200 Subject: [PATCH 1/2] Add integration tests for ODH and Notebook Controller This commit adds GitHub Actions workflows for ODH Notebook Controller and Notebook Controller. It automates the build, test, and deployment processes, which include installing necessary services like podman, KinD, kustomize, and Istio, and setting up environments for testing. The integration tests will run on every push, pull request, and can be manually dispatched when needed. --- .../notebook_controller_integration_test.yaml | 112 +++++++++++++++ ..._notebook_controller_integration_test.yaml | 127 ++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 .github/workflows/notebook_controller_integration_test.yaml create mode 100644 .github/workflows/odh_notebook_controller_integration_test.yaml diff --git a/.github/workflows/notebook_controller_integration_test.yaml b/.github/workflows/notebook_controller_integration_test.yaml new file mode 100644 index 00000000000..dd8caffe5fa --- /dev/null +++ b/.github/workflows/notebook_controller_integration_test.yaml @@ -0,0 +1,112 @@ +name: Notebook Controller Integration Test +on: + push: + pull_request: + paths: + - components/notebook-controller/** + workflow_dispatch: + +env: + IMG: notebook-controller + TAG: integration-test + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install podman + run: | + sudo mkdir -p /etc/apt/keyrings + curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/Release.key \ + | gpg --dearmor \ + | sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ + https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/ /" \ + | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null + sudo apt-get update -qq + sudo apt-get -qq -y install podman + podman version + + # temporary fix for https://github.com/containers/podman/issues/21024 + wget https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_22.04/amd64/conmon_2.1.2~0_amd64.deb -O /tmp/conmon_2.1.2.deb + sudo apt install /tmp/conmon_2.1.2.deb + + # Starting systemd user service + systemctl --user daemon-reload + systemctl --user start podman.socket + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Go + uses: actions/setup-go@v5 + with: + check-latest: true + go-version-file: components/notebook-controller/go.mod + cache-dependency-path: components/notebook-controller/go.sum + + - name: Build Notebook Controller Image + run: | + cd components/notebook-controller + make docker-build + env: + CACHE_IMAGE: ghcr.io/${{ github.repository }}/components/notebook-controller/build-cache + + - name: Install KinD + run: ./components/testing/gh-actions/install_kind.sh + + - name: Create KinD Cluster + run: kind create cluster --config components/testing/gh-actions/kind-1-25.yaml + + - name: Load Images into KinD Cluster + run: | + # kind load docker-image localhost/${{env.IMG}}:${{env.TAG}} + podman save -o img.tar localhost/${{env.IMG}}:${{env.TAG}} + kind load image-archive img.tar + + - name: Install kustomize + run: ./components/testing/gh-actions/install_kustomize.sh + + - name: Install Istio + run: ./components/testing/gh-actions/install_istio.sh + + - name: Build & Apply manifests + run: | + set -x + + cd components/notebook-controller/config/overlays/kubeflow + kubectl create ns kubeflow + + export CURRENT_NOTEBOOK_IMG=docker.io/kubeflownotebookswg/notebook-controller + export PR_NOTEBOOK_IMG=localhost/${{env.IMG}}:${{env.TAG}} + kustomize edit set image ${CURRENT_NOTEBOOK_IMG}=${PR_NOTEBOOK_IMG} + + cat < /dev/null + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ + https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/ /" \ + | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null + sudo apt-get update -qq + sudo apt-get -qq -y install podman + podman version + + # temporary fix for https://github.com/containers/podman/issues/21024 + wget https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_22.04/amd64/conmon_2.1.2~0_amd64.deb -O /tmp/conmon_2.1.2.deb + sudo apt install /tmp/conmon_2.1.2.deb + + # Starting systemd user service + systemctl --user daemon-reload + systemctl --user start podman.socket + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Go + uses: actions/setup-go@v5 + with: + check-latest: true + go-version-file: components/odh-notebook-controller/go.mod + cache-dependency-path: components/odh-notebook-controller/go.sum + + - name: Build Notebook Controller Image + run: | + cd components/odh-notebook-controller + make docker-build + env: + CACHE_IMAGE: ghcr.io/${{ github.repository }}/components/odh-notebook-controller/build-cache + + - name: Install KinD + run: ./components/testing/gh-actions/install_kind.sh + + - name: Create KinD Cluster + run: kind create cluster --config components/testing/gh-actions/kind-1-25.yaml + + - name: Load Images into KinD Cluster + run: | + # kind load docker-image localhost/${{env.IMG}}:${{env.TAG}} + podman save -o img.tar localhost/${{env.IMG}}:${{env.TAG}} + kind load image-archive img.tar + + - name: Install kustomize + run: ./components/testing/gh-actions/install_kustomize.sh + + - name: Install Istio + run: ./components/testing/gh-actions/install_istio.sh + + - name: Build & Apply manifests + run: | + set -x + + cd components/odh-notebook-controller/config/default + kubectl create ns opendatahub + + export CURRENT_NOTEBOOK_IMG=quay.io/opendatahub/odh-notebook-controller:latest + export PR_NOTEBOOK_IMG=localhost/${{env.IMG}}:${{env.TAG}} + kustomize edit set image ${CURRENT_NOTEBOOK_IMG}=${PR_NOTEBOOK_IMG} + + cat < Date: Tue, 4 Jun 2024 16:56:13 +0200 Subject: [PATCH 2/2] Use unauthenticated Red Hat container registry in our upstream Dockerfile --- components/notebook-controller/Dockerfile | 4 ++-- components/odh-notebook-controller/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/notebook-controller/Dockerfile b/components/notebook-controller/Dockerfile index 1ce58843911..cac8594e54d 100644 --- a/components/notebook-controller/Dockerfile +++ b/components/notebook-controller/Dockerfile @@ -10,7 +10,7 @@ ARG SOURCE_CODE=. ARG GOLANG_VERSION=1.20 # Use ubi8/go-toolset as base image -FROM registry.redhat.io/ubi8/go-toolset:${GOLANG_VERSION} as builder +FROM registry.access.redhat.com/ubi8/go-toolset:${GOLANG_VERSION} as builder ## Build args to be used at this step ARG SOURCE_CODE @@ -40,7 +40,7 @@ RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -mod=mod \ -o ./bin/manager main.go # Use ubi8/ubi-minimal as base image -FROM registry.redhat.io/ubi8/ubi-minimal:latest +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest ## Install additional packages RUN microdnf install -y shadow-utils &&\ diff --git a/components/odh-notebook-controller/Dockerfile b/components/odh-notebook-controller/Dockerfile index 84f06d04c04..996900f882f 100644 --- a/components/odh-notebook-controller/Dockerfile +++ b/components/odh-notebook-controller/Dockerfile @@ -10,7 +10,7 @@ ARG SOURCE_CODE=. ARG GOLANG_VERSION=1.20 # Use ubi8/go-toolset as base image -FROM registry.redhat.io/ubi8/go-toolset:${GOLANG_VERSION} as builder +FROM registry.access.redhat.com/ubi8/go-toolset:${GOLANG_VERSION} as builder ## Build args to be used at this step ARG SOURCE_CODE @@ -38,7 +38,7 @@ RUN go build \ -o ./bin/manager main.go # Use ubi8/ubi-minimal as base image -FROM registry.redhat.io/ubi8/ubi-minimal:latest +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest ## Install additional packages RUN microdnf install -y shadow-utils &&\