Skip to content

Commit 4078046

Browse files
authored
Merge pull request #9 from datum-cloud/init-multicluster
Update network-services-operator with multicluster support, migrate e2e tests to Chainsaw
2 parents b4bcc24 + 8a02d5e commit 4078046

36 files changed

+2898
-1246
lines changed

.github/workflows/publish.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
push:
5+
release:
6+
types: ['published']
7+
8+
jobs:
9+
publish:
10+
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@v1.0.0
11+
with:
12+
image-name: network-services-operator
13+
secrets: inherit

.github/workflows/test-e2e.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,14 @@ jobs:
1717
with:
1818
go-version: '~1.23'
1919

20-
- name: Install the latest version of kind
21-
run: |
22-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
23-
chmod +x ./kind
24-
sudo mv ./kind /usr/local/bin/kind
25-
2620
- name: Verify kind installation
2721
run: kind version
2822

2923
- name: Create kind cluster
3024
run: kind create cluster
3125

26+
- name: Prepare e2e
27+
run: make prepare-e2e
28+
3229
- name: Running Test e2e
33-
run: |
34-
go mod tidy
35-
make test-e2e
30+
run: make test-e2e

Makefile

Lines changed: 83 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Image URL to use all building/pushing image targets
2-
IMG ?= controller:latest
2+
IMG ?= network-services-operator:latest
33
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
44
ENVTEST_K8S_VERSION = 1.31.0
55

@@ -70,15 +70,15 @@ test: manifests generate fmt vet envtest ## Run tests.
7070
# - CERT_MANAGER_INSTALL_SKIP=true
7171
.PHONY: test-e2e
7272
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
73-
# @command -v kind >/dev/null 2>&1 || { \
74-
# echo "Kind is not installed. Please install Kind manually."; \
75-
# exit 1; \
76-
# }
77-
# @kind get clusters | grep -q 'kind' || { \
78-
# echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
79-
# exit 1; \
80-
# }
81-
# go test ./test/e2e/ -v -ginkgo.v
73+
@command -v kind >/dev/null 2>&1 || { \
74+
echo "Kind is not installed. Please install Kind manually."; \
75+
exit 1; \
76+
}
77+
@kind get clusters | grep -q 'kind' || { \
78+
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
79+
exit 1; \
80+
}
81+
chainsaw test ./test/e2e
8282

8383
.PHONY: lint
8484
lint: golangci-lint ## Run golangci-lint linter
@@ -127,11 +127,29 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
127127
rm Dockerfile.cross
128128

129129
.PHONY: build-installer
130-
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
130+
build-installer: set-image-controller generate ## Generate a consolidated YAML with CRDs and deployment.
131131
mkdir -p dist
132-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
133132
$(KUSTOMIZE) build config/default > dist/install.yaml
134133

134+
.PHONY: set-image-controller
135+
set-image-controller: manifests kustomize
136+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
137+
138+
.PHONY: prepare-e2e
139+
prepare-e2e: chainsaw set-image-controller cert-manager load-image-all deploy
140+
141+
.PHONY: load-image-all
142+
load-image-all: load-image-operator
143+
144+
.PHONY: load-image-operator
145+
load-image-operator: docker-build kind
146+
$(KIND) load docker-image $(IMG)
147+
148+
.PHONY: cert-manager
149+
cert-manager:
150+
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v${CERTMANAGER_VERSION}/cert-manager.yaml
151+
$(CMCTL) check api --wait=5m
152+
135153
##@ Deployment
136154

137155
ifndef ignore-not-found
@@ -147,8 +165,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
147165
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
148166

149167
.PHONY: deploy
150-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
151-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
168+
deploy: set-image-controller ## Deploy controller to the K8s cluster specified in ~/.kube/config.
152169
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
153170

154171
.PHONY: undeploy
@@ -165,21 +182,44 @@ $(LOCALBIN):
165182
## Tool Binaries
166183
KUBECTL ?= kubectl
167184
KUSTOMIZE ?= $(LOCALBIN)/kustomize
185+
KIND ?= $(LOCALBIN)/kind
168186
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
169187
ENVTEST ?= $(LOCALBIN)/setup-envtest
170188
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
189+
CRDOC ?= $(LOCALBIN)/crdoc
190+
CHAINSAW ?= $(LOCALBIN)/chainsaw
191+
CMCTL ?= $(LOCALBIN)/cmctl
171192

172193
## Tool Versions
173194
KUSTOMIZE_VERSION ?= v5.5.0
174195
CONTROLLER_TOOLS_VERSION ?= v0.16.4
175196
ENVTEST_VERSION ?= release-0.19
176197
GOLANGCI_LINT_VERSION ?= v1.62.0
177198

199+
# renovate: datasource=go depName=github.com/cert-manager/cert-manager
200+
CERTMANAGER_VERSION ?= 1.17.1
201+
202+
# renovate: datasource=go depName=fybrik.io/crdoc
203+
CRDOC_VERSION ?= v0.6.4
204+
205+
# renovate: datasource=go depName=sigs.k8s.io/kind
206+
KIND_VERSION ?= v0.27.0
207+
208+
# renovate: datasource=go depName=github.com/kyverno/chainsaw
209+
CHAINSAW_VERSION ?= v0.2.12
210+
211+
# renovate: datasource=go depName=github.com/cert-manager/cmctl/v2
212+
CMCTL_VERSION ?= v2.1.1
213+
178214
.PHONY: kustomize
179215
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
180216
$(KUSTOMIZE): $(LOCALBIN)
181217
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))
182218

219+
.PHONY: kind
220+
kind: ## Download kind locally if necessary.
221+
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION))
222+
183223
.PHONY: controller-gen
184224
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
185225
$(CONTROLLER_GEN): $(LOCALBIN)
@@ -195,6 +235,18 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
195235
$(GOLANGCI_LINT): $(LOCALBIN)
196236
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
197237

238+
.PHONY: crdoc
239+
crdoc: ## Download crdoc locally if necessary.
240+
$(call go-install-tool,$(CRDOC),fybrik.io/crdoc,$(CRDOC_VERSION))
241+
242+
.PHONY: chainsaw
243+
chainsaw: ## Find or download chainsaw
244+
$(call go-install-tool,$(CHAINSAW),github.com/kyverno/chainsaw,$(CHAINSAW_VERSION))
245+
246+
.PHONY: cmctl
247+
cmctl: ## Find or download cmctl
248+
$(call go-install-tool,$(CMCTL),github.com/cert-manager/cmctl/v2,$(CMCTL_VERSION))
249+
198250
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
199251
# $1 - target path with name of binary
200252
# $2 - package url which can be installed
@@ -210,3 +262,20 @@ mv $(1) $(1)-$(3) ;\
210262
} ;\
211263
ln -sf $(1)-$(3) $(1)
212264
endef
265+
266+
.PHONY: api-docs
267+
api-docs: crdoc kustomize
268+
@{ \
269+
set -e ;\
270+
TMP_MANIFEST_DIR=$$(mktemp -d) ; \
271+
cp -r config/crd/* $$TMP_MANIFEST_DIR; \
272+
$(MAKE) CRD_OPTIONS=$(CRD_OPTIONS),maxDescLen=1200 MANIFEST_DIR=$$TMP_MANIFEST_DIR/bases manifests ;\
273+
TMP_DIR=$$(mktemp -d) ; \
274+
$(KUSTOMIZE) build $$TMP_MANIFEST_DIR -o $$TMP_DIR ;\
275+
mkdir -p docs/api ;\
276+
for crdmanifest in $$TMP_DIR/*; do \
277+
filename="$$(basename -s .networking.datumapis.com.yaml $$crdmanifest)" ;\
278+
filename="$${filename#apiextensions.k8s.io_v1_customresourcedefinition_}" ;\
279+
$(CRDOC) --resources $$crdmanifest --output docs/api/$$filename.md ;\
280+
done;\
281+
}

0 commit comments

Comments
 (0)