-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Separate Makefiles and move tools
- Loading branch information
Showing
17 changed files
with
197 additions
and
97 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/verify-build.yaml → .github/workflows/webhosting-operator.yaml
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,4 +1,4 @@ | ||
name: Verify and Build | ||
name: webhosting-operator | ||
|
||
on: | ||
release: | ||
|
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,24 @@ | ||
.idea | ||
*.secret* | ||
.envrc | ||
/dev | ||
bin | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
testbin/* | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# editor and IDE paraphernalia | ||
.idea | ||
*.swp | ||
*.swo | ||
*~ |
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,160 @@ | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
# Image URL to use all building/pushing image targets | ||
TAG ?= latest | ||
GHCR_REPO ?= ghcr.io/timebertt/kubernetes-controller-sharding | ||
OPERATOR_IMG ?= $(GHCR_REPO)/webhosting-operator:$(TAG) | ||
EXPERIMENT_IMG ?= $(GHCR_REPO)/experiment:$(TAG) | ||
|
||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.24 | ||
# set OVERLAY to shoot to configure ingress-nginx with public dns and a TLS certificate | ||
OVERLAY = default | ||
|
||
# Setting SHELL to bash allows bash commands to be executed by recipes. | ||
# Options are set to exit when a recipe line exits non-zero or a piped command fails. | ||
SHELL = /usr/bin/env bash -o pipefail | ||
.SHELLFLAGS = -ec | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
##@ General | ||
|
||
# The help target prints out all targets with their descriptions organized | ||
# beneath their categories. The categories are represented by '##@' and the | ||
# target descriptions by '##'. The awk commands is responsible for reading the | ||
# entire set of makefiles included in this invocation, looking for lines of the | ||
# file as xyz: ## something, and then pretty-format the target and help. Then, | ||
# if there's a line with ##@ something, that gets pretty-printed as a category. | ||
# More info on the usage of ANSI control characters for terminal formatting: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
# More info on the awk command: | ||
# http://linuxcommand.org/lc3_adv_awk.php | ||
|
||
.PHONY: help | ||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
##@ Tools | ||
|
||
include hack/tools.mk | ||
|
||
.PHONY: clean-tools-bin | ||
clean-tools-bin: ## Empty the tools binary directory | ||
rm -rf $(TOOLS_BIN_DIR)/* | ||
|
||
##@ Development | ||
|
||
.PHONY: manifests | ||
manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
$(CONTROLLER_GEN) rbac:roleName=operator crd paths="./webhosting-operator/..." output:rbac:artifacts:config=../config/manager/rbac output:crd:artifacts:config=../config/manager/crds | ||
|
||
.PHONY: generate | ||
generate: $(CONTROLLER_GEN) modules ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./webhosting-operator/..." | ||
webhosting-operator/hack/update-codegen.sh | ||
|
||
.PHONY: fmt | ||
fmt: ## Run go fmt against code. | ||
cd webhosting-operator && go fmt ./... | ||
|
||
.PHONY: modules | ||
modules: ## Runs go mod to ensure modules are up to date. | ||
cd webhosting-operator && go mod tidy | ||
|
||
.PHONY: test | ||
test: $(SETUP_ENVTEST) ## Run tests. | ||
cd webhosting-operator && KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -race ./... | ||
|
||
.PHONY: test-kyverno | ||
test-kyverno: $(KYVERNO) ## Run kyverno policy tests. | ||
$(KYVERNO) test --remove-color -v 4 . | ||
|
||
##@ Verification | ||
|
||
.PHONY: vet | ||
vet: ## Run go vet against code. | ||
cd webhosting-operator && go vet ./... | ||
|
||
.PHONY: check | ||
check: vet test test-kyverno ## Check everything (vet + test + test-kyverno). | ||
|
||
.PHONY: verify-fmt | ||
verify-fmt: fmt ## Verify go code is formatted. | ||
@if !(git diff --quiet HEAD); then \ | ||
echo "unformatted files are out of date, please run 'make fmt'"; exit 1; \ | ||
fi | ||
|
||
.PHONY: verify-generate | ||
verify-generate: manifests generate ## Verify generated files are up to date. | ||
@if !(git diff --quiet HEAD); then \ | ||
echo "generated files are out of date, please run 'make manifests generate'"; exit 1; \ | ||
fi | ||
|
||
.PHONY: verify-modules | ||
verify-modules: modules ## Verify go module files are up to date. | ||
@if !(git diff --quiet HEAD -- go.sum go.mod); then \ | ||
echo "go module files are out of date, please run 'make modules'"; exit 1; \ | ||
fi | ||
|
||
.PHONY: verify | ||
verify: verify-fmt verify-generate verify-modules check ## Verify everything (all verify-* rules + check). | ||
|
||
##@ Build | ||
|
||
.PHONY: build | ||
build: generate fmt vet ## Build manager binary. | ||
cd webhosting-operator && go build -o bin/webhosting-operator ./cmd/webhosting-operator | ||
|
||
.PHONY: run-webhosting-operator | ||
run-webhosting-operator: manifests generate fmt vet ## Run the webhosting-operator from your host. | ||
cd webhosting-operator && go run ./cmd/webhosting-operator | ||
|
||
PUSH ?= false | ||
images: export KO_DOCKER_REPO = $(GHCR_REPO) | ||
|
||
.PHONY: images | ||
images: $(KO) ## Build and push container images using ko. | ||
$(KO) build --push=$(PUSH) --sbom none --base-import-paths -t $(TAG) --platform linux/amd64,linux/arm64 ./webhosting-operator/cmd/webhosting-operator | ||
|
||
##@ Deployment | ||
|
||
KIND_KUBECONFIG := $(PROJECT_DIR)/dev/kind_kubeconfig.yaml | ||
kind-up kind-down: export KUBECONFIG = $(KIND_KUBECONFIG) | ||
|
||
.PHONY: kind-up | ||
kind-up: $(KIND) ## Launch a kind cluster for testing the operator. | ||
$(KIND) create cluster --name webhosting --config hack/kind-config.yaml | ||
# run `export KUBECONFIG=$$PWD/dev/kind_kubeconfig.yaml` to target the created kind cluster. | ||
$(MAKE) deploy-ingress-nginx OVERLAY=kind | ||
|
||
.PHONY: kind-down | ||
kind-down: $(KIND) ## Tear down the kind testing cluster. | ||
$(KIND) delete cluster --name webhosting | ||
|
||
.PHONY: deploy-ingress-nginx | ||
deploy-ingress-nginx: $(KUBECTL) ## Deploy ingress-nginx to K8s cluster specified in $KUBECONFIG. | ||
@# job template is immutable, delete old jobs to prepare for upgrade | ||
$(KUBECTL) -n ingress-nginx delete job --ignore-not-found ingress-nginx-admission-create ingress-nginx-admission-patch | ||
$(KUBECTL) apply --server-side -k config/ingress-nginx/$(OVERLAY) | ||
$(KUBECTL) -n ingress-nginx wait deploy ingress-nginx-controller --for=condition=Available --timeout=2m | ||
|
||
# use static label for skaffold to prevent rolling all components on every skaffold invocation | ||
deploy up dev down: export SKAFFOLD_LABEL = skaffold.dev/run-id=webhosting-operator | ||
|
||
.PHONY: deploy | ||
deploy: $(SKAFFOLD) $(KUBECTL) $(YQ) ## Build all images and deploy everything to K8s cluster specified in $KUBECONFIG. | ||
$(SKAFFOLD) deploy --port-forward=user --tail -i $(OPERATOR_IMG) -i $(EXPERIMENT_IMG) | ||
|
||
.PHONY: up | ||
up: $(SKAFFOLD) $(KUBECTL) $(YQ) ## Build all images, deploy everything to K8s cluster specified in $KUBECONFIG, start port-forward and tail logs. | ||
$(SKAFFOLD) run --port-forward=user --tail | ||
|
||
.PHONY: dev | ||
dev: $(SKAFFOLD) $(KUBECTL) $(YQ) ## Start continuous dev loop with skaffold. | ||
$(SKAFFOLD) dev --port-forward=user --cleanup=false --trigger=manual | ||
|
||
.PHONY: down | ||
down: $(SKAFFOLD) $(KUBECTL) $(YQ) ## Remove everything from K8s cluster specified in $KUBECONFIG. | ||
$(SKAFFOLD) delete |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Empty file.
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 @@ | ||
# sharder |
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,3 @@ | ||
module github.com/timebertt/kubernetes-controller-sharding/sharder | ||
|
||
go 1.21.3 |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.