diff --git a/.github/workflows/auto-merge-sync.yaml b/.github/workflows/auto-merge-sync.yaml new file mode 100644 index 000000000..1267095db --- /dev/null +++ b/.github/workflows/auto-merge-sync.yaml @@ -0,0 +1,41 @@ +# Workflow is meant to run in the red-hat-data-services/codeflare-operator repo +name: Auto-Merge-Sync +on: + workflow_dispatch: + +jobs: + trigger-auto-merge-sync: + runs-on: ubuntu-latest + steps: + - name: upstream-odh-auto-merge + run: | + gh workflow run upstream-auto-merge.yaml --repo github.com/red-hat-data-services/rhods-devops-infra --ref main --field repositories=codeflare-upstream + sleep 5 + run_id=$(gh run list --workflow upstream-auto-merge.yaml --repo github.com/red-hat-data-services/rhods-devops-infra --limit 1 --json databaseId --jq .[].databaseId) + gh run watch ${run_id} --repo github.com/red-hat-data-services/rhods-devops-infra --interval 10 --exit-status + env: + GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} + shell: + bash + - name: odh-rhds-auto-merge + if: ${{ success()}} + run: | + gh workflow run upstream-auto-merge.yaml --repo github.com/red-hat-data-services/rhods-devops-infra --ref main --field repositories=codeflare-downstream + sleep 5 + run_id=$(gh run list --workflow upstream-auto-merge.yaml --repo github.com/red-hat-data-services/rhods-devops-infra --limit 1 --json databaseId --jq .[].databaseId) + gh run watch ${run_id} --repo github.com/red-hat-data-services/rhods-devops-infra --interval 10 --exit-status + env: + GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} + shell: + bash + - name: rhds-release-auto-merge + if: ${{ success()}} + run: | + gh workflow run main-release-auto-merge.yaml --repo github.com/red-hat-data-services/rhods-devops-infra --ref main --field repositories=codeflare-operator + sleep 5 + run_id=$(gh run list --workflow main-release-auto-merge.yaml --repo github.com/red-hat-data-services/rhods-devops-infra --limit 1 --json databaseId --jq .[].databaseId) + gh run watch ${run_id} --repo github.com/red-hat-data-services/rhods-devops-infra --interval 10 --exit-status + env: + GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} + shell: + bash diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml new file mode 100644 index 000000000..d2fa60acd --- /dev/null +++ b/.github/workflows/build-and-push.yaml @@ -0,0 +1,71 @@ +# This workflow will build the CodeFlare Operator image and push it to the opendatahub image registry + +name: Build and Push + +on: + push: + branches: + - 'main' + paths: + - 'config/manager/params.env' + workflow_dispatch: + +jobs: + check-image-existence: + name: Check if ODH CFO image exists on Quay + runs-on: ubuntu-latest + outputs: + image-found: ${{ steps.image.outputs.found }} + steps: + - uses: actions/checkout@v4 + + - name: Verify that the latest images are available on Quay + id: image + run: | + imageTag=$(cat config/manager/params.env | grep codeflare-operator-controller-image | cut -d ':' -f2) + size=$(curl -s https://quay.io/api/v1/repository/opendatahub/codeflare-operator/tag/?specificTag=$imageTag | jq .tags[0].size) + if [[ "$size" -eq 0 ]]; then + echo "Operator image with tag $imageTag not found in Quay.io, will be built." + echo "found=false" >> "$GITHUB_OUTPUT" + else + echo "Operator image with tag $imageTag found in Quay.io" + fi + + build-and-push: + needs: [check-image-existence] + if: ${{ needs.check-image-existence.outputs.image-found == 'false' }} + + name: Build and push ODH/CFO image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set Go + uses: actions/setup-go@v5 + with: + go-version-file: './go.mod' + + - name: Login to Quay.io + uses: redhat-actions/podman-login@v1 + with: + username: ${{ secrets.QUAY_BOT_USER }} + password: ${{ secrets.QUAY_BOT_PASSWORD }} + registry: quay.io + + - name: Get Upstream Release Tags + id: release-tags + run: | + release_tag=$(gh release view -R github.com/project-codeflare/codeflare-operator --json tagName | jq -r '.tagName') + echo "RELEASE_TAG=$release_tag" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Cleanup the go.mod and go.sum + run: | + go mod tidy + + - name: Image Build and Push + run: | + make build + make image-build -e IMG=quay.io/opendatahub/codeflare-operator:${{ env.RELEASE_TAG }} + make image-push -e IMG=quay.io/opendatahub/codeflare-operator:${{ env.RELEASE_TAG }} diff --git a/.github/workflows/odh-release.yml b/.github/workflows/odh-release.yml new file mode 100644 index 000000000..9fb2a6c0a --- /dev/null +++ b/.github/workflows/odh-release.yml @@ -0,0 +1,48 @@ +# This workflow will compile e2e tests and release them + +name: ODH Release +on: + workflow_dispatch: + inputs: + version: + description: 'Tag to be used for release, i.e.: v0.0.1-odh' + required: true + +jobs: + release-odh: + runs-on: ubuntu-latest + + # Permission required to create a release + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Set Go + uses: actions/setup-go@v5 + with: + go-version-file: './go.mod' + + - name: Verify that release doesn't exist yet + shell: bash {0} + run: | + gh release view ${{ github.event.inputs.version }} + status=$? + if [[ $status -eq 0 ]]; then + echo "Release ${{ github.event.inputs.version }} already exists." + exit 1 + fi + env: + GITHUB_TOKEN: ${{ github.TOKEN }} + + - name: Compile tests + run: | + go test -c -o compiled-tests/e2e ./test/e2e/ + + - name: Creates a release in GitHub + run: | + gh release create ${{ github.event.inputs.version }} --target ${{ github.ref }} compiled-tests/* + env: + GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} + shell: bash diff --git a/.tekton/odh-codeflare-operator-pull-request.yaml b/.tekton/odh-codeflare-operator-pull-request.yaml new file mode 100644 index 000000000..163003502 --- /dev/null +++ b/.tekton/odh-codeflare-operator-pull-request.yaml @@ -0,0 +1,50 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + annotations: + build.appstudio.openshift.io/repo: https://github.com/opendatahub-io/codeflare-operator?rev={{revision}} + build.appstudio.redhat.com/commit_sha: '{{revision}}' + build.appstudio.redhat.com/target_branch: '{{target_branch}}' + pipelinesascode.tekton.dev/cancel-in-progress: "false" + pipelinesascode.tekton.dev/max-keep-runs: "3" + pipelinesascode.tekton.dev/on-target-branch: "[test]" + pipelinesascode.tekton.dev/on-event: "[pull_request]" + pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch + == "main" + creationTimestamp: null + labels: + appstudio.openshift.io/application: opendatahub-release + appstudio.openshift.io/component: odh-codeflare-operator + pipelines.appstudio.openshift.io/type: build + name: odh-codeflare-operator-on-pull-request + namespace: open-data-hub-tenant +spec: + params: + - name: git-url + value: '{{source_url}}' + - name: revision + value: '{{revision}}' + - name: image-expires-after + value: 5d + - name: output-image + value: quay.io/opendatahub/codeflare-operator:pr-v1.16.0 + - name: dockerfile + value: Dockerfile + - name: path-context + value: . + pipelineRef: + resolver: git + params: + - name: url + value: https://github.com/red-hat-data-services/konflux-central.git + - name: revision + value: '{{ target_branch }}' + - name: pathInRepo + value: pipelines/container-build.yaml + taskRunTemplate: + serviceAccountName: build-pipeline-odh-codeflare-operator + workspaces: + - name: git-auth + secret: + secretName: '{{ git_auth_secret }}' +status: {} diff --git a/.tekton/odh-codeflare-operator-push.yaml b/.tekton/odh-codeflare-operator-push.yaml new file mode 100644 index 000000000..103bbc578 --- /dev/null +++ b/.tekton/odh-codeflare-operator-push.yaml @@ -0,0 +1,48 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + annotations: + build.appstudio.openshift.io/repo: https://github.com/opendatahub-io/codeflare-operator?rev={{revision}} + build.appstudio.redhat.com/commit_sha: '{{revision}}' + build.appstudio.redhat.com/target_branch: '{{target_branch}}' + pipelinesascode.tekton.dev/cancel-in-progress: "false" + pipelinesascode.tekton.dev/max-keep-runs: "3" + pipelinesascode.tekton.dev/on-target-branch: "[test]" + pipelinesascode.tekton.dev/on-event: "[push, comment]" + pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch + == "main" + creationTimestamp: null + labels: + appstudio.openshift.io/application: opendatahub-release + appstudio.openshift.io/component: odh-codeflare-operator + pipelines.appstudio.openshift.io/type: build + name: odh-codeflare-operator-on-push + namespace: open-data-hub-tenant +spec: + params: + - name: git-url + value: '{{source_url}}' + - name: revision + value: '{{revision}}' + - name: output-image + value: quay.io/opendatahub/codeflare-operator:v1.16.0 + - name: dockerfile + value: Dockerfile + - name: path-context + value: . + pipelineRef: + resolver: git + params: + - name: url + value: https://github.com/red-hat-data-services/konflux-central.git + - name: revision + value: '{{ target_branch }}' + - name: pathInRepo + value: pipelines/container-build.yaml + taskRunTemplate: + serviceAccountName: build-pipeline-odh-codeflare-operator + workspaces: + - name: git-auth + secret: + secretName: '{{ git_auth_secret }}' +status: {} diff --git a/Makefile b/Makefile index 31ce98cd6..e80330494 100644 --- a/Makefile +++ b/Makefile @@ -224,6 +224,11 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi $(KUSTOMIZE) build config/${ENV} | kubectl delete --ignore-not-found=$(ignore-not-found) -f - git restore config/* +.PHONY: install-odh-operator +install-odh-operator: kustomize ## Install ODH operator into the OpenShift cluster specified in ~/.kube/config. + $(KUSTOMIZE) build config/odh-operator | kubectl apply -f - + kubectl wait -n openshift-operators subscription/opendatahub-operator --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=180s + ##@ Build Dependencies ## Location to install dependencies to @@ -394,6 +399,13 @@ test-component: envtest ginkgo ## Run component tests. test-e2e: manifests fmt vet ## Run e2e tests. CODEFLARE_TEST_OUTPUT_DIR=/tmp/ CLUSTER_HOSTNAME=kind CODEFLARE_TEST_TIMEOUT_MEDIUM=5m CODEFLARE_TEST_TIMEOUT_LONG=40m go test -v -skip "^Test.*Gpu$$" ./test/e2e -timeout=60m +.PHONY: store-odh-logs +store-odh-logs: # Store all ODH relevant logs into artifact directory + kubectl logs -n opendatahub deployment/codeflare-operator-manager > ${ARTIFACT_DIR}/codeflare-operator.log + kubectl logs -n opendatahub deployment/kuberay-operator > ${ARTIFACT_DIR}/kuberay-operator.log + kubectl logs -n openshift-operators deployment/opendatahub-operator-controller-manager > ${ARTIFACT_DIR}/odh-operator.log + kubectl get events -n opendatahub > ${ARTIFACT_DIR}/odh-events.log + .PHONY: kind-e2e kind-e2e: ## Set up e2e KinD cluster test/e2e/kind.sh diff --git a/README.md b/README.md index 50228b780..21c71674b 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ For ODH tests additional environment variables are needed: 6. In ODH/CFO verify that the [Build and Push action](https://github.com/opendatahub-io/codeflare-operator/actions/workflows/build-and-push.yaml) was triggered and ran successfully. 7. Make sure that release automation created a PR updating CodeFlare SDK version in [ODH Notebooks repository](https://github.com/opendatahub-io/notebooks). Make sure the PR gets merged. 8. Run [ODH CodeFlare Operator release workflow](https://github.com/opendatahub-io/codeflare-operator/actions/workflows/odh-release.yml) to produce ODH CodeFlare Operator release. +9. Ensure that the version details in the `config/component_metadata.yaml` file are updated to reflect the latest upstream CodeFlare Operator release version ### Releases involving part of the stack diff --git a/config/component_metadata.yaml b/config/component_metadata.yaml new file mode 100644 index 000000000..61be7369b --- /dev/null +++ b/config/component_metadata.yaml @@ -0,0 +1,4 @@ +releases: + - name: CodeFlare operator + version: 1.15.0 + repoUrl: https://github.com/project-codeflare/codeflare-operator diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 74cfe3139..a4db4f0c9 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -1,5 +1,5 @@ # Adds namespace to all resources. -namespace: openshift-operators +namespace: opendatahub # Value of this field is prepended to the # names of all resources, e.g. a deployment named diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 20a34fe9d..14f62ad48 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -1,8 +1,3 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: system ---- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/config/manager/params.yaml b/config/manager/params.yaml index 43509ff29..4d4bd9d60 100644 --- a/config/manager/params.yaml +++ b/config/manager/params.yaml @@ -1,3 +1,5 @@ varReference: + - path: subjects[]/namespace + kind: ClusterRoleBinding - path: spec/template/spec/containers[]/image kind: Deployment diff --git a/config/odh-operator/kustomization.yaml b/config/odh-operator/kustomization.yaml new file mode 100644 index 000000000..02358bd9f --- /dev/null +++ b/config/odh-operator/kustomization.yaml @@ -0,0 +1,2 @@ +resources: +- odh.yaml diff --git a/config/odh-operator/odh.yaml b/config/odh-operator/odh.yaml new file mode 100644 index 000000000..6f7521595 --- /dev/null +++ b/config/odh-operator/odh.yaml @@ -0,0 +1,13 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: opendatahub-operator + labels: + operators.coreos.com/opendatahub-operator.openshift-operators: '' + namespace: openshift-operators +spec: + channel: fast + name: opendatahub-operator + installPlanApproval: Automatic + source: community-operators + sourceNamespace: openshift-marketplace diff --git a/contrib/configuration/basic-dsc.yaml b/contrib/configuration/basic-dsc.yaml new file mode 100644 index 000000000..9a0c2bccc --- /dev/null +++ b/contrib/configuration/basic-dsc.yaml @@ -0,0 +1,33 @@ +apiVersion: datasciencecluster.opendatahub.io/v1 +kind: DataScienceCluster +metadata: + labels: + app.kubernetes.io/created-by: opendatahub-operator + app.kubernetes.io/instance: default + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: datasciencecluster + app.kubernetes.io/part-of: opendatahub-operator + name: default-dsc +spec: + components: + codeflare: + devFlags: + manifests: + - uri: '' + contextDir: 'config' + sourcePath: 'default' + managementState: Managed + dashboard: + managementState: Managed + datasciencepipelines: + managementState: Removed + kserve: + managementState: Removed + kueue: + managementState: Managed + modelmeshserving: + managementState: Removed + ray: + managementState: Managed + workbenches: + managementState: Managed