|
| 1 | +version: '3' |
| 2 | + |
| 3 | +includes: |
| 4 | + tools: |
| 5 | + taskfile: .taskfile.tools.yaml |
| 6 | + internal: true |
| 7 | + |
| 8 | +vars: |
| 9 | + BIN: "{{.ROOT_DIR}}/bin" |
| 10 | + OPERATOR_CONTROLLER_MANIFEST: ./operator-controller.yaml |
| 11 | + |
| 12 | + OLMV0_VERSION: v0.24.0 |
| 13 | + CERT_MANAGER_VERSION: v1.9.0 |
| 14 | + RUKPAK_VERSION: v0.11.0 |
| 15 | + |
| 16 | +env: |
| 17 | + IMAGE_REPO: quay.io/operator-framework/operator-controller |
| 18 | + IMAGE_TAG: devel |
| 19 | + |
| 20 | +tasks: |
| 21 | + generate: |
| 22 | + desc: "Run code generation" |
| 23 | + summary: | |
| 24 | + This task runs go generate and controller-gen to generate code, CRDs, |
| 25 | + webhook configurations, and RBAC manifests. |
| 26 | + cmds: |
| 27 | + - go generate ./... |
| 28 | + - "{{.TOOLSBIN}}/controller-gen object:headerFile=hack/boilerplate.go.txt paths=./..." |
| 29 | + - "{{.TOOLSBIN}}/controller-gen rbac:roleName=manager-role crd webhook paths=./... output:crd:artifacts:config=config/crd/bases" |
| 30 | + deps: [tools:controller-gen] |
| 31 | + |
| 32 | + binary: |
| 33 | + desc: "Build the binaries for the current OS" |
| 34 | + summary: | |
| 35 | + This task uses goreleaser to build the operator binary based on GOOS and GOARCH. |
| 36 | + By default, the binary is created at ./bin/manager. |
| 37 | + |
| 38 | + To generate the binary for a different OS, set the GOOS task variable accordingly. |
| 39 | + cmds: |
| 40 | + - mkdir -p {{.BIN}} |
| 41 | + - GOOS={{.GOOS}} {{.TOOLSBIN}}/goreleaser build --single-target --snapshot --clean --output {{.BIN}}/manager |
| 42 | + deps: [tools:goreleaser, generate] |
| 43 | + |
| 44 | + docker: |
| 45 | + desc: "Build the docker image" |
| 46 | + summary: | |
| 47 | + This task builds the operator's linux binary in {{.BIN}}/linux and then uses |
| 48 | + the Dockerfile to build the docker image in {{.BIN}}/linux. |
| 49 | + |
| 50 | + GOARCH is taken from the environment to ensure a binary that will run on the local |
| 51 | + machine. GOOS is always set to `linux` for the docker build. |
| 52 | + |
| 53 | + By default, the image is tagged as quay.io/operator-framework/operator-controller:devel. |
| 54 | + You can control the image repo and tag by setting the IMAGE_REPO and IMAGE_TAG |
| 55 | + environment variables. |
| 56 | + cmds: |
| 57 | + - docker build -f Dockerfile -t $IMAGE_REPO:$IMAGE_TAG bin/linux |
| 58 | + deps: |
| 59 | + - task: binary |
| 60 | + vars: |
| 61 | + BIN: "{{.ROOT_DIR}}/bin/linux" |
| 62 | + GOOS: linux |
| 63 | + |
| 64 | + manifest: |
| 65 | + desc: "Generate the operator manifest" |
| 66 | + summary: | |
| 67 | + This task uses kustomize to generate the operator manifest. |
| 68 | + |
| 69 | + The operator manifest is generated by combining the CRD and default manifests |
| 70 | + with the controller image set to the IMAGE_REPO and IMAGE_TAG environment variables. |
| 71 | + cmds: |
| 72 | + - cd config/manager && {{.TOOLSBIN}}/kustomize edit set image controller=$IMAGE_REPO:$IMAGE_TAG |
| 73 | + - "{{.TOOLSBIN}}/kustomize build config/default > ./operator-controller.yaml" |
| 74 | + deps: [tools:kustomize, generate] |
| 75 | + |
| 76 | + install-script: |
| 77 | + desc: "Generate the install script" |
| 78 | + summary: | |
| 79 | + This task generates the install script that can be used to install the operator. |
| 80 | + |
| 81 | + The OPERATOR_CONTROLLER_MANIFEST task variable is used to set the location that |
| 82 | + will be used to `kubectl apply -f` the operator-controller manifest. By default, |
| 83 | + this is set to `./operator-controller.yaml`. However this can be overridden during |
| 84 | + a release to reference the release manifest URL that is uploaded to GitHub during |
| 85 | + the release. |
| 86 | + silent: true |
| 87 | + cmds: |
| 88 | + - | |
| 89 | + cat << EOF > ./install.sh |
| 90 | + #!/usr/bin/env bash |
| 91 | + set -o pipefail -o errexit -o nounset |
| 92 | +
|
| 93 | + # Install OLMv0 |
| 94 | + curl -L -s https://github.com/operator-framework/operator-lifecycle-manager/releases/download/{{.OLMV0_VERSION}}/install.sh | bash -s {{.OLMV0_VERSION}} |
| 95 | +
|
| 96 | + # Install cert-manager |
| 97 | + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/{{.CERT_MANAGER_VERSION}}/cert-manager.yaml |
| 98 | + kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s |
| 99 | +
|
| 100 | + # Install rukpak |
| 101 | + kubectl apply -f https://github.com/operator-framework/rukpak/releases/download/{{.RUKPAK_VERSION}}/rukpak.yaml |
| 102 | + kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=60s |
| 103 | + kubectl wait --for=condition=Available --namespace=rukpak-system deployment/helm-provisioner --timeout=60s |
| 104 | + kubectl wait --for=condition=Available --namespace=rukpak-system deployment/rukpak-webhooks --timeout=60s |
| 105 | + kubectl wait --for=condition=Available --namespace=crdvalidator-system deployment/crd-validation-webhook --timeout=60s |
| 106 | +
|
| 107 | + # Install operator-controller |
| 108 | + kubectl apply -f {{.OPERATOR_CONTROLLER_MANIFEST}} |
| 109 | + kubectl wait --for=condition=Available --namespace=operator-controller-system deployment/operator-controller-controller-manager --timeout=60s |
| 110 | + EOF |
| 111 | + - chmod +x ./install.sh |
0 commit comments