Skip to content

Commit

Permalink
add image pull secret name variable to makefile (#359)
Browse files Browse the repository at this point in the history
* add image pull secret name to makefile

* add kustomize command to the deploy makefile target

* add image_pull_secret_name to docs

* move image pull secrets patch further up in makefile
  • Loading branch information
j1m-ryan authored Aug 13, 2024
1 parent 81338d9 commit 72c75ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ KRP_IMAGE_BASE ?= quay.io/brancz/kube-rbac-proxy
# kube-rbac-proxy image tag
KRP_IMAGE_TAG ?= v0.18.0

# image pull secret name: eg regcred
IMAGE_PULL_SECRET_NAME ?=

image_pull_secrets_patch = $(shell printf '[{"op":"add","path":"/spec/template/spec/imagePullSecrets","value":[{"name":"%s"}]}]' '$(strip $(IMAGE_PULL_SECRET_NAME))' )


.PHONY: all
all: docker-build

Expand Down Expand Up @@ -125,6 +131,7 @@ uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/default && $(KUSTOMIZE) edit set image kube-rbac-proxy=$(KRP_IMAGE_BASE):$(KRP_IMAGE_TAG)
if [ -n "$(IMAGE_PULL_SECRET_NAME)" ]; then cd config/default && $(KUSTOMIZE) edit add patch --kind Deployment --group apps --version v1 --name controller-manager --patch '${image_pull_secrets_patch}'; fi
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
Expand Down Expand Up @@ -188,6 +195,7 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
cd config/manifests/bases && $(KUSTOMIZE) edit set annotation containerImage:$(IMG)
cd config/default && $(KUSTOMIZE) edit set image kube-rbac-proxy=$(KRP_IMAGE_BASE):$(KRP_IMAGE_TAG)
if [ -n "$(IMAGE_PULL_SECRET_NAME)" ]; then cd config/default && $(KUSTOMIZE) edit add patch --kind Deployment --group apps --version v1 --name controller-manager --patch '${image_pull_secrets_patch}'; fi
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
@printf "%s\n" '' 'LABEL com.redhat.openshift.versions="v4.12"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile
@printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: v4.12' >> bundle/metadata/annotations.yaml
Expand Down Expand Up @@ -240,3 +248,4 @@ catalog-build: opm ## Build a catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

3 changes: 2 additions & 1 deletion docs/manual-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ You can use the operator (including the kube-rbac-proxy) images from your own pr
```shell
make deploy IMG=<my-private-registry>/nginx-ingress-operator:2.3.1 KRP_IMAGE_BASE=<my-private-registry>/kube-rbac-proxy
```
**Note: If you need to use a different `kube-rbac-proxy` version than the default, use the `KRP_IMAGE_TAG` variable**
**Note: If you need to use a different `kube-rbac-proxy` version than the default, use the `KRP_IMAGE_TAG` variable**
**Note: To use an image pull secret, you can specify the IMAGE_PULL_SECRET_NAME variable, eg IMAGE_PULL_SECRET_NAME=regcred**

0 comments on commit 72c75ca

Please sign in to comment.