Skip to content

Commit

Permalink
deploy: update kustomize + remove patch file workaround
Browse files Browse the repository at this point in the history
This allows us to remove the workaround for patch files because
kubernetes-sigs/kustomize#998 added support
for loading patch files outside of the root.

While at it, this fixes two things:
- incorrect comment (Go 1.11 already had good enough module support)
- dependencies were to complicated and prevented rebuilding files
  when changing the kustomize version
  • Loading branch information
pohly committed May 2, 2019
1 parent 8643040 commit 7dc6821
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
41 changes: 14 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,24 @@ include test/clear-kvm.make
include test/start-stop.make
include test/test.make


# Build kustomize at a certain revision. Depends on go >= 1.11
# because we use module support.
KUSTOMIZE_VERSION=e42933ec54ce9a65f65e125a1ccf482927f0e515
_work/kustomize-$(KUSTOMIZE_VERSION):
tmpdir=`mktemp -d` && \
trap 'rm -r $$tmpdir' EXIT && \
cd $$tmpdir && \
echo "module foo" >go.mod && \
go get sigs.k8s.io/kustomize@$(KUSTOMIZE_VERSION) && \
go build -o $(abspath $@) sigs.k8s.io/kustomize
ln -sf $(@F) _work/kustomize

# We generate deployment files with kustomize and include the output
# in the git repo because not all users will have kustomize or it
# might be an unsuitable version. When any file changes, update the
# output.
KUSTOMIZE_INPUT := $(shell find deploy/kustomize -type f)

# Workaround for https://github.com/kubernetes-sigs/kustomize/issues/937:
# we have to copy patch files into targets instead of referencing
# with a relative path to the parent directory.
KUSTOMIZE_INPUT += deploy/kustomize/kubernetes-1.13-lvm-testing/controller-socat-patch.yaml
KUSTOMIZE_INPUT += deploy/kustomize/kubernetes-1.13-direct-testing/controller-socat-patch.yaml
deploy/kustomize/kubernetes-%/controller-socat-patch.yaml: deploy/kustomize/testing/controller-socat-patch.yaml
cp $< $@

# Output files and their corresponding kustomize target.
KUSTOMIZE_OUTPUT :=
KUSTOMIZE_OUTPUT += deploy/kubernetes-1.13/pmem-csi-direct.yaml
Expand All @@ -117,29 +119,14 @@ KUSTOMIZATION_deploy/kubernetes-1.13/pmem-storageclass-xfs.yaml = deploy/kustomi
KUSTOMIZE_OUTPUT += deploy/kubernetes-1.13/pmem-storageclass-cache.yaml
KUSTOMIZATION_deploy/kubernetes-1.13/pmem-storageclass-cache.yaml = deploy/kustomize/storageclass-cache
kustomize: $(KUSTOMIZE_OUTPUT)
$(KUSTOMIZE_OUTPUT): _work/kustomize $(KUSTOMIZE_INPUT)
$< build $(KUSTOMIZATION_$@) >$@


# Build kustomize at a certain revision. Depends on go >= 1.12
# because we use module support.
KUSTOMIZE_VERSION=177297c0efb92ec2d7eea8f20c65c1d11c6ae7ef
_work/kustomize: _work/.kustomize-$(KUSTOMIZE_VERSION)-stamp
_work/.kustomize-$(KUSTOMIZE_VERSION)-stamp:
tmpdir=`mktemp -d` && \
trap 'rm -r $$tmpdir' EXIT && \
cd $$tmpdir && \
echo "module foo" >go.mod && \
go get sigs.k8s.io/kustomize@$(KUSTOMIZE_VERSION) && \
go build -o $(abspath _work/kustomize) sigs.k8s.io/kustomize && \
touch --reference=$(abspath _work/kustomize) $(abspath $@)
$(KUSTOMIZE_OUTPUT): _work/kustomize-$(KUSTOMIZE_VERSION) $(KUSTOMIZE_INPUT)
$< build --load_restrictor none $(KUSTOMIZATION_$@) >$@

PHONY: clean-kustomize
clean: clean-kustomize
clean-kustomize:
rm -f _work/kustomize-*
rm -f _work/kustomize
rm -f _work/.kustomize-$(KUSTOMIZE_VERSION)-stamp
rm -f deploy/kustomize/kubernetes-*/controller-socat-patch.yaml

PHONY: test-kustomize $(addprefix test-kustomize-,$(KUSTOMIZE_OUTPUT))
test: test-kustomize
Expand Down
3 changes: 0 additions & 3 deletions deploy/kustomize/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ patchesJson6902:
version: v1
kind: StatefulSet
name: pmem-csi-controller
path: controller-socat-patch.yaml
path: ../testing/controller-socat-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ patchesJson6902:
version: v1
kind: StatefulSet
name: pmem-csi-controller
path: controller-socat-patch.yaml
path: ../testing/controller-socat-patch.yaml
4 changes: 1 addition & 3 deletions deploy/kustomize/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ forwarding to the outside world:
The pmem-csi-controller-testing Service exposes the PMEM-CSI controller's
csi.sock as a TCP service with a dynamically allocated port, on any
node of the cluster. For this to work, the pmem-csi-controller has
to be patched with the controller-socat-patch.yaml. Due to
https://github.com/kubernetes-sigs/kustomize/issues/937, that file has to
be duplicated in the repo.
to be patched with the controller-socat-patch.yaml.

The pmem-csi-node-testing DaemonSet forwards
/var/lib/kubelet/plugins/pmem-csi.intel.com/csi.sock on all nodes,
Expand Down

0 comments on commit 7dc6821

Please sign in to comment.