Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ go.work

# macOS
.DS_Store

# Helm Chart generated directory
# The .gitignore inside helm/ controls specific ignored files
helm/Chart.yaml
helm/values.yaml
helm/templates/
helm/crds/
helm/charts/
helm/*.tgz
95 changes: 91 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,48 @@ vet: ## Run go vet against code.
go vet ./...

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
test: manifests generate fmt vet envtest helm-tool ## Run tests.
ENVTEST_K8S_VERSION=$(ENVTEST_K8S_VERSION) \
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v $$(go list ./... | grep -v /e2e) -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
PATH="$(LOCALBIN):$(PATH)" \
go test -v $$(go list ./... | grep -v /e2e) -coverprofile cover.out
@echo "==> Validating Helm Chart generation..."
$(MAKE) helm
@echo "==> Running Helm lint..."
$(HELM) lint helm/
@echo "==> Testing Helm template rendering..."
$(HELM) template test helm/ > /dev/null
@echo "✅ All tests passed including Helm validation!"

# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
# Prometheus and CertManager are installed by default; skip with:
# - PROMETHEUS_INSTALL_SKIP=true
# - CERT_MANAGER_INSTALL_SKIP=true
#
# DEPLOY_METHOD controls the deployment method for E2E tests:
# - all (default): Test both deployment methods sequentially
# - kustomize: Deploy using Kustomize only
# - helm: Deploy using Helm Chart only
DEPLOY_METHOD ?= all

.PHONY: test-e2e
test-e2e: generate fmt vet kind ## Run the e2e tests. Expected an isolated environment using Kind.
ETCD_VERSION="$(E2E_ETCD_VERSION)" PATH="$(LOCALBIN):$(PATH)" go test ./test/e2e/ -v
test-e2e: generate fmt vet kind helm-tool ## Run the e2e tests. Expected an isolated environment using Kind.
@if [ "$(DEPLOY_METHOD)" = "all" ]; then \
echo "==> Testing all deployment methods..."; \
echo ""; \
echo "==> [1/2] Testing Kustomize deployment"; \
DEPLOY_METHOD=kustomize ETCD_VERSION="$(E2E_ETCD_VERSION)" PATH="$(LOCALBIN):$(PATH)" go test ./test/e2e/ -v || exit 1; \
echo ""; \
echo "==> [2/2] Testing Helm deployment"; \
$(MAKE) helm; \
DEPLOY_METHOD=helm ETCD_VERSION="$(E2E_ETCD_VERSION)" PATH="$(LOCALBIN):$(PATH)" go test ./test/e2e/ -v || exit 1; \
echo ""; \
echo "✅ All deployment methods tested successfully!"; \
else \
echo "==> Testing with DEPLOY_METHOD=$(DEPLOY_METHOD)"; \
ETCD_VERSION="$(E2E_ETCD_VERSION)" PATH="$(LOCALBIN):$(PATH)" go test ./test/e2e/ -v; \
fi

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
Expand Down Expand Up @@ -157,6 +187,27 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install$(VERSION_SUFFIX).yaml

##@ Helm

.PHONY: helm
helm: manifests kustomize helmify yq helm-tool ## Generate Helm Chart from Kustomize manifests.
@echo "==> Generating Helm Chart..."
@mkdir -p helm
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir -image-pull-secrets helm
@echo "==> Updating Chart metadata..."
$(YQ) -i '.name = "etcd-operator"' helm/Chart.yaml
$(YQ) -i '.description = "Official Kubernetes operator for etcd"' helm/Chart.yaml
$(YQ) -i '.home = "https://github.com/etcd-io/etcd-operator"' helm/Chart.yaml
@echo "==> Validating generated Chart..."
@$(HELM) lint helm/ || (echo "❌ Helm Chart validation failed!" && exit 1)
@echo "✅ Helm Chart generated and validated at helm/"

.PHONY: helm-lint
helm-lint: helm ## Lint the generated Helm Chart.
@echo "==> Linting Helm Chart..."
@$(HELM) lint helm/
@echo "✅ Helm Chart validation passed!"

##@ Deployment

ifndef ignore-not-found
Expand Down Expand Up @@ -206,6 +257,9 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs
KIND ?= $(LOCALBIN)/kind
HELMIFY ?= $(LOCALBIN)/helmify
YQ ?= $(LOCALBIN)/yq
HELM ?= $(LOCALBIN)/helm

## Tool Versions
KUSTOMIZE_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} sigs.k8s.io/kustomize/kustomize/v5)
Expand All @@ -214,6 +268,10 @@ ENVTEST_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} sigs.k8s.io
GOLANGCI_LINT_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} github.com/golangci/golangci-lint/v2)
CRD_REF_DOCS_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} github.com/elastic/crd-ref-docs)
KIND_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} sigs.k8s.io/kind)
HELMIFY_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} github.com/arttor/helmify)
YQ_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} github.com/mikefarah/yq/v4)
# Helm is not a Go module, must specify version directly
HELM_VERSION ?= v3.17.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -245,6 +303,35 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(LOCALBIN) $(GOLANGCI_LINT_VERSION)

.PHONY: helmify
helmify: $(HELMIFY) ## Download helmify locally if necessary.
$(HELMIFY): $(LOCALBIN)
$(call go-install-tool,$(HELMIFY),github.com/arttor/helmify/cmd/helmify,$(HELMIFY_VERSION))

.PHONY: yq
yq: $(YQ) ## Download yq locally if necessary.
$(YQ): $(LOCALBIN)
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4,$(YQ_VERSION))

.PHONY: helm-tool
helm-tool: $(HELM) ## Download helm locally if necessary.
$(HELM): $(LOCALBIN)
@[ -f "$(HELM)-$(HELM_VERSION)" ] || { \
set -e; \
echo "Downloading Helm $(HELM_VERSION)"; \
rm -f $(HELM) || true; \
OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
ARCH=$$(uname -m); \
case $$ARCH in \
x86_64) ARCH=amd64 ;; \
aarch64) ARCH=arm64 ;; \
esac; \
curl -sSL https://get.helm.sh/helm-$(HELM_VERSION)-$${OS}-$${ARCH}.tar.gz | \
tar xz -C $(LOCALBIN) --strip-components=1 $${OS}-$${ARCH}/helm; \
mv $(HELM) $(HELM)-$(HELM_VERSION); \
}
@ln -sf $(HELM)-$(HELM_VERSION) $(HELM)

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,25 @@ Participation in the Kubernetes community is governed by the [Kubernetes Code of
- kubectl version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.

### To Deploy on the cluster
### Deployment Methods

The etcd-operator supports two deployment methods:

- **Helm**: Package management with easy configuration via values files
- **Kustomize**: Simple, GitOps-friendly deployment

📦 **For Helm deployment**, see the [Helm Chart Documentation](helm/README.md) for:
- Quick start guide
- How the Chart is auto-generated from Kustomize
- Customizing values and configuration
- Example configurations (HA, minimal resources)
- Upgrade and troubleshooting guides

The instructions below use **Kustomize** for deployment.

---

### To Deploy on the cluster (Kustomize)

**Build and push your image to the location specified by `IMG`:**

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
go.etcd.io/etcd/client/v3 v3.6.5
go.etcd.io/etcd/server/v3 v3.6.5
go.uber.org/zap v1.27.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.34.1
k8s.io/apimachinery v0.34.1
k8s.io/client-go v0.34.1
Expand Down Expand Up @@ -118,7 +119,6 @@ require (
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.34.1
k8s.io/apiserver v0.34.1 // indirect
k8s.io/component-base v0.34.1 // indirect
Expand Down
12 changes: 12 additions & 0 deletions helm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Helm Chart generated files (created by helmify) - do not commit to Git
# These files are generated by the `make helm` command
Chart.yaml
values.yaml
templates/
crds/
charts/
*.tgz

# Keep manually created example configs and documentation
!examples/
!README.md
23 changes: 23 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
Loading