Skip to content

Commit ebe2b08

Browse files
committed
✨ (go/v4): Allows kubectl to be configured in Makefile
- This allows multiple different kubectl installs to be used. Signed-off-by: Gabe Alford <[email protected]>
1 parent a6fca17 commit ebe2b08

File tree

9 files changed

+45
-36
lines changed

9 files changed

+45
-36
lines changed

docs/book/src/component-config-tutorial/testdata/project/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

docs/book/src/cronjob-tutorial/testdata/project/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,20 @@ endif
174174
175175
.PHONY: install
176176
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
177-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
177+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
178178
179179
.PHONY: uninstall
180180
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.
181-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
181+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
182182
183183
.PHONY: deploy
184184
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
185185
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
186-
$(KUSTOMIZE) build config/default | kubectl apply -f -
186+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
187187
188188
.PHONY: undeploy
189189
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
190-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
190+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
191191
192192
##@ Build Dependencies
193193
@@ -197,6 +197,7 @@ $(LOCALBIN):
197197
mkdir -p $(LOCALBIN)
198198
199199
## Tool Binaries
200+
KUBECTL ?= kubectl
200201
KUSTOMIZE ?= $(LOCALBIN)/kustomize
201202
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
202203
ENVTEST ?= $(LOCALBIN)/setup-envtest

testdata/project-v4-config/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

testdata/project-v4-declarative-v1/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

testdata/project-v4-multigroup/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

testdata/project-v4-with-deploy-image/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

testdata/project-v4-with-grafana/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

testdata/project-v4/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ endif
110110

111111
.PHONY: install
112112
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
113-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
113+
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
114114

115115
.PHONY: uninstall
116116
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.
117-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
117+
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
118118

119119
.PHONY: deploy
120120
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
121121
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
122-
$(KUSTOMIZE) build config/default | kubectl apply -f -
122+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
123123

124124
.PHONY: undeploy
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
126+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128128
##@ Build Dependencies
129129

@@ -133,6 +133,7 @@ $(LOCALBIN):
133133
mkdir -p $(LOCALBIN)
134134

135135
## Tool Binaries
136+
KUBECTL ?= kubectl
136137
KUSTOMIZE ?= $(LOCALBIN)/kustomize
137138
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
138139
ENVTEST ?= $(LOCALBIN)/setup-envtest

0 commit comments

Comments
 (0)