Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Install script #157

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```
26 changes: 10 additions & 16 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)
awgreene marked this conversation as resolved.
Show resolved Hide resolved
export WAIT_TIMEOUT ?= 60s
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)

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

.PHONY: run
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.
run: docker-build kind-cluster kind-load install ## Build the operator-controller then deploy it into a new kind cluster.

.PHONY: wait
wait:
Expand Down Expand Up @@ -138,34 +139,27 @@ 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: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
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,$$MANIFEST' < scripts/install.tpl.sh > install.sh

##@ Deployment

ifndef ignore-not-found
ignore-not-found = false
endif

## TODO dfranz: replace cert-mgr and rukpak targets with our chosen method of distribution when available
.PHONY: cert-mgr
cert-mgr: ## Install cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=$(WAIT_TIMEOUT)

.PHONY: rukpak
rukpak: ## Install rukpak
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=$(WAIT_TIMEOUT)

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -
install: export MANIFEST="./operator-controller.yaml"
install: manifests kustomize generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
kubectl kustomize config/default > operator-controller.yaml
envsubst '$$OLM_V0_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s

.PHONY: uninstall
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.
Expand Down
48 changes: 48 additions & 0 deletions scripts/install.tpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

operator_controller_manifest=$MANIFEST

if [[ -z "$operator_controller_manifest" ]]; then
echo "Error: Missing required MANIFEST variable"
exit 1
fi

olm_version=$OLM_V0_VERSION
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are "supposed" to be set from the envsubst command in the makefile's quickstart target but I added some simple checks just in case.

cert_mgr_version=$CERT_MGR_VERSION
rukpak_version=$RUKPAK_VERSION

if [[ -z "$olm_version" || -z "$cert_mgr_version" || -z "$rukpak_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 "
awgreene marked this conversation as resolved.
Show resolved Hide resolved
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 "${operator_controller_manifest}"
kubectl_wait "operator-controller-system" "deployment/operator-controller-controller-manager" "60s"