-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganized repository into v2 format, where code is organized in root directory instead of pkg dir. Added cert manager managing self signed certificate by default. Modernized Dockerfile which takes adventage of Go module cache. Fixes #56
- Loading branch information
Showing
100 changed files
with
25,897 additions
and
1,641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
bin | ||
config | ||
docs | ||
examples | ||
hack | ||
scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
FROM alpine:3.11 | ||
# Build the manager binary | ||
FROM golang:1.13 as builder | ||
|
||
# Run tini as PID 1 and avoid signal handling issues | ||
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini-static-amd64 /usr/local/bin/tini | ||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Add exec permissions | ||
RUN chmod +x /usr/local/bin/tini | ||
# Copy source | ||
COPY . . | ||
|
||
# Add files for the sidecar | ||
RUN mkdir -p /sidecar | ||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o scylla-operator github.com/scylladb/scylla-operator/pkg/cmd | ||
|
||
# Add tini to sidecar | ||
RUN cp /usr/local/bin/tini /sidecar/tini | ||
FROM alpine:3.12 | ||
WORKDIR / | ||
COPY --from=builder /workspace/scylla-operator . | ||
|
||
# Add operator binary | ||
COPY manager /usr/local/bin/scylla-operator | ||
RUN chmod +x /usr/local/bin/scylla-operator | ||
|
||
# Add executables to sidecar folder | ||
RUN cp /usr/local/bin/scylla-operator /sidecar/scylla-operator | ||
|
||
ENTRYPOINT ["tini", "--", "scylla-operator"] | ||
ENTRYPOINT ["/scylla-operator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,77 +4,104 @@ all: test local-build | |
REPO ?= scylladb/scylla-operator | ||
TAG ?= $(shell git describe --tags --always) | ||
IMG ?= $(REPO):$(TAG) | ||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true" | ||
|
||
.EXPORT_ALL_VARIABLES: | ||
DOCKER_BUILDKIT := 1 | ||
GO111MODULE := off | ||
KUBEBUILDER_ASSETS := $(CURDIR)/bin/deps | ||
PATH := $(CURDIR)/bin/deps/go/bin:$(CURDIR)/bin/deps:$(PATH) | ||
PATH := $(CURDIR)/bin/deps:$(PATH): | ||
PATH := $(CURDIR)/bin/deps/go/bin:$(PATH): | ||
GOROOT := $(CURDIR)/bin/deps/go | ||
GOVERSION := $(shell go version) | ||
|
||
# Run tests | ||
.PHONY: test | ||
test: fmt vet vendor | ||
go test ./pkg/... ./cmd/... -coverprofile cover.out | ||
# Default package | ||
PKG := ./pkg/... | ||
|
||
# Build local-build binary | ||
.PHONY: local-build | ||
local-build: fmt vet vendor | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/manager github.com/scylladb/scylla-operator/cmd | ||
# Run tests | ||
test: generate fmt vet manifests | ||
go test $(PKG) -coverprofile cover.out | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
.PHONY: run | ||
run: fmt vet vendor | ||
run: generate fmt vet manifests | ||
go run ./cmd operator --image="$(IMG)" --enable-admission-webhook=false | ||
|
||
# Install CRDs into a cluster | ||
.PHONY: install | ||
install: manifests | ||
kubectl apply -f config/crds | ||
install: manifests cert-manager | ||
kustomize build config/crd | kubectl apply -f - | ||
|
||
# Uninstall CRDs from a cluster | ||
uninstall: manifests | ||
kustomize build config/crd | kubectl delete -f - | ||
kubectl delete -f examples/generic/cert-manager.yaml | ||
|
||
cert-manager: | ||
cat config/certmanager/cert-manager.yaml > examples/generic/cert-manager.yaml | ||
cat config/certmanager/cert-manager.yaml > examples/gke/cert-manager.yaml | ||
kubectl apply -f examples/generic/cert-manager.yaml | ||
|
||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
.PHONY: deploy | ||
deploy: install | ||
kubectl apply -f config/rbac | ||
kustomize build config | kubectl apply -f - | ||
deploy: manifests cert-manager | ||
cd config/manager && kustomize edit set image controller=${IMG} | ||
kustomize build config/default | kubectl apply -f - | ||
kustomize build config/default > examples/generic/operator.yaml | ||
kustomize build config/default > examples/gke/operator.yaml | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
.PHONY: manifests | ||
manifests: bin/deps | ||
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all | ||
cd config && kustomize edit set image scylladb/scylla-operator="$(IMG)" | ||
kustomize build config > examples/generic/operator.yaml | ||
kustomize build config > examples/gke/operator.yaml | ||
manifests: bin/deps controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) webhook rbac:roleName=manager-role paths="$(PKG)" output:crd:artifacts:config=config/crd/bases output:rbac:artifacts:config=config/rbac/bases | ||
|
||
# Run go fmt against code | ||
.PHONY: fmt | ||
fmt: bin/deps | ||
go fmt ./pkg/... ./cmd/... | ||
fmt: | ||
go fmt $(PKG) | ||
|
||
# Run go vet against code | ||
.PHONY: vet | ||
vet: bin/deps | ||
go vet ./pkg/... ./cmd/... | ||
vet: | ||
go vet $(PKG) | ||
|
||
# Generate code | ||
.PHONY: generate | ||
generate: bin/deps | ||
go generate ./pkg/... ./cmd/... | ||
|
||
# Ensure dependencies | ||
.PHONY: vendor | ||
vendor: | ||
dep ensure -v | ||
generate: controller-gen | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="$(PKG)" | ||
|
||
# Build the docker image | ||
.PHONY: docker-build | ||
docker-build: bin/deps | ||
goreleaser --skip-validate --skip-publish --rm-dist | ||
|
||
# Push the docker image | ||
docker-push: | ||
docker push ${IMG} | ||
|
||
# Ensure dependencies | ||
.PHONY: vendor | ||
vendor: | ||
go mod vendor | ||
|
||
# Build local-build binary | ||
.PHONY: local-build | ||
local-build: fmt vet vendor | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/scylla-operator github.com/scylladb/scylla-operator/pkg/cmd | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
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=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif | ||
|
||
release: bin/deps | ||
goreleaser --rm-dist | ||
|
||
bin/deps: hack/binary_deps.py | ||
mkdir -p bin/deps | ||
hack/binary_deps.py bin/deps | ||
hack/binary_deps.py bin/deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
version: "1" | ||
domain: scylladb.com | ||
domain: scylla.scylladb.com | ||
repo: github.com/scylladb/scylla-operator | ||
resources: | ||
- group: scylla | ||
kind: Cluster | ||
version: v1alpha1 | ||
version: "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# this file prevents go compiler from looking into this directory and compiling | ||
# go source which lies in deps/go. | ||
# Please leave it here, unless there's a way to tell compiler which directories | ||
# should be ignored. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.