From 7901c43225927c780be03bfb8e3f7c03f835d810 Mon Sep 17 00:00:00 2001 From: Kenneth Koski Date: Tue, 5 Jan 2021 05:56:01 -0600 Subject: [PATCH] Add Github Actions CI for charm operators (#1407) Builds images locally with `latest` tag, and includes new bundle for testing purposes that sets operator docker images to `latest` as well instead of a particular revision. --- .github/workflows/test-charmed-katib.yaml | 83 +++++++++++++++++++++++ operators/bundle-edge.yaml | 24 +++++++ 2 files changed, 107 insertions(+) create mode 100644 .github/workflows/test-charmed-katib.yaml create mode 100644 operators/bundle-edge.yaml diff --git a/.github/workflows/test-charmed-katib.yaml b/.github/workflows/test-charmed-katib.yaml new file mode 100644 index 00000000000..8aa86ec9e9f --- /dev/null +++ b/.github/workflows/test-charmed-katib.yaml @@ -0,0 +1,83 @@ +name: Charmed Katib + +on: + - push + - pull_request + +jobs: + build: + name: Test + runs-on: ubuntu-latest + + steps: + - name: Check out repo + uses: actions/checkout@v2 + + - uses: balchua/microk8s-actions@v0.2.2 + with: + channel: '1.19/stable' + addons: '["dns", "storage", "rbac"]' + + - name: Install dependencies + run: | + set -eux + sudo snap install charm --classic + sudo snap install juju --classic + sudo snap install juju-helpers --classic + sudo snap install juju-wait --classic + sudo apt update + + - name: Build Docker images + run: | + set -eux + for image in katib-ui katib-controller katib-db-manager; do + docker build . \ + -t docker.io/kubeflowkatib/$image:latest \ + -f cmd/katib-controller/v1beta1/Dockerfile + docker save docker.io/kubeflowkatib/$image > $image.tar + microk8s ctr image import $image.tar + done + + - name: Deploy Katib + run: | + set -eux + cd operators/ + git clone git://git.launchpad.net/canonical-osm + cp -r canonical-osm/charms/interfaces/juju-relation-mysql mysql + sg microk8s -c 'juju bootstrap microk8s uk8s' + juju add-model katib + juju bundle deploy -b bundle-edge.yaml --build + juju wait -wvt 300 + + - name: Test Katib + run: | + set -eux + kubectl run \ + --rm \ + -i \ + --restart=Never \ + --image=ubuntu \ + katib-check \ + -- \ + bash -c "apt update && apt install -y curl && curl -f http://katib-ui.katib.svc.cluster.local:8080/katib/" + + + - name: Get pod statuses + run: kubectl get all -A + if: failure() + + - name: Get juju status + run: juju status + if: failure() + + - name: Get katib-controller logs + run: kubectl logs --tail 100 -nkatib -ljuju-app=katib-controller + if: failure() + + - name: Get katib-ui logs + run: kubectl logs --tail 100 -nkatib -ljuju-app=katib-ui + if: failure() + + - name: Get katib-manager logs + run: kubectl logs --tail 100 -nkatib -ljuju-app=katib-manager + if: failure() diff --git a/operators/bundle-edge.yaml b/operators/bundle-edge.yaml new file mode 100644 index 00000000000..1b37cbf38bd --- /dev/null +++ b/operators/bundle-edge.yaml @@ -0,0 +1,24 @@ +bundle: kubernetes +applications: + katib-controller: + charm: katib-controller + scale: 1 + resources: + oci-image: docker.io/kubeflowkatib/katib-controller:latest + katib-db: + charm: cs:~charmed-osm/mariadb-k8s + scale: 1 + options: + database: katib + katib-db-manager: + charm: katib-db-manager + scale: 1 + resources: + oci-image: docker.io/kubeflowkatib/katib-db-manager:latest + katib-ui: + charm: katib-ui + scale: 1 + resources: + oci-image: docker.io/kubeflowkatib/katib-ui:latest +relations: +- [katib-db-manager, katib-db]