Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit 4381d13

Browse files
upgrade to use SDK 0.18 and fix the Makefile target to keep it aligned with kubebuider (#134)
1 parent d2c1fe1 commit 4381d13

7 files changed

Lines changed: 112 additions & 83 deletions

File tree

go/kubebuilder/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
10+
# Test binary, build with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Kubernetes Generated files - skip generated files, except for vendored files
17+
18+
!vendor/**/zz_generated.*
19+
20+
# editor and IDE paraphernalia
21+
.idea
22+
*.swp
23+
*.swo
24+
*~

go/kubebuilder/memcached-operator/Makefile

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
4-
# Namespace used for this example
5-
NAMESPACE=memcached-operator-system
64
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
75
CRD_OPTIONS ?= "crd:trivialVersions=true"
86

@@ -28,24 +26,23 @@ run: generate fmt vet manifests
2826
go run ./main.go
2927

3028
# Install CRDs into a cluster
31-
install: manifests
32-
kustomize build config/crd | kubectl apply -f -
29+
install: manifests kustomize
30+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
3331

3432
# Uninstall CRDs from a cluster
35-
uninstall: manifests
36-
@echo ....... Uninstalling .......
37-
kustomize build config/crd | kubectl delete -f -
38-
- kubectl delete deployments,service -l control-plane=controller-manager -n ${NAMESPACE}
39-
- kubectl delete role,rolebinding --all -n ${NAMESPACE}
40-
@echo ....... Deleting namespace ${NAMESPACE}.......
41-
- kubectl delete namespace ${NAMESPACE}
33+
uninstall: manifests kustomize
34+
$(KUSTOMIZE) build config/crd | kubectl delete -f -
4235

4336
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
44-
deploy: manifests
37+
deploy: manifests kustomize
4538
cd config/manager && kustomize edit set image controller=${IMG}
46-
kustomize build config/default | kubectl apply -f -
47-
- kubectl create -f config/samples/cache_v1alpha1_memcached.yaml -n ${NAMESPACE}
39+
$(KUSTOMIZE) build config/default | kubectl apply -f -
4840

41+
# UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config
42+
# Note that it was added for we are allowed to uninstall the files. However, it will be present by default in the future
43+
# versions.
44+
undeploy:
45+
$(KUSTOMIZE) build config/default | kubectl delete -f -
4946

5047
# Generate manifests e.g. CRD, RBAC etc.
5148
manifests: controller-gen
@@ -80,10 +77,25 @@ ifeq (, $(shell which controller-gen))
8077
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
8178
cd $$CONTROLLER_GEN_TMP_DIR ;\
8279
go mod init tmp ;\
83-
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
80+
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
8481
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
8582
}
8683
CONTROLLER_GEN=$(GOBIN)/controller-gen
8784
else
8885
CONTROLLER_GEN=$(shell which controller-gen)
8986
endif
87+
88+
kustomize:
89+
ifeq (, $(shell which kustomize))
90+
@{ \
91+
set -e ;\
92+
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
93+
cd $$KUSTOMIZE_GEN_TMP_DIR ;\
94+
go mod init tmp ;\
95+
go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\
96+
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
97+
}
98+
KUSTOMIZE=$(GOBIN)/kustomize
99+
else
100+
KUSTOMIZE=$(shell which kustomize)
101+
endif

go/kubebuilder/memcached-operator/config/crd/bases/cache.example.com_memcacheds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.2.5
7+
controller-gen.kubebuilder.io/version: v0.3.0
88
creationTimestamp: null
99
name: memcacheds.cache.example.com
1010
spec:

go/kubebuilder/memcached-operator/config/manager/kustomization.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: quay.io/btenneti/kb-memcached-operator
8-
newTag: v0.0.1
7+
newName: quay.io/example-inc/memcached-operator

go/kubebuilder/memcached-operator/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ require (
66
github.com/go-logr/logr v0.1.0
77
github.com/onsi/ginkgo v1.11.0
88
github.com/onsi/gomega v1.8.1
9-
k8s.io/api v0.17.2
10-
k8s.io/apimachinery v0.17.2
11-
k8s.io/client-go v0.17.2
12-
sigs.k8s.io/controller-runtime v0.5.0
9+
k8s.io/api v0.18.2
10+
k8s.io/apimachinery v0.18.2
11+
k8s.io/client-go v0.18.2
12+
sigs.k8s.io/controller-runtime v0.6.0
1313
)

0 commit comments

Comments
 (0)