Skip to content

Commit a553313

Browse files
authored
Release Install script (#157)
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 a85307e commit a553313

File tree

4 files changed

+61
-25
lines changed

4 files changed

+61
-25
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: 10 additions & 16 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

@@ -100,7 +101,7 @@ build: manifests generate fmt vet goreleaser ## Build manager binary using gorel
100101
${GORELEASER} build ${GORELEASER_ARGS} --single-target -o bin/manager
101102

102103
.PHONY: run
103-
run: docker-build kind-cluster kind-load cert-mgr rukpak install deploy wait ## Build the operator-controller then deploy it into a new kind cluster.
104+
run: docker-build kind-cluster kind-load install ## Build the operator-controller then deploy it into a new kind cluster.
104105

105106
.PHONY: wait
106107
wait:
@@ -138,34 +139,27 @@ 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: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
148+
quickstart: kustomize generate ## Generate the installation release manifests and scripts
147149
kubectl kustomize config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
150+
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
148151

149152
##@ Deployment
150153

151154
ifndef ignore-not-found
152155
ignore-not-found = false
153156
endif
154157

155-
## TODO dfranz: replace cert-mgr and rukpak targets with our chosen method of distribution when available
156-
.PHONY: cert-mgr
157-
cert-mgr: ## Install cert-manager
158-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml
159-
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=$(WAIT_TIMEOUT)
160-
161-
.PHONY: rukpak
162-
rukpak: ## Install rukpak
163-
kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml
164-
kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=$(WAIT_TIMEOUT)
165-
166158
.PHONY: install
167-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
168-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
159+
install: export MANIFEST="./operator-controller.yaml"
160+
install: manifests kustomize generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
161+
kubectl kustomize config/default > operator-controller.yaml
162+
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
169163

170164
.PHONY: uninstall
171165
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.

scripts/install.tpl.sh

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

0 commit comments

Comments
 (0)