Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt controller-gen to generate crd manifests and adopt helm v3 way of managing crds #227

Merged
merged 7 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@ build: test build-go build-image

build-go:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-linux-amd64 cmd/manager/main.go
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-linux-amd64 cmd/manager/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-linux-amd64 cmd/exporter/main.go
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-linux-amd64 cmd/exporter/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-darwin-amd64 cmd/manager/main.go
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-darwin-amd64 cmd/manager/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-darwin-amd64 cmd/exporter/main.go
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-darwin-amd64 cmd/exporter/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-windows-amd64.exe cmd/manager/main.go
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-windows-amd64.exe cmd/manager/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-windows-amd64.exe cmd/exporter/main.go
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-windows-amd64.exe cmd/exporter/main.go

build-image:
docker build --build-arg VERSION=$(VERSION) --build-arg GIT_SHA=$(GIT_SHA) -t $(REPO):$(VERSION) .
docker tag $(REPO):$(VERSION) $(REPO):latest
Expand All @@ -57,7 +58,8 @@ build-zk-image:
docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest

build-zk-image-swarm:
docker build --build-arg VERSION=$(VERSION)-swarm --build-arg GIT_SHA=$(GIT_SHA) -f ./docker/Dockerfile-swarm -t $(APP_REPO):$(VERSION)-swarm ./docker
docker build --build-arg VERSION=$(VERSION)-swarm --build-arg GIT_SHA=$(GIT_SHA) \
-f ./docker/Dockerfile-swarm -t $(APP_REPO):$(VERSION)-swarm ./docker

test:
go test $$(go list ./... | grep -v /vendor/ | grep -v /test/e2e) -race -coverprofile=coverage.txt -covermode=atomic
Expand All @@ -67,10 +69,13 @@ test-e2e: test-e2e-remote
test-e2e-remote: test-login
operator-sdk build $(TEST_IMAGE)
docker push $(TEST_IMAGE)
operator-sdk test local ./test/e2e --operator-namespace default --namespaced-manifest ./test/e2e/resources/rbac-operator.yaml --global-manifest deploy/crds/zookeeper_v1beta1_zookeepercluster_crd.yaml --image $(TEST_IMAGE) --go-test-flags "-v -timeout 0"
operator-sdk test local ./test/e2e --operator-namespace default \
--namespaced-manifest ./test/e2e/resources/rbac-operator.yaml \
--global-manifest deploy/crds/zookeeper.pravega.io_zookeeperclusters.yaml \
--image $(TEST_IMAGE) --go-test-flags "-v -timeout 0"

test-e2e-local:
operator-sdk test local ./test/e2e --operator-namespace default --up-local --go-test-flags "-v -timeout 0"
operator-sdk test local ./test/e2e --operator-namespace default --up-local --go-test-flags "-v -timeout 0"

run-local:
operator-sdk up local
Expand All @@ -81,7 +86,7 @@ login:
test-login:
echo "$(DOCKER_TEST_PASS)" | docker login -u "$(DOCKER_TEST_USER)" --password-stdin

push: build-image build-zk-image build-zk-image-swarm login
push: build-image build-zk-image build-zk-image-swarm login
docker push $(REPO):$(VERSION)
docker push $(REPO):latest
docker push $(APP_REPO):$(VERSION)
Expand Down Expand Up @@ -109,3 +114,22 @@ check-license:

update-kube-version:
./scripts/update_kube_version.sh ${KUBE_VERSION}

manifests: controller-gen
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=deploy/crds
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=charts/zookeeper-operator/crds

controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOPATH)/bin/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ $ helm install zookeeper-operator charts/zookeeper-operator
Register the `ZookeeperCluster` custom resource definition (CRD).

```
$ kubectl create -f deploy/crds/zookeeper_v1beta1_zookeepercluster_crd.yaml
$ kubectl create -f deploy/crds
```

You can choose to enable Zookeeper operator for all namespaces or just for the a specific namespace. The example is using the `default` namespace, but feel free to edit the Yaml files and use a different namespace.
You can choose to enable Zookeeper operator for all namespaces or just for a specific namespace. The example is using the `default` namespace, but feel free to edit the Yaml files and use a different namespace.

Create the operator role and role binding.

Expand Down
Loading