Skip to content

Commit 5757e4a

Browse files
authored
chore: dropping kustomize dependency in favor of yq (#565)
* chore(makefile): installing cert-manager via helm Signed-off-by: Dario Tranchitella <[email protected]> * chore: removing need of kustomize in favor of yq By removing kustomize generation files we can simply release, despite the bundles must be removed since based on kustomize despite never being used. Signed-off-by: Dario Tranchitella <[email protected]> * chore(ci): aligning to latest manifest generation strategy Signed-off-by: Dario Tranchitella <[email protected]> --------- Signed-off-by: Dario Tranchitella <[email protected]>
1 parent dada857 commit 5757e4a

File tree

63 files changed

+681
-18460
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+681
-18460
lines changed

.github/workflows/ci.yaml

+5-7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-go@v5
1616
with:
17-
go-version: '1.22'
18-
check-latest: true
17+
go-version-file: go.mod
1918
- name: Run golangci-lint
2019
uses: golangci/[email protected]
2120
with:
@@ -31,12 +30,11 @@ jobs:
3130
fetch-depth: 0
3231
- uses: actions/setup-go@v5
3332
with:
34-
go-version: '1.22'
35-
check-latest: true
36-
- run: make yaml-installation-file
37-
- name: Checking if YAML installer file is not aligned
33+
go-version-file: go.mod
34+
- run: make manifests
35+
- name: Checking if generated manifests are not aligned
3836
run: if [[ $(git diff | wc -l) -gt 0 ]]; then echo ">>> Untracked generated files have not been committed" && git --no-pager diff && exit 1; fi
39-
- name: Checking if YAML installer generated untracked files
37+
- name: Checking if missing untracked files for generated manifests
4038
run: test -z "$(git ls-files --others --exclude-standard 2> /dev/null)"
4139
- name: Checking if source code is not formatted
4240
run: test -z "$(git diff 2> /dev/null)"

Makefile

+30-130
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,6 @@
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66
VERSION ?= v1.0.0
77

8-
# CHANNELS define the bundle channels used in the bundle.
9-
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
10-
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11-
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
12-
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
13-
ifneq ($(origin CHANNELS), undefined)
14-
BUNDLE_CHANNELS := --channels=$(CHANNELS)
15-
endif
16-
17-
# DEFAULT_CHANNEL defines the default channel used in the bundle.
18-
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
19-
# To re-generate a bundle for any other default channel without changing the default setup, you can:
20-
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
21-
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
22-
ifneq ($(origin DEFAULT_CHANNEL), undefined)
23-
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
24-
endif
25-
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
26-
27-
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
28-
# This variable is used to construct full image tags for bundle and catalog images.
29-
#
30-
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
31-
# clastix.io/operator-bundle:$VERSION and clastix.io/operator-catalog:$VERSION.
32-
IMAGE_TAG_BASE ?= clastix.io/operator
33-
34-
# BUNDLE_IMG defines the image:tag used for the bundle.
35-
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
36-
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)
37-
388
# Image URL to use all building/pushing image targets
399
CONTAINER_REPOSITORY ?= docker.io/clastix/kamaji
4010

@@ -61,9 +31,9 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
6131
GINKGO ?= $(LOCALBIN)/ginkgo
6232
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
6333
HELM ?= $(LOCALBIN)/helm
64-
KUSTOMIZE ?= $(LOCALBIN)/kustomize
6534
KIND ?= $(LOCALBIN)/kind
6635
KO ?= $(LOCALBIN)/ko
36+
YQ ?= $(LOCALBIN)/yq
6737

6838
all: build
6939

@@ -90,6 +60,11 @@ ko: $(KO) ## Download ko locally if necessary.
9060
$(KO): $(LOCALBIN)
9161
test -s $(LOCALBIN)/ko || GOBIN=$(LOCALBIN) go install github.com/google/[email protected]
9262

63+
.PHONY: yq
64+
yq: $(YQ) ## Download yq locally if necessary.
65+
$(YQ): $(LOCALBIN)
66+
test -s $(LOCALBIN)/yq || GOBIN=$(LOCALBIN) go install github.com/mikefarah/yq/[email protected]
67+
9368
.PHONY: helm
9469
helm: $(HELM) ## Download helm locally if necessary.
9570
$(HELM): $(LOCALBIN)
@@ -120,13 +95,25 @@ apidocs-gen: $(APIDOCS_GEN) ## Download crdoc locally if necessary.
12095
$(APIDOCS_GEN): $(LOCALBIN)
12196
test -s $(LOCALBIN)/crdoc || GOBIN=$(LOCALBIN) go install fybrik.io/crdoc@latest
12297

123-
kustomize: ## Download kustomize locally if necessary.
124-
$(call install-kustomize,$(KUSTOMIZE),3.8.7)
125-
12698
##@ Development
12799

128-
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
129-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
100+
rbac: controller-gen yq
101+
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="./..." output:stdout | $(YQ) '.rules' > ./charts/kamaji/controller-gen/clusterrole.yaml
102+
103+
webhook: controller-gen yq
104+
$(CONTROLLER_GEN) webhook paths="./..." output:stdout | $(YQ) 'select(documentIndex == 0) | .webhooks' > ./charts/kamaji/controller-gen/mutating-webhook.yaml
105+
$(CONTROLLER_GEN) webhook paths="./..." output:stdout | $(YQ) 'select(documentIndex == 1) | .webhooks' > ./charts/kamaji/controller-gen/validating-webhook.yaml
106+
$(YQ) -i 'map(.clientConfig.service.name |= "{{ include \"kamaji.webhookServiceName\" . }}")' ./charts/kamaji/controller-gen/mutating-webhook.yaml
107+
$(YQ) -i 'map(.clientConfig.service.namespace |= "{{ .Release.Namespace }}")' ./charts/kamaji/controller-gen/mutating-webhook.yaml
108+
$(YQ) -i 'map(.clientConfig.service.name |= "{{ include \"kamaji.webhookServiceName\" . }}")' ./charts/kamaji/controller-gen/validating-webhook.yaml
109+
$(YQ) -i 'map(.clientConfig.service.namespace |= "{{ .Release.Namespace }}")' ./charts/kamaji/controller-gen/validating-webhook.yaml
110+
111+
crds: controller-gen yq
112+
$(CONTROLLER_GEN) crd webhook paths="./..." output:stdout | $(YQ) 'select(documentIndex == 0)' > ./charts/kamaji/crds/kamaji.clastix.io_datastores.yaml
113+
$(CONTROLLER_GEN) crd webhook paths="./..." output:stdout | $(YQ) 'select(documentIndex == 1)' > ./charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml
114+
$(YQ) -i '. *n load("./charts/kamaji/controller-gen/crd-conversion.yaml")' ./charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml
115+
116+
manifests: rbac webhook crds ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
130117

131118
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
132119
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@@ -207,7 +194,7 @@ build: $(KO)
207194
KOCACHE=/tmp/ko-cache KO_DOCKER_REPO=${CONTAINER_REPOSITORY} \
208195
$(KO) build ./ --bare --tags=$(VERSION) --local=$(KO_LOCAL) --push=$(KO_PUSH)
209196

210-
##@ Deployment
197+
##@ Development
211198

212199
metallb:
213200
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/$$(curl "https://api.github.com/repos/metallb/metallb/releases/latest" | jq -r ".tag_name")/config/manifests/metallb-native.yaml"
@@ -216,107 +203,20 @@ metallb:
216203
cat hack/metallb.yaml | sed -E "s|172.19|$$(docker network inspect -f '{{range .IPAM.Config}}{{.Gateway}}{{end}}' kind | sed -E 's|^([0-9]+\.[0-9]+)\..*$$|\1|g')|g" | kubectl apply -f -
217204

218205
cert-manager:
219-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.1/cert-manager.yaml
206+
$(HELM) repo add bitnami https://charts.bitnami.com/bitnami
207+
$(HELM) upgrade --install cert-manager bitnami/cert-manager --namespace certmanager-system --create-namespace --set "installCRDs=true"
220208

221-
dev: generate manifests uninstall install rbac ## Full installation for development purposes
222-
go fmt ./...
223-
224-
load: kind build
209+
load: kind
225210
$(KIND) load docker-image --name kamaji ${CONTAINER_REPOSITORY}:${VERSION}
226211

227-
rbac: manifests kustomize ## Install RBAC into the K8s cluster specified in ~/.kube/config.
228-
$(KUSTOMIZE) build config/rbac | kubectl apply -f -
229-
230-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
231-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
232-
233-
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
234-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
235-
236-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
237-
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTAINER_REPOSITORY}:${VERSION}
238-
$(KUSTOMIZE) build config/default | kubectl apply -f -
239-
240-
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
241-
$(KUSTOMIZE) build config/default | kubectl delete -f -
242-
243-
yaml-installation-file: manifests kustomize ## Create yaml installation file
244-
$(KUSTOMIZE) build config/default > config/install.yaml
245-
246-
.PHONY: bundle
247-
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
248-
operator-sdk generate kustomize manifests -q
249-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
250-
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
251-
operator-sdk bundle validate ./bundle
252-
253-
.PHONY: bundle-build
254-
bundle-build: ## Build the bundle image.
255-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
256-
257-
.PHONY: bundle-push
258-
bundle-push: ## Push the bundle image.
259-
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
260-
261-
.PHONY: opm
262-
OPM = ./bin/opm
263-
opm: ## Download opm locally if necessary.
264-
ifeq (,$(wildcard $(OPM)))
265-
ifeq (,$(shell which opm 2>/dev/null))
266-
@{ \
267-
set -e ;\
268-
mkdir -p $(dir $(OPM)) ;\
269-
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
270-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
271-
chmod +x $(OPM) ;\
272-
}
273-
else
274-
OPM = $(shell which opm)
275-
endif
276-
endif
277-
278-
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
279-
# These images MUST exist in a registry and be pull-able.
280-
BUNDLE_IMGS ?= $(BUNDLE_IMG)
281-
282-
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
283-
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
284-
285-
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
286-
ifneq ($(origin CATALOG_BASE_IMG), undefined)
287-
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
288-
endif
289-
290-
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
291-
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
292-
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
293-
.PHONY: catalog-build
294-
catalog-build: opm ## Build a catalog image.
295-
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
296-
297-
# Push the catalog image.
298-
.PHONY: catalog-push
299-
catalog-push: ## Push a catalog image.
300-
$(MAKE) docker-push IMG=$(CATALOG_IMG)
301-
302-
define install-kustomize
303-
@[ -f $(1) ] || { \
304-
set -e ;\
305-
echo "Installing v$(2)" ;\
306-
cd bin ;\
307-
wget "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" ;\
308-
bash ./install_kustomize.sh $(2) ;\
309-
}
310-
endef
212+
##@ e2e
311213

312214
.PHONY: env
313215
env:
314216
@make -C deploy/kind kind ingress-nginx
315217

316-
##@ e2e
317-
318218
.PHONY: e2e
319-
e2e: env load helm ginkgo cert-manager ## Create a KinD cluster, install Kamaji on it and run the test suite.
219+
e2e: env build load helm ginkgo cert-manager ## Create a KinD cluster, install Kamaji on it and run the test suite.
320220
$(HELM) repo add clastix https://clastix.github.io/charts
321221
$(HELM) dependency build ./charts/kamaji
322222
$(HELM) upgrade --debug --install kamaji ./charts/kamaji --create-namespace --namespace kamaji-system --set "image.pullPolicy=Never" --set "telemetry.disabled=true"
@@ -327,4 +227,4 @@ e2e: env load helm ginkgo cert-manager ## Create a KinD cluster, install Kamaji
327227

328228
.PHONY: apidoc
329229
apidoc: apidocs-gen
330-
$(APIDOCS_GEN) crdoc --resources config/crd/bases --output docs/content/reference/api.md --template docs/templates/reference-cr.tmpl
230+
$(APIDOCS_GEN) crdoc --resources charts/kamaji/crds --output docs/content/reference/api.md --template docs/templates/reference-cr.tmpl

api/v1alpha1/datastore_types.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
)
1010

11-
// +kubebuilder:validation:Enum=etcd;MySQL;PostgreSQL;NATS
11+
//+kubebuilder:validation:Enum=etcd;MySQL;PostgreSQL;NATS
1212

1313
type Driver string
1414

@@ -19,7 +19,7 @@ var (
1919
KineNatsDriver Driver = "NATS"
2020
)
2121

22-
// +kubebuilder:validation:MinItems=1
22+
//+kubebuilder:validation:MinItems=1
2323

2424
type Endpoints []string
2525

@@ -91,6 +91,7 @@ type DataStoreStatus struct {
9191
//+kubebuilder:resource:scope=Cluster
9292
//+kubebuilder:printcolumn:name="Driver",type="string",JSONPath=".spec.driver",description="Kamaji data store driver"
9393
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
94+
//+kubebuilder:metadata:annotations={"cert-manager.io/inject-ca-from=kamaji-system/kamaji-serving-cert"}
9495

9596
// DataStore is the Schema for the datastores API.
9697
type DataStore struct {

api/v1alpha1/tenantcontrolplane_registrysettings.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
package v1alpha1
55

66
type RegistrySettings struct {
7-
// +kubebuilder:default="registry.k8s.io"
7+
//+kubebuilder:default="registry.k8s.io"
88
Registry string `json:"registry,omitempty"`
99
// The tag to append to all the Control Plane container images.
1010
// Optional.
1111
TagSuffix string `json:"tagSuffix,omitempty"`
12-
// +kubebuilder:default="kube-apiserver"
12+
//+kubebuilder:default="kube-apiserver"
1313
APIServerImage string `json:"apiServerImage,omitempty"`
14-
// +kubebuilder:default="kube-controller-manager"
14+
//+kubebuilder:default="kube-controller-manager"
1515
ControllerManagerImage string `json:"controllerManagerImage,omitempty"`
16-
// +kubebuilder:default="kube-scheduler"
16+
//+kubebuilder:default="kube-scheduler"
1717
SchedulerImage string `json:"schedulerImage,omitempty"`
1818
}

api/v1alpha1/tenantcontrolplane_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ var (
198198
type KubernetesVersion struct {
199199
// Version is the running Kubernetes version of the Tenant Control Plane.
200200
Version string `json:"version,omitempty"`
201-
// +kubebuilder:default=Provisioning
201+
//+kubebuilder:default=Provisioning
202202
// Status returns the current status of the Kubernetes version, such as its provisioning state, or completed upgrade.
203203
Status *KubernetesVersionStatus `json:"status,omitempty"`
204204
}

0 commit comments

Comments
 (0)