diff --git a/.gitignore b/.gitignore index 56a86e3a4..e48b81835 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ Dockerfile.cross # Release output dist/** operator-controller.yaml +install.sh # Kubernetes Generated files - skip generated files, except for vendored files diff --git a/.goreleaser.yml b/.goreleaser.yml index 7645897ee..197c6cb84 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -59,17 +59,10 @@ release: disable: '{{ ne .Env.ENABLE_RELEASE_PIPELINE "true" }}' extra_files: - glob: 'operator-controller.yaml' + - glob: 'install.sh' header: | ## Installation ```bash - curl -L -s https://github.com/operator-framework/operator-lifecycle-manager/releases/download/{{ .Env.OLM_V0_VERSION }}/install.sh | bash -s {{ .Env.OLM_V0_VERSION }} - kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/{{ .Env.CERT_MGR_VERSION }}/cert-manager.yaml - kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s - kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml - kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=60s - kubectl wait --for=condition=Available --namespace=rukpak-system deployment/helm-provisioner --timeout=60s - kubectl wait --for=condition=Available --namespace=rukpak-system deployment/rukpak-webhooks --timeout=60s - kubectl apply -f https://github.com/operator-framework/operator-controller/releases/download/{{ .Tag }}/operator-controller.yaml - kubectl wait --for=condition=Available --namespace=operator-controller-system deployment/operator-controller-controller-manager --timeout=60s + curl -L -s https://github.com/operator-framework/operator-controller/releases/download/{{ .Tag }}/install.sh | bash -s ``` diff --git a/Makefile b/Makefile index 816a7bdd1..3e6aa12da 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ export GO_BUILD_TAGS ?= upstream export CERT_MGR_VERSION ?= v1.9.0 export GORELEASER_VERSION ?= v1.16.2 export OLM_V0_VERSION ?= v0.24.0 +export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak) export WAIT_TIMEOUT ?= 60s IMG?=$(IMAGE_REPO):$(IMAGE_TAG) @@ -138,13 +139,14 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla ##@ Release: export ENABLE_RELEASE_PIPELINE ?= false export GORELEASER_ARGS ?= --snapshot --clean +export VERSION ?= $(shell git describe --abbrev=0 --tags) release: goreleaser ## Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release. $(GORELEASER) $(GORELEASER_ARGS) -quickstart: VERSION ?= $(shell git describe --abbrev=0 --tags) -quickstart: kustomize generate ## Generate the installation release manifests +quickstart: kustomize generate ## Generate the installation release manifests and scripts kubectl kustomize config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml + envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$VERSION' < scripts/install.tpl.sh > install.sh ##@ Deployment @@ -160,7 +162,7 @@ cert-mgr: ## Install cert-manager .PHONY: rukpak rukpak: ## Install rukpak - kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml + kubectl apply -f https://github.com/operator-framework/rukpak/releases/download/$(RUKPAK_VERSION)/rukpak.yaml kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=$(WAIT_TIMEOUT) .PHONY: install diff --git a/scripts/install.tpl.sh b/scripts/install.tpl.sh new file mode 100644 index 000000000..23a45040c --- /dev/null +++ b/scripts/install.tpl.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +olm_version=$OLM_V0_VERSION +cert_mgr_version=$CERT_MGR_VERSION +rukpak_version=$RUKPAK_VERSION +operator_controller_version=$VERSION + +if [[ -z "$olm_version" || -z "$cert_mgr_version" || -z "$rukpak_version" || -z "$operator_controller_version" ]]; then + err="Error: Missing component version(s) for: " + if [[ -z "$olm_version" ]]; then + err+="operator-lifecycle-manager " + fi + if [[ -z "$cert_mgr_version" ]]; then + err+="cert-manager " + fi + if [[ -z "$rukpak_version" ]]; then + err+="rukpak " + fi + if [[ -z "$operator_controller_version" ]]; then + err+="operator-controller" + fi + echo $err + exit 1 +fi + +function kubectl_wait() { + namespace=$1 + runtime=$2 + timeout=$3 + + kubectl wait --for=condition=Available --namespace="${namespace}" "${runtime}" --timeout="${timeout}" +} + +curl -L -s "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${olm_version}/install.sh" | bash -s "${olm_version}" + +kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/${cert_mgr_version}/cert-manager.yaml" +kubectl_wait "cert-manager" "deployment/cert-manager-webhook" "60s" + +kubectl apply -f "https://github.com/operator-framework/rukpak/releases/download/${rukpak_version}/rukpak.yaml" +kubectl_wait "rukpak-system" "deployment/core" "60s" +kubectl_wait "rukpak-system" "deployment/helm-provisioner" "60s" +kubectl_wait "rukpak-system" "deployment/rukpak-webhooks" "60s" + +kubectl apply -f "https://github.com/operator-framework/operator-controller/releases/download/${operator_controller_version}/operator-controller.yaml" +kubectl_wait "operator-controller-system" "deployment/operator-controller-controller-manager" "60s"