Skip to content

Commit

Permalink
kube: Rework k8s release manifests
Browse files Browse the repository at this point in the history
We shouldn't be patching a git tracked file as part of the build because
then we'd have to go back and checkout the changes. Unfortunately this means
we need to copy the whole directory tree so that kustomize will pick up the
edited files.

I also fixed a typo that used the TINK_SERVER_IMAGE_NAME for the manager.

I also cleaned up the recursive uses of make since they are considered
harmful and dropped `release` as that should be for the whole project not
just the k8s manifests.

Signed-off-by: Manuel Mendez <[email protected]>
  • Loading branch information
mmlb committed May 3, 2022
1 parent 0941c5a commit d303dc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
4 changes: 2 additions & 2 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ bases:
- ../server-rbac

patchesStrategicMerge:
- manager_image_patch.yaml
- server_image_patch.yaml
- manager_image.yaml
- server_image.yaml
File renamed without changes.
File renamed without changes.
39 changes: 14 additions & 25 deletions kube.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,26 @@ generate-server-rbacs: bin/controller-gen
rbac:roleName=server-role
prettier --write ./config/server-rbac/

RELEASE_DIR ?= out/release

$(RELEASE_DIR):
mkdir -p $(RELEASE_DIR)/

REGISTRY ?= quay.io/tinkerbell
TINK_SERVER_IMAGE_NAME ?= tink-server
TINK_CONTROLLER_IMAGE_NAME ?= tink-controller
TINK_SERVER_IMAGE_TAG ?= latest
TINK_CONTROLLER_IMAGE_TAG ?= latest

.PHONY: set-manager-manifest-image
set-manager-manifest-image:
$(info Updating kustomize image patch file for tink-controller)
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/default/manager_image_patch.yaml

.PHONY: set-server-manifest-image
set-server-manifest-image:
$(info Updating kustomize image patch file for tink-server)
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/default/server_image_patch.yaml
out/release/default/manager_image.yaml: config/default/manager_image.yaml out/release/default/kustomization.yaml
out/release/default/manager_image.yaml: TAG=$(REGISTRY)/$(TINK_CONTROLLER_IMAGE_NAME):$(TINK_CONTROLLER_IMAGE_TAG)
out/release/default/server_image.yaml: config/default/server_image.yaml out/release/default/kustomization.yaml
out/release/default/server_image.yaml: TAG=$(REGISTRY)/$(TINK_SERVER_IMAGE_NAME):$(TINK_SERVER_IMAGE_TAG)
out/release/default/manager_image.yaml out/release/default/server_image.yaml:
sed -e 's|image: .*|image: "$(TAG)"|' $^ >$@

.PHONY: release
release: clean-release
$(MAKE) set-manager-manifest-image MANIFEST_IMG=$(REGISTRY)/$(TINK_SERVER_IMAGE_NAME) MANIFEST_TAG=$(TINK_CONTROLLER_IMAGE_TAG)
$(MAKE) set-server-manifest-image MANIFEST_IMG=$(REGISTRY)/$(TINK_SERVER_IMAGE_NAME) MANIFEST_TAG=$(TINK_SERVER_IMAGE_TAG)
$(MAKE) release-manifests
out/release/default/kustomization.yaml: config/default/kustomization.yaml
rm -rf out/
mkdir -p out/
cp -a config/ out/release/

.PHONY: release-manifests ## Builds the manifests to publish with a release.
release-manifests: bin/kustomize $(RELEASE_DIR)
kustomize build config/default > $(RELEASE_DIR)/tink.yaml
out/release/tink.yaml: bin/kustomize generate-manifests out/release/default/manager_image.yaml out/release/default/manager_image.yaml
kustomize build out/release/default -o $@
prettier --write $@

.PHONY: clean-release
clean-release: ## Remove the release folder
rm -rf $(RELEASE_DIR)
release-manifests: out/release/tink.yaml ## Builds the manifests to publish with a release.

0 comments on commit d303dc2

Please sign in to comment.