Skip to content

Commit

Permalink
Release Install Script
Browse files Browse the repository at this point in the history
Adds an install script which installs the required sub-components of OLM v1 in a single command. The install script is built on-the-fly when the release is run, and the appropriate versions of all sub-components are set inside the Makefile or grabbed from the go.mod file.

Signed-off-by: dtfranz <dfranz@redhat.com>
  • Loading branch information
dtfranz committed Apr 4, 2023
1 parent 8288ac0 commit 0dd7acc
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Dockerfile.cross
# Release output
dist/**
operator-controller.yaml
install.sh

# Kubernetes Generated files - skip generated files, except for vendored files

Expand Down
11 changes: 2 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
45 changes: 45 additions & 0 deletions scripts/install.tpl.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 0dd7acc

Please sign in to comment.