Skip to content

Commit

Permalink
capx clusterclass support
Browse files Browse the repository at this point in the history
have kept the go/v3 kuberbuilder scffolding as is so reduce the code
churn
  • Loading branch information
deepakm-ntnx committed Dec 11, 2023
1 parent 7f5909c commit 8594642
Show file tree
Hide file tree
Showing 18 changed files with 1,255 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -328,6 +328,7 @@ 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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: cluster.x-k8s.io
layout:
- go.kubebuilder.io/v3
Expand Down Expand Up @@ -30,4 +34,12 @@ resources:
kind: NutanixMachineTemplate
path: github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1alpha4
version: v1alpha4
- api:
crdVersion: v1
namespaced: true
domain: cluster.x-k8s.io
group: infrastructure
kind: NutanixClusterTemplate
path: github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1
version: v1beta1
version: "3"
67 changes: 67 additions & 0 deletions api/v1beta1/nutanixclustertemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright 2022 Nutanix
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// NutanixClusterTemplateSpec defines the desired state of NutanixClusterTemplate
type NutanixClusterTemplateSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Template NutanixClusterTemplateResource `json:"template"`
}

// NutanixClusterTemplateStatus defines the observed state of NutanixClusterTemplate
type NutanixClusterTemplateStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// NutanixClusterTemplate is the Schema for the nutanixclustertemplates API
type NutanixClusterTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NutanixClusterTemplateSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

// NutanixClusterTemplateList contains a list of NutanixClusterTemplate
type NutanixClusterTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NutanixClusterTemplate `json:"items"`
}

func init() {
SchemeBuilder.Register(&NutanixClusterTemplate{}, &NutanixClusterTemplateList{})
}

// NutanixClusterTemplateResource describes the data needed to create a NutanixCluster from a template.
type NutanixClusterTemplateResource struct {
Spec NutanixClusterSpec `json:"spec"`
}
105 changes: 105 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8594642

Please sign in to comment.