diff --git a/Makefile b/Makefile index 1e3e053f6b..2d326ac770 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,17 @@ 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 @@ -92,14 +102,6 @@ include test/test.make # 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 @@ -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 diff --git a/deploy/kustomize/.gitignore b/deploy/kustomize/.gitignore deleted file mode 100644 index b8feda18f7..0000000000 --- a/deploy/kustomize/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# make copies these files because of -# https://github.com/kubernetes-sigs/kustomize/issues/937 -/kubernetes-*/controller-socat-patch.yaml diff --git a/deploy/kustomize/kubernetes-1.13-direct-testing/kustomization.yaml b/deploy/kustomize/kubernetes-1.13-direct-testing/kustomization.yaml index 4883442068..7b13d89c88 100644 --- a/deploy/kustomize/kubernetes-1.13-direct-testing/kustomization.yaml +++ b/deploy/kustomize/kubernetes-1.13-direct-testing/kustomization.yaml @@ -8,4 +8,4 @@ patchesJson6902: version: v1 kind: StatefulSet name: pmem-csi-controller - path: controller-socat-patch.yaml + path: ../testing/controller-socat-patch.yaml diff --git a/deploy/kustomize/kubernetes-1.13-lvm-testing/kustomization.yaml b/deploy/kustomize/kubernetes-1.13-lvm-testing/kustomization.yaml index ae29330d0d..05b0a616fa 100644 --- a/deploy/kustomize/kubernetes-1.13-lvm-testing/kustomization.yaml +++ b/deploy/kustomize/kubernetes-1.13-lvm-testing/kustomization.yaml @@ -8,4 +8,4 @@ patchesJson6902: version: v1 kind: StatefulSet name: pmem-csi-controller - path: controller-socat-patch.yaml + path: ../testing/controller-socat-patch.yaml diff --git a/deploy/kustomize/testing/README.md b/deploy/kustomize/testing/README.md index a951795581..b2adf1d3b6 100644 --- a/deploy/kustomize/testing/README.md +++ b/deploy/kustomize/testing/README.md @@ -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,