Skip to content

Commit 0dd7acc

Browse files
committed
Release Install Script
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 <[email protected]>
1 parent 8288ac0 commit 0dd7acc

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Dockerfile.cross
1919
# Release output
2020
dist/**
2121
operator-controller.yaml
22+
install.sh
2223

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

.goreleaser.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,10 @@ release:
5959
disable: '{{ ne .Env.ENABLE_RELEASE_PIPELINE "true" }}'
6060
extra_files:
6161
- glob: 'operator-controller.yaml'
62+
- glob: 'install.sh'
6263
header: |
6364
## Installation
6465
6566
```bash
66-
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 }}
67-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/{{ .Env.CERT_MGR_VERSION }}/cert-manager.yaml
68-
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s
69-
kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml
70-
kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=60s
71-
kubectl wait --for=condition=Available --namespace=rukpak-system deployment/helm-provisioner --timeout=60s
72-
kubectl wait --for=condition=Available --namespace=rukpak-system deployment/rukpak-webhooks --timeout=60s
73-
kubectl apply -f https://github.com/operator-framework/operator-controller/releases/download/{{ .Tag }}/operator-controller.yaml
74-
kubectl wait --for=condition=Available --namespace=operator-controller-system deployment/operator-controller-controller-manager --timeout=60s
67+
curl -L -s https://github.com/operator-framework/operator-controller/releases/download/{{ .Tag }}/install.sh | bash -s
7568
```

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export GO_BUILD_TAGS ?= upstream
88
export CERT_MGR_VERSION ?= v1.9.0
99
export GORELEASER_VERSION ?= v1.16.2
1010
export OLM_V0_VERSION ?= v0.24.0
11+
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
1112
export WAIT_TIMEOUT ?= 60s
1213
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
1314

@@ -138,13 +139,14 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla
138139
##@ Release:
139140
export ENABLE_RELEASE_PIPELINE ?= false
140141
export GORELEASER_ARGS ?= --snapshot --clean
142+
export VERSION ?= $(shell git describe --abbrev=0 --tags)
141143

142144
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.
143145
$(GORELEASER) $(GORELEASER_ARGS)
144146

145-
quickstart: VERSION ?= $(shell git describe --abbrev=0 --tags)
146-
quickstart: kustomize generate ## Generate the installation release manifests
147+
quickstart: kustomize generate ## Generate the installation release manifests and scripts
147148
kubectl kustomize config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
149+
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$VERSION' < scripts/install.tpl.sh > install.sh
148150

149151
##@ Deployment
150152

@@ -160,7 +162,7 @@ cert-mgr: ## Install cert-manager
160162

161163
.PHONY: rukpak
162164
rukpak: ## Install rukpak
163-
kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml
165+
kubectl apply -f https://github.com/operator-framework/rukpak/releases/download/$(RUKPAK_VERSION)/rukpak.yaml
164166
kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=$(WAIT_TIMEOUT)
165167

166168
.PHONY: install

scripts/install.tpl.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
olm_version=$OLM_V0_VERSION
4+
cert_mgr_version=$CERT_MGR_VERSION
5+
rukpak_version=$RUKPAK_VERSION
6+
operator_controller_version=$VERSION
7+
8+
if [[ -z "$olm_version" || -z "$cert_mgr_version" || -z "$rukpak_version" || -z "$operator_controller_version" ]]; then
9+
err="Error: Missing component version(s) for: "
10+
if [[ -z "$olm_version" ]]; then
11+
err+="operator-lifecycle-manager "
12+
fi
13+
if [[ -z "$cert_mgr_version" ]]; then
14+
err+="cert-manager "
15+
fi
16+
if [[ -z "$rukpak_version" ]]; then
17+
err+="rukpak "
18+
fi
19+
if [[ -z "$operator_controller_version" ]]; then
20+
err+="operator-controller"
21+
fi
22+
echo $err
23+
exit 1
24+
fi
25+
26+
function kubectl_wait() {
27+
namespace=$1
28+
runtime=$2
29+
timeout=$3
30+
31+
kubectl wait --for=condition=Available --namespace="${namespace}" "${runtime}" --timeout="${timeout}"
32+
}
33+
34+
curl -L -s "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${olm_version}/install.sh" | bash -s "${olm_version}"
35+
36+
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/${cert_mgr_version}/cert-manager.yaml"
37+
kubectl_wait "cert-manager" "deployment/cert-manager-webhook" "60s"
38+
39+
kubectl apply -f "https://github.com/operator-framework/rukpak/releases/download/${rukpak_version}/rukpak.yaml"
40+
kubectl_wait "rukpak-system" "deployment/core" "60s"
41+
kubectl_wait "rukpak-system" "deployment/helm-provisioner" "60s"
42+
kubectl_wait "rukpak-system" "deployment/rukpak-webhooks" "60s"
43+
44+
kubectl apply -f "https://github.com/operator-framework/operator-controller/releases/download/${operator_controller_version}/operator-controller.yaml"
45+
kubectl_wait "operator-controller-system" "deployment/operator-controller-controller-manager" "60s"

0 commit comments

Comments
 (0)