-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] ClusterClass support in CAPX #334
Closed
deepakm-ntnx
wants to merge
24
commits into
nutanix-cloud-native:main
from
deepakm-ntnx:clusterclassv4
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
16e67be
created scaffolding for go/v4
deepakm-ntnx a60f330
upgrade client-go and gingko to remove cve
deepakm-ntnx 6cafa44
updated location of new layout folder
deepakm-ntnx 0d64077
updated go.sum
deepakm-ntnx ecbe3ba
[WIP] added NutanixClusterTemplate API
deepakm-ntnx ea672f4
WIP clusterclass changes
deepakm-ntnx 544e2be
added generated template file
deepakm-ntnx 133068f
fixed docker-build`
deepakm-ntnx 0d03986
upgraded kustomize to latest
deepakm-ntnx 6eb8304
reorg of existing controllers to new gov4 format
deepakm-ntnx ee8a325
fixed the kustomize yamls with latest version
deepakm-ntnx 14cf676
added webhook for NutanixClusterTemplate
deepakm-ntnx 9c92eaf
added webhooks to make clusterclass work
deepakm-ntnx 513551a
enabled webhook
deepakm-ntnx 618b868
merged latest main
deepakm-ntnx 1604859
upgraded controller-gen to fix creationTimestamp issue
deepakm-ntnx 133d541
added webhook for nutanixmachinetemplate
deepakm-ntnx e7e812f
corrected kubebuilder annotations
deepakm-ntnx 180a1eb
fixed the stack overflow issue
deepakm-ntnx 5691e64
merged latest master changes to this branch
deepakm-ntnx ea91bc2
now webhooks are working
deepakm-ntnx 24decba
added missing failureDomain in the template
deepakm-ntnx 9cfc372
fixed the paths in newer tests after rebasing with master
deepakm-ntnx 7293c11
test fixes
deepakm-ntnx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ PLATFORMS_E2E ?= linux/amd64 | |
KIND_CLUSTER_NAME ?= capi-test | ||
|
||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.23 | ||
ENVTEST_K8S_VERSION = 1.28.0 | ||
|
||
# | ||
# Directories. | ||
|
@@ -66,9 +66,9 @@ KO := $(abspath $(TOOLS_BIN_DIR)/$(KO_BIN)-$(KO_VER)) | |
KO_PKG := github.com/google/ko | ||
|
||
KUSTOMIZE_BIN := kustomize | ||
KUSTOMIZE_VER := v4.5.4 | ||
KUSTOMIZE_VER := v5.2.1 | ||
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)) | ||
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v4 | ||
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5 | ||
|
||
GINGKO_VER := v2.1.4 | ||
GINKGO_BIN := ginkgo | ||
|
@@ -80,7 +80,7 @@ SETUP_ENVTEST_BIN := setup-envtest | |
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER)) | ||
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest | ||
|
||
CONTROLLER_GEN_VER := v0.8.0 | ||
CONTROLLER_GEN_VER := v0.13.0 | ||
CONTROLLER_GEN_BIN := controller-gen | ||
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)) | ||
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen | ||
|
@@ -210,8 +210,8 @@ generate: controller-gen conversion-gen ## Generate code containing DeepCopy, De | |
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
||
$(CONVERSION_GEN) \ | ||
--input-dirs=./api/v1alpha4 \ | ||
--input-dirs=./api/v1beta1 \ | ||
--input-dirs=./api/infrastructure/v1alpha4 \ | ||
--input-dirs=./api/infrastructure/v1beta1 \ | ||
--build-tag=ignore_autogenerated_core \ | ||
--output-file-base=zz_generated.conversion \ | ||
--go-header-file=./hack/boilerplate.go.txt | ||
|
@@ -235,25 +235,25 @@ kind-delete: ## Delete the kind cluster | |
.PHONY: build | ||
build: generate fmt ## Build manager binary. | ||
GIT_COMMIT_HASH=`git rev-parse HEAD` && \ | ||
go build -ldflags "-X main.gitCommitHash=$${GIT_COMMIT_HASH}" -o bin/manager main.go | ||
go build -ldflags "-X main.gitCommitHash=$${GIT_COMMIT_HASH}" -o bin/manager cmd/main.go | ||
|
||
.PHONY: run | ||
run: manifests generate fmt vet ## Run a controller from your host. | ||
go run ./main.go | ||
go run cmd/main.go | ||
|
||
.PHONY: docker-build | ||
docker-build: $(KO) ## Build docker image with the manager. | ||
GIT_COMMIT_HASH=`git rev-parse HEAD` && \ | ||
KO_DOCKER_REPO=ko.local GOFLAGS="-ldflags=-X=main.gitCommitHash=$${GIT_COMMIT_HASH}" $(KO) build -B --platform=${PLATFORMS} -t ${IMG_TAG} -L . | ||
KO_DOCKER_REPO=ko.local GOFLAGS="-ldflags=-X=main.gitCommitHash=$${GIT_COMMIT_HASH}" $(KO) build -B --platform=${PLATFORMS} -t ${IMG_TAG} -L ./cmd | ||
|
||
.PHONY: docker-push | ||
docker-push: $(KO) ## Push docker image with the manager. | ||
KO_DOCKER_REPO=${IMG_REPO} $(KO) build --bare --platform=${PLATFORMS} -t ${IMG_TAG} . | ||
KO_DOCKER_REPO=${IMG_REPO} $(KO) build --bare --platform=${PLATFORMS} -t ${IMG_TAG} ./cmd | ||
|
||
.PHONY: docker-push-kind | ||
docker-push-kind: $(KO) ## Make docker image available to kind cluster. | ||
GOOS=linux GOARCH=${shell go env GOARCH} KO_DOCKER_REPO=ko.local ${KO} build -B -t ${IMG_TAG} -L . | ||
docker tag ko.local/cluster-api-provider-nutanix:${IMG_TAG} ${IMG} | ||
GOOS=linux GOARCH=${shell go env GOARCH} KO_DOCKER_REPO=ko.local ${KO} build -B -t ${IMG_TAG} -L ./cmd | ||
docker tag ko.local/cmd:${IMG_TAG} ${IMG} | ||
kind load docker-image --name ${KIND_CLUSTER_NAME} ${IMG} | ||
|
||
##@ Deployment | ||
|
@@ -272,7 +272,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified | |
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
||
.PHONY: deploy | ||
deploy: manifests kustomize docker-push-kind ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||
deploy: manifests kustomize docker-push-kind prepare-local-clusterctl ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||
clusterctl delete --infrastructure nutanix:${LOCAL_PROVIDER_VERSION} --include-crd || true | ||
clusterctl init --infrastructure nutanix:${LOCAL_PROVIDER_VERSION} -v 9 | ||
# cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
|
@@ -328,14 +328,15 @@ cluster-templates: $(KUSTOMIZE) ## Generate cluster templates for all flavors | |
$(KUSTOMIZE) build $(TEMPLATES_DIR)/base > $(TEMPLATES_DIR)/cluster-template.yaml | ||
$(KUSTOMIZE) build $(TEMPLATES_DIR)/csi > $(TEMPLATES_DIR)/cluster-template-csi.yaml | ||
$(KUSTOMIZE) build $(TEMPLATES_DIR)/ccm > $(TEMPLATES_DIR)/cluster-template-ccm.yaml | ||
$(KUSTOMIZE) build $(TEMPLATES_DIR)/clusterclass > $(TEMPLATES_DIR)/cluster-template-clusterclass.yaml | ||
|
||
##@ Testing | ||
|
||
.PHONY: docker-build-e2e | ||
docker-build-e2e: $(KO) ## Build docker image with the manager with e2e tag. | ||
GIT_COMMIT_HASH=`git rev-parse HEAD` && \ | ||
KO_DOCKER_REPO=ko.local GOFLAGS="-ldflags=-X=main.gitCommitHash=$${GIT_COMMIT_HASH}" $(KO) build -B --platform=${PLATFORMS_E2E} -t e2e -L . | ||
docker tag ko.local/cluster-api-provider-nutanix:e2e ${IMG_REPO}:e2e | ||
KO_DOCKER_REPO=ko.local GOFLAGS="-ldflags=-X=main.gitCommitHash=$${GIT_COMMIT_HASH}" $(KO) build -B --platform=${PLATFORMS_E2E} -t e2e -L ./cmd | ||
docker tag ko.local/cmd:e2e ${IMG_REPO}:e2e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copy paste mistake |
||
|
||
.PHONY: prepare-local-clusterctl | ||
prepare-local-clusterctl: manifests kustomize cluster-templates ## Prepare overide file for local clusterctl. | ||
|
@@ -392,6 +393,35 @@ test-kubectl-workload: ## Run kubectl queries to get all capx workload related o | |
kubectl -n ${TEST_NAMESPACE} get secret ${TEST_CLUSTER_NAME}-kubeconfig -o json | jq -r .data.value | base64 --decode > ${TEST_CLUSTER_NAME}.workload.kubeconfig | ||
kubectl --kubeconfig ./${TEST_CLUSTER_NAME}.workload.kubeconfig get nodes,ns | ||
|
||
.PHONY: test-clusterclass-create | ||
test-clusterclass-create: cluster-templates | ||
clusterctl generate cluster ccls-test1 --from ./templates/cluster-template-clusterclass.yaml -n $(TEST_NAMESPACE) > ccls-test1.yaml | ||
kubectl create ns $(TEST_NAMESPACE) || true | ||
kubectl apply -f ./ccls-test1.yaml | ||
|
||
.PHONY: test-clusterclass-delete | ||
test-clusterclass-delete: | ||
kubectl -n $(TEST_NAMESPACE) delete cluster ccls-test1 || true | ||
kubectl -n $(TEST_NAMESPACE) delete nutanixcluster ccls-test1 || true | ||
kubectl -n $(TEST_NAMESPACE) delete clusterclass my-test-cluster-template || true | ||
kubectl -n $(TEST_NAMESPACE) delete nutanixmachinetemplate my-test-cluster-template-cp-nmt || true | ||
kubectl -n $(TEST_NAMESPACE) delete nutanixmachinetemplate my-test-cluster-template-md-nmt || true | ||
kubectl -n $(TEST_NAMESPACE) delete KubeadmConfigTemplate my-test-cluster-template-md-kcfgt || true | ||
kubectl -n $(TEST_NAMESPACE) delete kubeadmcontrolplanetemplate my-test-cluster-template-kcpt || true | ||
kubectl -n $(TEST_NAMESPACE) delete NutanixClustertemplate my-test-cluster-template-nct || true | ||
# kubectl -n $(TEST_NAMESPACE) delete secret ccls-test1 | ||
kubectl -n $(TEST_NAMESPACE) delete cm user-ca-bundle | ||
rm ccls-test1.yaml || true | ||
|
||
|
||
.PHONY: test-kubectl-clusterclass | ||
test-kubectl-clusterclass: | ||
kubectl -n capx-system get endpoints | ||
kubectl -n $(TEST_NAMESPACE) get cluster,machine,MachineDeployment | ||
kubectl -n $(TEST_NAMESPACE) get NutanixCluster,NutanixMachine -n $(TEST_NAMESPACE) | ||
kubectl -n $(TEST_NAMESPACE) get NutanixClusterTemplate,clusterclass,KubeadmConfigTemplate,KubeadmControlPlaneTemplate,NutanixMachineTemplate,secret,configmap -n $(TEST_NAMESPACE) | ||
kubectl -n $(TEST_NAMESPACE) get ValidatingWebhookConfiguration,MutatingWebhookConfiguration | ||
|
||
.PHONY: ginkgo-help | ||
ginkgo-help: | ||
$(GINKGO) help run | ||
|
@@ -513,7 +543,11 @@ $(KO): # Build ko from tools folder. | |
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KO_PKG) $(KO_BIN) $(KO_VER) | ||
|
||
$(KUSTOMIZE): # Build kustomize from tools folder. | ||
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER) | ||
@if test -x $(KUSTOMIZE) && ! $(KUSTOMIZE) version | grep -q $(KUSTOMIZE_VERSION); then \ | ||
echo "$(KUSTOMIZE) version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \ | ||
rm -rf $(KUSTOMIZE); \ | ||
fi | ||
test -s $(KUSTOMIZE) || GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER) | ||
|
||
.PHONY: $(KO_BIN) | ||
$(KO_BIN): $(KO) ## Build a local copy of ko | ||
|
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
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
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
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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
api/v1alpha4/zz_generated.conversion.go → ...cture/v1alpha4/zz_generated.conversion.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy paste mistake.