-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy across build/helm boilerplate from gitopssets-controller (#6)
* Copy across build/doc/helm boilerplate from gitopssets-controller - Auto-generate and publish a helm-chart - Auto-generate and copy api docs * Add and report version on startup * Update license and include in helm chart
- Loading branch information
Showing
8 changed files
with
147 additions
and
10 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
FluxShardController is under the same license and commercial agreement as Weave GitOps Enterprise, and can only be used in conjunction. |
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,9 +1,16 @@ | ||
|
||
VERSION ?= $(shell git describe --tags --always) | ||
# Strip off leading `v`: v0.12.0 -> 0.12.0 | ||
# Seems to be idiomatic for chart versions: https://helm.sh/docs/topics/charts/#the-chart-file | ||
CHART_VERSION := $(shell echo $(VERSION) | sed 's/^v//') | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= controller:latest | ||
IMG ?= ghcr.io/weaveworks/flux-shard-controller:${VERSION} | ||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.26.1 | ||
|
||
CHART_REGISTRY ?= ghcr.io/weaveworks/charts | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
|
@@ -62,18 +69,21 @@ test: manifests generate fmt vet envtest ## Run tests. | |
|
||
.PHONY: build | ||
build: manifests generate fmt vet ## Build manager binary. | ||
go build -o bin/manager cmd/main.go | ||
go build -o bin/manager -ldflags "-X main.Version=${VERSION}" cmd/main.go cmd/version.go | ||
|
||
.PHONY: run | ||
run: manifests generate fmt vet ## Run a controller from your host. | ||
go run ./cmd/main.go | ||
|
||
version: | ||
@echo $(VERSION) | ||
|
||
# If you wish built the manager image targeting other platforms you can use the --platform flag. | ||
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. | ||
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/ | ||
.PHONY: docker-build | ||
docker-build: test ## Build docker image with the manager. | ||
docker build -t ${IMG} . | ||
docker build -t ${IMG} --build-arg VERSION=${VERSION} . | ||
|
||
.PHONY: docker-push | ||
docker-push: ## Push docker image with the manager. | ||
|
@@ -160,3 +170,34 @@ $(CONTROLLER_GEN): $(LOCALBIN) | |
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. | ||
$(ENVTEST): $(LOCALBIN) | ||
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
|
||
HELMIFY = $(LOCALBIN)/helmify | ||
.PHONY: helmify | ||
helmify: | ||
$(call go-get-tool,$(HELMIFY),github.com/arttor/helmify/cmd/[email protected]) | ||
|
||
.PHONY: helm-chart | ||
helm-chart: manifests kustomize helmify | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir charts/flux-shard-controller | ||
echo "fullnameOverride: flux-shard" >> charts/flux-shard-controller/values.yaml | ||
cp LICENSE charts/flux-shard-controller/LICENSE | ||
helm lint charts/flux-shard-controller | ||
helm package charts/flux-shard-controller --app-version $(VERSION) --version $(CHART_VERSION) --destination /tmp/helm-repo | ||
|
||
publish-helm-chart: helm-chart | ||
helm push /tmp/helm-repo/flux-shard-controller-${CHART_VERSION}.tgz oci://${CHART_REGISTRY} | ||
|
||
# go-get-tool will 'go get' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
endef |
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,2 +1,17 @@ | ||
# flux-shard-controller | ||
|
||
Easily spread load across replicated kustomize, source, helm and notification controllers | ||
|
||
## Releasing | ||
|
||
Publishing a **GitHub release** will trigger a GitHub Action to build and push the docker image and helm chart to ghcr.io. | ||
|
||
### Create the release | ||
|
||
Create a [new Github release](https://github.com/weaveworks/flux-shard-controller/releases/new) | ||
|
||
1. Click "Choose a tag" and type in the tag that the release should create on publish (e.g. `v0.5.0`) | ||
2. Click **Generate release notes** | ||
3. Click **Publish release** | ||
|
||
After a few minutes the new packages should be available to view via the repo's [packages page](https://github.com/orgs/weaveworks/packages?repo_name=flux-shard-controller). |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package main | ||
|
||
var Version = "dev" |
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