From 1e126bbbd3a708fa95666ed2253c6d60cc079dc8 Mon Sep 17 00:00:00 2001 From: Andrea Mazzotti Date: Wed, 8 May 2024 11:21:36 +0200 Subject: [PATCH] Add v1beta2 version and implement KThreesControlPlaneTemplate Signed-off-by: Andrea Mazzotti --- .github/workflows/pr.yaml | 2 +- .github/workflows/release.yaml | 2 +- Makefile | 35 +- bootstrap/PROJECT | 6 + bootstrap/api/v1beta1/conversion.go | 94 +++ bootstrap/api/v1beta1/conversion_test.go | 45 ++ bootstrap/api/v1beta1/doc.go | 22 + bootstrap/api/v1beta1/groupversion_info.go | 10 +- bootstrap/api/v1beta1/kthreesconfig_types.go | 1 - .../api/v1beta1/zz_generated.conversion.go | 544 +++++++++++++++++ .../api/v1beta1/zz_generated.deepcopy.go | 2 +- bootstrap/api/v1beta2/condition_consts.go | 71 +++ bootstrap/api/v1beta2/conversion.go | 29 + bootstrap/api/v1beta2/doc.go | 21 + bootstrap/api/v1beta2/groupversion_info.go | 33 + bootstrap/api/v1beta2/kthreesconfig_types.go | 270 +++++++++ .../api/v1beta2/kthreesconfig_webhook.go | 56 ++ .../v1beta2/kthreesconfigtemplate_types.go | 57 ++ .../v1beta2/kthreesconfigtemplate_webhook.go | 56 ++ .../api/v1beta2/zz_generated.deepcopy.go | 367 +++++++++++ bootstrap/config/certmanager/certificate.yaml | 8 +- .../config/certmanager/kustomizeconfig.yaml | 3 + ...strap.cluster.x-k8s.io_kthreesconfigs.yaml | 280 +++++++++ ...uster.x-k8s.io_kthreesconfigtemplates.yaml | 227 +++++++ ...cluster.x-k8s.io_kthreescontrolplanes.yaml | 572 ++++++++++++++++-- bootstrap/config/crd/kustomization.yaml | 10 +- bootstrap/config/crd/kustomizeconfig.yaml | 22 +- .../cainjection_in_kthreesconfigs.yaml | 3 +- ...cainjection_in_kthreesconfigtemplates.yaml | 3 +- .../patches/webhook_in_kthreesconfigs.yaml | 22 +- .../webhook_in_kthreesconfigtemplates.yaml | 22 +- bootstrap/config/default/kustomization.yaml | 65 +- bootstrap/config/default/kustomizeconfig.yaml | 4 + .../config/default/manager_webhook_patch.yaml | 2 +- .../default/webhookcainjection_patch.yaml | 4 +- bootstrap/config/rbac/role.yaml | 65 -- bootstrap/config/webhook/manifests.yaml | 100 +++ .../controllers/kthreesconfig_controller.go | 2 +- bootstrap/controllers/suite_test.go | 5 +- bootstrap/main.go | 13 + controlplane/PROJECT | 6 + controlplane/api/v1beta1/condition_consts.go | 2 +- controlplane/api/v1beta1/conversion.go | 107 ++++ controlplane/api/v1beta1/conversion_test.go | 39 ++ controlplane/api/v1beta1/doc.go | 22 + controlplane/api/v1beta1/groupversion_info.go | 6 +- .../api/v1beta1/zz_generated.conversion.go | 335 ++++++++++ .../api/v1beta1/zz_generated.deepcopy.go | 2 +- controlplane/api/v1beta2/condition_consts.go | 130 ++++ controlplane/api/v1beta2/conversion.go | 23 + controlplane/api/v1beta2/doc.go | 21 + controlplane/api/v1beta2/groupversion_info.go | 33 + .../api/v1beta2/kthreescontrolplane_types.go | 270 +++++++++ .../v1beta2/kthreescontrolplane_webhook.go | 56 ++ .../kthreescontrolplanetemplate_types.go | 82 +++ .../api/v1beta2/zz_generated.deepcopy.go | 330 ++++++++++ .../config/certmanager/certificate.yaml | 8 +- .../config/certmanager/kustomizeconfig.yaml | 3 + ...strap.cluster.x-k8s.io_kthreesconfigs.yaml | 268 ++++++++ ...uster.x-k8s.io_kthreesconfigtemplates.yaml | 215 +++++++ ...cluster.x-k8s.io_kthreescontrolplanes.yaml | 542 +++++++++++++++++ ...x-k8s.io_kthreescontrolplanetemplates.yaml | 404 +++++++++++++ controlplane/config/crd/kustomization.yaml | 7 +- controlplane/config/crd/kustomizeconfig.yaml | 22 +- .../cainjection_in_kthreescontrolplanes.yaml | 3 +- .../webhook_in_kthreescontrolplanes.yaml | 22 +- .../config/default/kustomization.yaml | 64 +- .../config/default/kustomizeconfig.yaml | 4 + .../config/default/manager_webhook_patch.yaml | 2 +- .../default/webhookcainjection_patch.yaml | 4 +- controlplane/config/rbac/role.yaml | 58 -- controlplane/config/webhook/manifests.yaml | 56 ++ .../kthreescontrolplane_controller.go | 4 +- controlplane/controllers/remediation.go | 2 +- controlplane/controllers/scale.go | 8 +- controlplane/controllers/suite_test.go | 5 +- controlplane/main.go | 11 + pkg/cloudinit/cloudinit.go | 2 +- pkg/cloudinit/controlplane_init_test.go | 2 +- pkg/k3s/config.go | 2 +- pkg/k3s/control_plane.go | 6 +- pkg/k3s/workload_cluster.go | 2 +- pkg/k3s/workload_cluster_coredns.go | 2 +- pkg/machinefilters/machine_filters.go | 8 +- pkg/secret/certificates.go | 2 +- 85 files changed, 6006 insertions(+), 351 deletions(-) create mode 100644 bootstrap/api/v1beta1/conversion.go create mode 100644 bootstrap/api/v1beta1/conversion_test.go create mode 100644 bootstrap/api/v1beta1/doc.go create mode 100644 bootstrap/api/v1beta1/zz_generated.conversion.go create mode 100644 bootstrap/api/v1beta2/condition_consts.go create mode 100644 bootstrap/api/v1beta2/conversion.go create mode 100644 bootstrap/api/v1beta2/doc.go create mode 100644 bootstrap/api/v1beta2/groupversion_info.go create mode 100644 bootstrap/api/v1beta2/kthreesconfig_types.go create mode 100644 bootstrap/api/v1beta2/kthreesconfig_webhook.go create mode 100644 bootstrap/api/v1beta2/kthreesconfigtemplate_types.go create mode 100644 bootstrap/api/v1beta2/kthreesconfigtemplate_webhook.go create mode 100644 bootstrap/api/v1beta2/zz_generated.deepcopy.go create mode 100644 bootstrap/config/default/kustomizeconfig.yaml create mode 100644 bootstrap/config/webhook/manifests.yaml create mode 100644 controlplane/api/v1beta1/conversion.go create mode 100644 controlplane/api/v1beta1/conversion_test.go create mode 100644 controlplane/api/v1beta1/doc.go create mode 100644 controlplane/api/v1beta1/zz_generated.conversion.go create mode 100644 controlplane/api/v1beta2/condition_consts.go create mode 100644 controlplane/api/v1beta2/conversion.go create mode 100644 controlplane/api/v1beta2/doc.go create mode 100644 controlplane/api/v1beta2/groupversion_info.go create mode 100644 controlplane/api/v1beta2/kthreescontrolplane_types.go create mode 100644 controlplane/api/v1beta2/kthreescontrolplane_webhook.go create mode 100644 controlplane/api/v1beta2/kthreescontrolplanetemplate_types.go create mode 100644 controlplane/api/v1beta2/zz_generated.deepcopy.go create mode 100644 controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml create mode 100644 controlplane/config/default/kustomizeconfig.yaml create mode 100644 controlplane/config/webhook/manifests.yaml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index c111f4ad..21fe3fc2 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -24,7 +24,7 @@ jobs: - uses: actions/setup-go@v4 with: - go-version-file: "./go.mod" + go-version-file: go.mod cache: true - name: ${{ matrix.target }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7582b39d..e0e32aa5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -101,7 +101,7 @@ jobs: - uses: actions/setup-go@v4 with: - go-version: "${{ env.GO_VERSION }}" + go-version-file: go.mod cache: true - uses: actions/cache@v3 diff --git a/Makefile b/Makefile index 777efcca..70e893c2 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,11 @@ CONTROLLER_GEN_VER := v0.14.0 CONTROLLER_GEN_BIN := controller-gen CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER) +# Sync +CONVERSION_GEN_VER := v0.29.0 +CONVERSION_GEN_BIN := conversion-gen +CONVERSION_GEN := $(TOOLS_BIN_DIR)/$(CONVERSION_GEN_BIN)-$(CONVERSION_GEN_VER) + # Sync to github.com/drone/envsubst/v2 in https://github.com/kubernetes-sigs/cluster-api/blob/v{VERSION}/go.mod ENVSUBST_VER := v2.0.0-20210730161058-179042472c46 ENVSUBST_BIN := envsubst @@ -154,7 +159,7 @@ test-common: all-bootstrap: manager-bootstrap # Run tests -test-bootstrap: envtest generate-bootstrap lint manifests-bootstrap +test-bootstrap: envtest generate-bootstrap generate-bootstrap-conversions lint manifests-bootstrap KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(TOOLS_BIN_DIR) -p path)" go test $(shell pwd)/bootstrap/... -coverprofile cover.out # Build manager binary @@ -180,7 +185,7 @@ deploy-bootstrap: manifests-bootstrap # Generate manifests e.g. CRD, RBAC etc. manifests-bootstrap: $(KUSTOMIZE) $(CONTROLLER_GEN) - $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=bootstrap/config/crd/bases output:rbac:dir=bootstrap/config/rbac + $(CONTROLLER_GEN) paths=./bootstrap/... rbac:roleName=manager-role crd webhook output:crd:artifacts:config=bootstrap/config/crd/bases output:rbac:dir=bootstrap/config/rbac output:webhook:dir=bootstrap/config/webhook release-bootstrap:$(RELEASE_DIR) manifests-bootstrap ## Release bootstrap cd bootstrap/config/manager && $(KUSTOMIZE) edit set image controller=${BOOTSTRAP_IMG}:${BOOTSTRAP_IMG_TAG} @@ -190,6 +195,15 @@ release-bootstrap:$(RELEASE_DIR) manifests-bootstrap ## Release bootstrap generate-bootstrap: $(CONTROLLER_GEN) $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="$(shell pwd)/bootstrap/..." +generate-bootstrap-conversions: $(CONVERSION_GEN) + $(CONVERSION_GEN) \ + --input-dirs=./bootstrap/api/v1beta1 \ + --extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \ + --build-tag=ignore_autogenerated_conversions \ + --output-file-base=zz_generated.conversion \ + --output-base=./ \ + --go-header-file=./hack/boilerplate.go.txt + # Build the docker image docker-build-bootstrap: manager-bootstrap ## Build bootstrap DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg TARGETARCH=$(ARCH) --build-arg package=./bootstrap/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${BOOTSTRAP_IMG}:${BOOTSTRAP_IMG_TAG} @@ -201,7 +215,7 @@ docker-push-bootstrap: ## Push bootstrap all-controlplane: manager-controlplane # Run tests -test-controlplane: envtest generate-controlplane lint manifests-controlplane +test-controlplane: envtest generate-controlplane generate-controlplane-conversions lint manifests-controlplane KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(TOOLS_BIN_DIR) -p path)" go test $(shell pwd)/controlplane/... -coverprofile cover.out .PHONY: docker-build-e2e @@ -244,7 +258,7 @@ deploy-controlplane: manifests-controlplane # Generate manifests e.g. CRD, RBAC etc. manifests-controlplane: $(KUSTOMIZE) $(CONTROLLER_GEN) - $(CONTROLLER_GEN) rbac:roleName=manager-role webhook crd paths="./..." output:crd:artifacts:config=controlplane/config/crd/bases output:rbac:dir=controlplane/config/rbac + $(CONTROLLER_GEN) paths=./controlplane/... rbac:roleName=manager-role webhook crd output:crd:artifacts:config=controlplane/config/crd/bases output:rbac:dir=controlplane/config/rbac output:webhook:dir=controlplane/config/webhook release-controlplane: $(RELEASE_DIR) manifests-controlplane ## Release control-plane cd controlplane/config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLPLANE_IMG}:$(CONTROLPLANE_IMG_TAG) @@ -253,6 +267,16 @@ release-controlplane: $(RELEASE_DIR) manifests-controlplane ## Release control-p generate-controlplane: $(CONTROLLER_GEN) $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="$(shell pwd)/controlplane/..." +generate-controlplane-conversions: $(CONVERSION_GEN) + $(CONVERSION_GEN) \ + --input-dirs=./controlplane/api/v1beta1 \ + --extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \ + --extra-peer-dirs=github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1 \ + --build-tag=ignore_autogenerated_conversions \ + --output-file-base=zz_generated.conversion \ + --output-base=./ \ + --go-header-file=./hack/boilerplate.go.txt + docker-build-controlplane: manager-controlplane ## Build control-plane DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg TARGETARCH=$(ARCH) --build-arg package=./controlplane/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${CONTROLPLANE_IMG}:$(CONTROLPLANE_IMG_TAG) @@ -317,3 +341,6 @@ $(KUSTOMIZE): ## Put kustomize into tools folder. $(CONTROLLER_GEN): ## Build controller-gen from tools folder. GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/controller-tools/cmd/controller-gen $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER) + +$(CONVERSION_GEN): ## Build conversion-gen from tools folder. + GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/code-generator/cmd/conversion-gen $(CONVERSION_GEN_BIN) $(CONVERSION_GEN_VER) diff --git a/bootstrap/PROJECT b/bootstrap/PROJECT index 7076e096..3fd1bd16 100644 --- a/bootstrap/PROJECT +++ b/bootstrap/PROJECT @@ -4,7 +4,13 @@ resources: - group: bootstrap kind: KThreesConfig version: v1beta1 +- group: bootstrap + kind: KThreesConfig + version: v1beta2 - group: bootstrap kind: KThreesConfigTemplate version: v1beta1 +- group: bootstrap + kind: KThreesConfigTemplate + version: v1beta2 version: "2" diff --git a/bootstrap/api/v1beta1/conversion.go b/bootstrap/api/v1beta1/conversion.go new file mode 100644 index 00000000..375ba565 --- /dev/null +++ b/bootstrap/api/v1beta1/conversion.go @@ -0,0 +1,94 @@ +/* +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 ( + "fmt" + + "sigs.k8s.io/controller-runtime/pkg/conversion" + + cabp3v1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" +) + +// ConvertTo converts the v1beta1 KThreesConfig receiver to a v1beta2 KThreesConfig. +func (c *KThreesConfig) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*cabp3v1.KThreesConfig) + if err := autoConvert_v1beta1_KThreesConfig_To_v1beta2_KThreesConfig(c, dst, nil); err != nil { + return fmt.Errorf("converting KThreesConfig v1beta1 to v1beta2: %w", err) + } + return nil +} + +// ConvertFrom converts the v1beta1 KThreesConfig receiver from a v1beta2 KThreesConfig. +func (c *KThreesConfig) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*cabp3v1.KThreesConfig) + if err := autoConvert_v1beta2_KThreesConfig_To_v1beta1_KThreesConfig(src, c, nil); err != nil { + return fmt.Errorf("converting KThreesConfig v1beta1 from v1beta2: %w", err) + } + return nil +} + +// ConvertTo converts the v1beta1 KThreesConfigList receiver to a v1beta2 KThreesConfigList. +func (c *KThreesConfigList) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*cabp3v1.KThreesConfigList) + if err := autoConvert_v1beta1_KThreesConfigList_To_v1beta2_KThreesConfigList(c, dst, nil); err != nil { + return fmt.Errorf("converting KThreesConfigList v1beta1 to v1beta2: %w", err) + } + return nil +} + +// ConvertFrom converts the v1beta1 KThreesConfigList receiver from a v1beta2 KThreesConfigList. +func (c *KThreesConfigList) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*cabp3v1.KThreesConfigList) + if err := autoConvert_v1beta2_KThreesConfigList_To_v1beta1_KThreesConfigList(src, c, nil); err != nil { + return fmt.Errorf("converting KThreesConfigList v1beta1 from v1beta2: %w", err) + } + return nil +} + +// ConvertTo converts the v1beta1 KThreesConfigTemplate receiver to a v1beta2 KThreesConfigTemplate. +func (r *KThreesConfigTemplate) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*cabp3v1.KThreesConfigTemplate) + if err := autoConvert_v1beta1_KThreesConfigTemplate_To_v1beta2_KThreesConfigTemplate(r, dst, nil); err != nil { + return fmt.Errorf("converting KThreesConfigTemplate v1beta1 to v1beta2: %w", err) + } + return nil +} + +// ConvertFrom converts the v1beta1 KThreesConfigTemplate receiver from a v1beta2 KThreesConfigTemplate. +func (r *KThreesConfigTemplate) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*cabp3v1.KThreesConfigTemplate) + if err := autoConvert_v1beta2_KThreesConfigTemplate_To_v1beta1_KThreesConfigTemplate(src, r, nil); err != nil { + return fmt.Errorf("converting KThreesConfigTemplate v1beta1 from v1beta2: %w", err) + } + return nil +} + +// ConvertTo converts the v1beta1 KThreesConfigTemplateList receiver to a v1beta2 KThreesConfigTemplateList. +func (r *KThreesConfigTemplateList) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*cabp3v1.KThreesConfigTemplateList) + if err := autoConvert_v1beta1_KThreesConfigTemplateList_To_v1beta2_KThreesConfigTemplateList(r, dst, nil); err != nil { + return fmt.Errorf("converting KThreesConfigTemplateList v1beta1 to v1beta2: %w", err) + } + return nil +} + +// ConvertFrom converts the v1beta1 KThreesConfigTemplateList receiver from a v1beta2 KThreesConfigTemplateList. +func (r *KThreesConfigTemplateList) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*cabp3v1.KThreesConfigTemplateList) + if err := autoConvert_v1beta2_KThreesConfigTemplateList_To_v1beta1_KThreesConfigTemplateList(src, r, nil); err != nil { + return fmt.Errorf("converting KThreesConfigTemplateList v1beta1 from v1beta2: %w", err) + } + return nil +} diff --git a/bootstrap/api/v1beta1/conversion_test.go b/bootstrap/api/v1beta1/conversion_test.go new file mode 100644 index 00000000..65bd9f93 --- /dev/null +++ b/bootstrap/api/v1beta1/conversion_test.go @@ -0,0 +1,45 @@ +/* +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 ( + "testing" + + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + "k8s.io/apimachinery/pkg/runtime" + utilconversion "sigs.k8s.io/cluster-api/util/conversion" + + cabp3v1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" +) + +func TestFuzzyConversion(t *testing.T) { + g := NewWithT(t) + scheme := runtime.NewScheme() + g.Expect(AddToScheme(scheme)).To(Succeed()) + g.Expect(cabp3v1.AddToScheme(scheme)).To(Succeed()) + + t.Run("for KThreesConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ + Scheme: scheme, + Hub: &cabp3v1.KThreesConfig{}, + Spoke: &KThreesConfig{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + })) + t.Run("for KThreesConfigTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ + Scheme: scheme, + Hub: &cabp3v1.KThreesConfigTemplate{}, + Spoke: &KThreesConfigTemplate{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + })) +} diff --git a/bootstrap/api/v1beta1/doc.go b/bootstrap/api/v1beta1/doc.go new file mode 100644 index 00000000..e2fa1448 --- /dev/null +++ b/bootstrap/api/v1beta1/doc.go @@ -0,0 +1,22 @@ +/* + + +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 contains API Schema definitions for the bootstrap v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=bootstrap.cluster.x-k8s.io +// +k8s:defaulter-gen=TypeMeta +// +k8s:conversion-gen=github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2 +package v1beta1 diff --git a/bootstrap/api/v1beta1/groupversion_info.go b/bootstrap/api/v1beta1/groupversion_info.go index dde1946a..e762e1a1 100644 --- a/bootstrap/api/v1beta1/groupversion_info.go +++ b/bootstrap/api/v1beta1/groupversion_info.go @@ -1,11 +1,9 @@ /* - - 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 + 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, @@ -14,9 +12,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1beta1 contains API Schema definitions for the bootstrap v1beta1 API group -// +kubebuilder:object:generate=true -// +groupName=bootstrap.cluster.x-k8s.io package v1beta1 import ( @@ -33,4 +28,7 @@ var ( // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme + + // localSchemeBuilder is used by the conversion-gen tool. + localSchemeBuilder = SchemeBuilder.SchemeBuilder ) diff --git a/bootstrap/api/v1beta1/kthreesconfig_types.go b/bootstrap/api/v1beta1/kthreesconfig_types.go index 433269ce..f9436f37 100644 --- a/bootstrap/api/v1beta1/kthreesconfig_types.go +++ b/bootstrap/api/v1beta1/kthreesconfig_types.go @@ -21,7 +21,6 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) -// 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. // KThreesConfigSpec defines the desired state of KThreesConfig. diff --git a/bootstrap/api/v1beta1/zz_generated.conversion.go b/bootstrap/api/v1beta1/zz_generated.conversion.go new file mode 100644 index 00000000..8c96100d --- /dev/null +++ b/bootstrap/api/v1beta1/zz_generated.conversion.go @@ -0,0 +1,544 @@ +//go:build !ignore_autogenerated_conversions +// +build !ignore_autogenerated_conversions + +/* + + +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. +*/ +// Code generated by conversion-gen-v0.29.0. DO NOT EDIT. + +package v1beta1 + +import ( + unsafe "unsafe" + + v1beta2 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*File)(nil), (*v1beta2.File)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_File_To_v1beta2_File(a.(*File), b.(*v1beta2.File), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.File)(nil), (*File)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_File_To_v1beta1_File(a.(*v1beta2.File), b.(*File), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*FileSource)(nil), (*v1beta2.FileSource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_FileSource_To_v1beta2_FileSource(a.(*FileSource), b.(*v1beta2.FileSource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.FileSource)(nil), (*FileSource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_FileSource_To_v1beta1_FileSource(a.(*v1beta2.FileSource), b.(*FileSource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesAgentConfig)(nil), (*v1beta2.KThreesAgentConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesAgentConfig_To_v1beta2_KThreesAgentConfig(a.(*KThreesAgentConfig), b.(*v1beta2.KThreesAgentConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesAgentConfig)(nil), (*KThreesAgentConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesAgentConfig_To_v1beta1_KThreesAgentConfig(a.(*v1beta2.KThreesAgentConfig), b.(*KThreesAgentConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfig)(nil), (*v1beta2.KThreesConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfig_To_v1beta2_KThreesConfig(a.(*KThreesConfig), b.(*v1beta2.KThreesConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfig)(nil), (*KThreesConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfig_To_v1beta1_KThreesConfig(a.(*v1beta2.KThreesConfig), b.(*KThreesConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigList)(nil), (*v1beta2.KThreesConfigList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigList_To_v1beta2_KThreesConfigList(a.(*KThreesConfigList), b.(*v1beta2.KThreesConfigList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigList)(nil), (*KThreesConfigList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigList_To_v1beta1_KThreesConfigList(a.(*v1beta2.KThreesConfigList), b.(*KThreesConfigList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigSpec)(nil), (*v1beta2.KThreesConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(a.(*KThreesConfigSpec), b.(*v1beta2.KThreesConfigSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigSpec)(nil), (*KThreesConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(a.(*v1beta2.KThreesConfigSpec), b.(*KThreesConfigSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigStatus)(nil), (*v1beta2.KThreesConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigStatus_To_v1beta2_KThreesConfigStatus(a.(*KThreesConfigStatus), b.(*v1beta2.KThreesConfigStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigStatus)(nil), (*KThreesConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigStatus_To_v1beta1_KThreesConfigStatus(a.(*v1beta2.KThreesConfigStatus), b.(*KThreesConfigStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigTemplate)(nil), (*v1beta2.KThreesConfigTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigTemplate_To_v1beta2_KThreesConfigTemplate(a.(*KThreesConfigTemplate), b.(*v1beta2.KThreesConfigTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigTemplate)(nil), (*KThreesConfigTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigTemplate_To_v1beta1_KThreesConfigTemplate(a.(*v1beta2.KThreesConfigTemplate), b.(*KThreesConfigTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigTemplateList)(nil), (*v1beta2.KThreesConfigTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigTemplateList_To_v1beta2_KThreesConfigTemplateList(a.(*KThreesConfigTemplateList), b.(*v1beta2.KThreesConfigTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigTemplateList)(nil), (*KThreesConfigTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigTemplateList_To_v1beta1_KThreesConfigTemplateList(a.(*v1beta2.KThreesConfigTemplateList), b.(*KThreesConfigTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigTemplateResource)(nil), (*v1beta2.KThreesConfigTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigTemplateResource_To_v1beta2_KThreesConfigTemplateResource(a.(*KThreesConfigTemplateResource), b.(*v1beta2.KThreesConfigTemplateResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigTemplateResource)(nil), (*KThreesConfigTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigTemplateResource_To_v1beta1_KThreesConfigTemplateResource(a.(*v1beta2.KThreesConfigTemplateResource), b.(*KThreesConfigTemplateResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesConfigTemplateSpec)(nil), (*v1beta2.KThreesConfigTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigTemplateSpec_To_v1beta2_KThreesConfigTemplateSpec(a.(*KThreesConfigTemplateSpec), b.(*v1beta2.KThreesConfigTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesConfigTemplateSpec)(nil), (*KThreesConfigTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigTemplateSpec_To_v1beta1_KThreesConfigTemplateSpec(a.(*v1beta2.KThreesConfigTemplateSpec), b.(*KThreesConfigTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesServerConfig)(nil), (*v1beta2.KThreesServerConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesServerConfig_To_v1beta2_KThreesServerConfig(a.(*KThreesServerConfig), b.(*v1beta2.KThreesServerConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesServerConfig)(nil), (*KThreesServerConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesServerConfig_To_v1beta1_KThreesServerConfig(a.(*v1beta2.KThreesServerConfig), b.(*KThreesServerConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*SecretFileSource)(nil), (*v1beta2.SecretFileSource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_SecretFileSource_To_v1beta2_SecretFileSource(a.(*SecretFileSource), b.(*v1beta2.SecretFileSource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.SecretFileSource)(nil), (*SecretFileSource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_SecretFileSource_To_v1beta1_SecretFileSource(a.(*v1beta2.SecretFileSource), b.(*SecretFileSource), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1beta1_File_To_v1beta2_File(in *File, out *v1beta2.File, s conversion.Scope) error { + out.Path = in.Path + out.Owner = in.Owner + out.Permissions = in.Permissions + out.Encoding = v1beta2.Encoding(in.Encoding) + out.Content = in.Content + out.ContentFrom = (*v1beta2.FileSource)(unsafe.Pointer(in.ContentFrom)) + return nil +} + +// Convert_v1beta1_File_To_v1beta2_File is an autogenerated conversion function. +func Convert_v1beta1_File_To_v1beta2_File(in *File, out *v1beta2.File, s conversion.Scope) error { + return autoConvert_v1beta1_File_To_v1beta2_File(in, out, s) +} + +func autoConvert_v1beta2_File_To_v1beta1_File(in *v1beta2.File, out *File, s conversion.Scope) error { + out.Path = in.Path + out.Owner = in.Owner + out.Permissions = in.Permissions + out.Encoding = Encoding(in.Encoding) + out.Content = in.Content + out.ContentFrom = (*FileSource)(unsafe.Pointer(in.ContentFrom)) + return nil +} + +// Convert_v1beta2_File_To_v1beta1_File is an autogenerated conversion function. +func Convert_v1beta2_File_To_v1beta1_File(in *v1beta2.File, out *File, s conversion.Scope) error { + return autoConvert_v1beta2_File_To_v1beta1_File(in, out, s) +} + +func autoConvert_v1beta1_FileSource_To_v1beta2_FileSource(in *FileSource, out *v1beta2.FileSource, s conversion.Scope) error { + if err := Convert_v1beta1_SecretFileSource_To_v1beta2_SecretFileSource(&in.Secret, &out.Secret, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_FileSource_To_v1beta2_FileSource is an autogenerated conversion function. +func Convert_v1beta1_FileSource_To_v1beta2_FileSource(in *FileSource, out *v1beta2.FileSource, s conversion.Scope) error { + return autoConvert_v1beta1_FileSource_To_v1beta2_FileSource(in, out, s) +} + +func autoConvert_v1beta2_FileSource_To_v1beta1_FileSource(in *v1beta2.FileSource, out *FileSource, s conversion.Scope) error { + if err := Convert_v1beta2_SecretFileSource_To_v1beta1_SecretFileSource(&in.Secret, &out.Secret, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_FileSource_To_v1beta1_FileSource is an autogenerated conversion function. +func Convert_v1beta2_FileSource_To_v1beta1_FileSource(in *v1beta2.FileSource, out *FileSource, s conversion.Scope) error { + return autoConvert_v1beta2_FileSource_To_v1beta1_FileSource(in, out, s) +} + +func autoConvert_v1beta1_KThreesAgentConfig_To_v1beta2_KThreesAgentConfig(in *KThreesAgentConfig, out *v1beta2.KThreesAgentConfig, s conversion.Scope) error { + out.NodeLabels = *(*[]string)(unsafe.Pointer(&in.NodeLabels)) + out.NodeTaints = *(*[]string)(unsafe.Pointer(&in.NodeTaints)) + out.PrivateRegistry = in.PrivateRegistry + out.KubeletArgs = *(*[]string)(unsafe.Pointer(&in.KubeletArgs)) + out.KubeProxyArgs = *(*[]string)(unsafe.Pointer(&in.KubeProxyArgs)) + out.NodeName = in.NodeName + out.AirGapped = in.AirGapped + return nil +} + +// Convert_v1beta1_KThreesAgentConfig_To_v1beta2_KThreesAgentConfig is an autogenerated conversion function. +func Convert_v1beta1_KThreesAgentConfig_To_v1beta2_KThreesAgentConfig(in *KThreesAgentConfig, out *v1beta2.KThreesAgentConfig, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesAgentConfig_To_v1beta2_KThreesAgentConfig(in, out, s) +} + +func autoConvert_v1beta2_KThreesAgentConfig_To_v1beta1_KThreesAgentConfig(in *v1beta2.KThreesAgentConfig, out *KThreesAgentConfig, s conversion.Scope) error { + out.NodeLabels = *(*[]string)(unsafe.Pointer(&in.NodeLabels)) + out.NodeTaints = *(*[]string)(unsafe.Pointer(&in.NodeTaints)) + out.PrivateRegistry = in.PrivateRegistry + out.KubeletArgs = *(*[]string)(unsafe.Pointer(&in.KubeletArgs)) + out.KubeProxyArgs = *(*[]string)(unsafe.Pointer(&in.KubeProxyArgs)) + out.NodeName = in.NodeName + out.AirGapped = in.AirGapped + return nil +} + +// Convert_v1beta2_KThreesAgentConfig_To_v1beta1_KThreesAgentConfig is an autogenerated conversion function. +func Convert_v1beta2_KThreesAgentConfig_To_v1beta1_KThreesAgentConfig(in *v1beta2.KThreesAgentConfig, out *KThreesAgentConfig, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesAgentConfig_To_v1beta1_KThreesAgentConfig(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfig_To_v1beta2_KThreesConfig(in *KThreesConfig, out *v1beta2.KThreesConfig, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta1_KThreesConfigStatus_To_v1beta2_KThreesConfigStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_KThreesConfig_To_v1beta2_KThreesConfig is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfig_To_v1beta2_KThreesConfig(in *KThreesConfig, out *v1beta2.KThreesConfig, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfig_To_v1beta2_KThreesConfig(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfig_To_v1beta1_KThreesConfig(in *v1beta2.KThreesConfig, out *KThreesConfig, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta2_KThreesConfigStatus_To_v1beta1_KThreesConfigStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_KThreesConfig_To_v1beta1_KThreesConfig is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfig_To_v1beta1_KThreesConfig(in *v1beta2.KThreesConfig, out *KThreesConfig, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfig_To_v1beta1_KThreesConfig(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigList_To_v1beta2_KThreesConfigList(in *KThreesConfigList, out *v1beta2.KThreesConfigList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1beta2.KThreesConfig)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1beta1_KThreesConfigList_To_v1beta2_KThreesConfigList is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigList_To_v1beta2_KThreesConfigList(in *KThreesConfigList, out *v1beta2.KThreesConfigList, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigList_To_v1beta2_KThreesConfigList(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigList_To_v1beta1_KThreesConfigList(in *v1beta2.KThreesConfigList, out *KThreesConfigList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]KThreesConfig)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1beta2_KThreesConfigList_To_v1beta1_KThreesConfigList is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigList_To_v1beta1_KThreesConfigList(in *v1beta2.KThreesConfigList, out *KThreesConfigList, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigList_To_v1beta1_KThreesConfigList(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(in *KThreesConfigSpec, out *v1beta2.KThreesConfigSpec, s conversion.Scope) error { + out.Files = *(*[]v1beta2.File)(unsafe.Pointer(&in.Files)) + out.PreK3sCommands = *(*[]string)(unsafe.Pointer(&in.PreK3sCommands)) + out.PostK3sCommands = *(*[]string)(unsafe.Pointer(&in.PostK3sCommands)) + if err := Convert_v1beta1_KThreesAgentConfig_To_v1beta2_KThreesAgentConfig(&in.AgentConfig, &out.AgentConfig, s); err != nil { + return err + } + if err := Convert_v1beta1_KThreesServerConfig_To_v1beta2_KThreesServerConfig(&in.ServerConfig, &out.ServerConfig, s); err != nil { + return err + } + out.Version = in.Version + return nil +} + +// Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(in *KThreesConfigSpec, out *v1beta2.KThreesConfigSpec, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(in *v1beta2.KThreesConfigSpec, out *KThreesConfigSpec, s conversion.Scope) error { + out.Files = *(*[]File)(unsafe.Pointer(&in.Files)) + out.PreK3sCommands = *(*[]string)(unsafe.Pointer(&in.PreK3sCommands)) + out.PostK3sCommands = *(*[]string)(unsafe.Pointer(&in.PostK3sCommands)) + if err := Convert_v1beta2_KThreesAgentConfig_To_v1beta1_KThreesAgentConfig(&in.AgentConfig, &out.AgentConfig, s); err != nil { + return err + } + if err := Convert_v1beta2_KThreesServerConfig_To_v1beta1_KThreesServerConfig(&in.ServerConfig, &out.ServerConfig, s); err != nil { + return err + } + out.Version = in.Version + return nil +} + +// Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(in *v1beta2.KThreesConfigSpec, out *KThreesConfigSpec, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigStatus_To_v1beta2_KThreesConfigStatus(in *KThreesConfigStatus, out *v1beta2.KThreesConfigStatus, s conversion.Scope) error { + out.Ready = in.Ready + out.BootstrapData = *(*[]byte)(unsafe.Pointer(&in.BootstrapData)) + out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) + out.FailureReason = in.FailureReason + out.FailureMessage = in.FailureMessage + out.ObservedGeneration = in.ObservedGeneration + out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + return nil +} + +// Convert_v1beta1_KThreesConfigStatus_To_v1beta2_KThreesConfigStatus is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigStatus_To_v1beta2_KThreesConfigStatus(in *KThreesConfigStatus, out *v1beta2.KThreesConfigStatus, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigStatus_To_v1beta2_KThreesConfigStatus(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigStatus_To_v1beta1_KThreesConfigStatus(in *v1beta2.KThreesConfigStatus, out *KThreesConfigStatus, s conversion.Scope) error { + out.Ready = in.Ready + out.BootstrapData = *(*[]byte)(unsafe.Pointer(&in.BootstrapData)) + out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) + out.FailureReason = in.FailureReason + out.FailureMessage = in.FailureMessage + out.ObservedGeneration = in.ObservedGeneration + out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + return nil +} + +// Convert_v1beta2_KThreesConfigStatus_To_v1beta1_KThreesConfigStatus is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigStatus_To_v1beta1_KThreesConfigStatus(in *v1beta2.KThreesConfigStatus, out *KThreesConfigStatus, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigStatus_To_v1beta1_KThreesConfigStatus(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigTemplate_To_v1beta2_KThreesConfigTemplate(in *KThreesConfigTemplate, out *v1beta2.KThreesConfigTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_KThreesConfigTemplateSpec_To_v1beta2_KThreesConfigTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_KThreesConfigTemplate_To_v1beta2_KThreesConfigTemplate is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigTemplate_To_v1beta2_KThreesConfigTemplate(in *KThreesConfigTemplate, out *v1beta2.KThreesConfigTemplate, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigTemplate_To_v1beta2_KThreesConfigTemplate(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigTemplate_To_v1beta1_KThreesConfigTemplate(in *v1beta2.KThreesConfigTemplate, out *KThreesConfigTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_KThreesConfigTemplateSpec_To_v1beta1_KThreesConfigTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_KThreesConfigTemplate_To_v1beta1_KThreesConfigTemplate is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigTemplate_To_v1beta1_KThreesConfigTemplate(in *v1beta2.KThreesConfigTemplate, out *KThreesConfigTemplate, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigTemplate_To_v1beta1_KThreesConfigTemplate(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigTemplateList_To_v1beta2_KThreesConfigTemplateList(in *KThreesConfigTemplateList, out *v1beta2.KThreesConfigTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1beta2.KThreesConfigTemplate)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1beta1_KThreesConfigTemplateList_To_v1beta2_KThreesConfigTemplateList is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigTemplateList_To_v1beta2_KThreesConfigTemplateList(in *KThreesConfigTemplateList, out *v1beta2.KThreesConfigTemplateList, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigTemplateList_To_v1beta2_KThreesConfigTemplateList(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigTemplateList_To_v1beta1_KThreesConfigTemplateList(in *v1beta2.KThreesConfigTemplateList, out *KThreesConfigTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]KThreesConfigTemplate)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1beta2_KThreesConfigTemplateList_To_v1beta1_KThreesConfigTemplateList is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigTemplateList_To_v1beta1_KThreesConfigTemplateList(in *v1beta2.KThreesConfigTemplateList, out *KThreesConfigTemplateList, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigTemplateList_To_v1beta1_KThreesConfigTemplateList(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigTemplateResource_To_v1beta2_KThreesConfigTemplateResource(in *KThreesConfigTemplateResource, out *v1beta2.KThreesConfigTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_KThreesConfigTemplateResource_To_v1beta2_KThreesConfigTemplateResource is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigTemplateResource_To_v1beta2_KThreesConfigTemplateResource(in *KThreesConfigTemplateResource, out *v1beta2.KThreesConfigTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigTemplateResource_To_v1beta2_KThreesConfigTemplateResource(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigTemplateResource_To_v1beta1_KThreesConfigTemplateResource(in *v1beta2.KThreesConfigTemplateResource, out *KThreesConfigTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_KThreesConfigTemplateResource_To_v1beta1_KThreesConfigTemplateResource is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigTemplateResource_To_v1beta1_KThreesConfigTemplateResource(in *v1beta2.KThreesConfigTemplateResource, out *KThreesConfigTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigTemplateResource_To_v1beta1_KThreesConfigTemplateResource(in, out, s) +} + +func autoConvert_v1beta1_KThreesConfigTemplateSpec_To_v1beta2_KThreesConfigTemplateSpec(in *KThreesConfigTemplateSpec, out *v1beta2.KThreesConfigTemplateSpec, s conversion.Scope) error { + if err := Convert_v1beta1_KThreesConfigTemplateResource_To_v1beta2_KThreesConfigTemplateResource(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_KThreesConfigTemplateSpec_To_v1beta2_KThreesConfigTemplateSpec is an autogenerated conversion function. +func Convert_v1beta1_KThreesConfigTemplateSpec_To_v1beta2_KThreesConfigTemplateSpec(in *KThreesConfigTemplateSpec, out *v1beta2.KThreesConfigTemplateSpec, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesConfigTemplateSpec_To_v1beta2_KThreesConfigTemplateSpec(in, out, s) +} + +func autoConvert_v1beta2_KThreesConfigTemplateSpec_To_v1beta1_KThreesConfigTemplateSpec(in *v1beta2.KThreesConfigTemplateSpec, out *KThreesConfigTemplateSpec, s conversion.Scope) error { + if err := Convert_v1beta2_KThreesConfigTemplateResource_To_v1beta1_KThreesConfigTemplateResource(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_KThreesConfigTemplateSpec_To_v1beta1_KThreesConfigTemplateSpec is an autogenerated conversion function. +func Convert_v1beta2_KThreesConfigTemplateSpec_To_v1beta1_KThreesConfigTemplateSpec(in *v1beta2.KThreesConfigTemplateSpec, out *KThreesConfigTemplateSpec, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesConfigTemplateSpec_To_v1beta1_KThreesConfigTemplateSpec(in, out, s) +} + +func autoConvert_v1beta1_KThreesServerConfig_To_v1beta2_KThreesServerConfig(in *KThreesServerConfig, out *v1beta2.KThreesServerConfig, s conversion.Scope) error { + out.KubeAPIServerArgs = *(*[]string)(unsafe.Pointer(&in.KubeAPIServerArgs)) + out.KubeControllerManagerArgs = *(*[]string)(unsafe.Pointer(&in.KubeControllerManagerArgs)) + out.KubeSchedulerArgs = *(*[]string)(unsafe.Pointer(&in.KubeSchedulerArgs)) + out.TLSSan = *(*[]string)(unsafe.Pointer(&in.TLSSan)) + out.BindAddress = in.BindAddress + out.HTTPSListenPort = in.HTTPSListenPort + out.AdvertiseAddress = in.AdvertiseAddress + out.AdvertisePort = in.AdvertisePort + out.ClusterCidr = in.ClusterCidr + out.ServiceCidr = in.ServiceCidr + out.ClusterDNS = in.ClusterDNS + out.ClusterDomain = in.ClusterDomain + out.DisableComponents = *(*[]string)(unsafe.Pointer(&in.DisableComponents)) + out.DisableExternalCloudProvider = in.DisableExternalCloudProvider + return nil +} + +// Convert_v1beta1_KThreesServerConfig_To_v1beta2_KThreesServerConfig is an autogenerated conversion function. +func Convert_v1beta1_KThreesServerConfig_To_v1beta2_KThreesServerConfig(in *KThreesServerConfig, out *v1beta2.KThreesServerConfig, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesServerConfig_To_v1beta2_KThreesServerConfig(in, out, s) +} + +func autoConvert_v1beta2_KThreesServerConfig_To_v1beta1_KThreesServerConfig(in *v1beta2.KThreesServerConfig, out *KThreesServerConfig, s conversion.Scope) error { + out.KubeAPIServerArgs = *(*[]string)(unsafe.Pointer(&in.KubeAPIServerArgs)) + out.KubeControllerManagerArgs = *(*[]string)(unsafe.Pointer(&in.KubeControllerManagerArgs)) + out.KubeSchedulerArgs = *(*[]string)(unsafe.Pointer(&in.KubeSchedulerArgs)) + out.TLSSan = *(*[]string)(unsafe.Pointer(&in.TLSSan)) + out.BindAddress = in.BindAddress + out.HTTPSListenPort = in.HTTPSListenPort + out.AdvertiseAddress = in.AdvertiseAddress + out.AdvertisePort = in.AdvertisePort + out.ClusterCidr = in.ClusterCidr + out.ServiceCidr = in.ServiceCidr + out.ClusterDNS = in.ClusterDNS + out.ClusterDomain = in.ClusterDomain + out.DisableComponents = *(*[]string)(unsafe.Pointer(&in.DisableComponents)) + out.DisableExternalCloudProvider = in.DisableExternalCloudProvider + return nil +} + +// Convert_v1beta2_KThreesServerConfig_To_v1beta1_KThreesServerConfig is an autogenerated conversion function. +func Convert_v1beta2_KThreesServerConfig_To_v1beta1_KThreesServerConfig(in *v1beta2.KThreesServerConfig, out *KThreesServerConfig, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesServerConfig_To_v1beta1_KThreesServerConfig(in, out, s) +} + +func autoConvert_v1beta1_SecretFileSource_To_v1beta2_SecretFileSource(in *SecretFileSource, out *v1beta2.SecretFileSource, s conversion.Scope) error { + out.Name = in.Name + out.Key = in.Key + return nil +} + +// Convert_v1beta1_SecretFileSource_To_v1beta2_SecretFileSource is an autogenerated conversion function. +func Convert_v1beta1_SecretFileSource_To_v1beta2_SecretFileSource(in *SecretFileSource, out *v1beta2.SecretFileSource, s conversion.Scope) error { + return autoConvert_v1beta1_SecretFileSource_To_v1beta2_SecretFileSource(in, out, s) +} + +func autoConvert_v1beta2_SecretFileSource_To_v1beta1_SecretFileSource(in *v1beta2.SecretFileSource, out *SecretFileSource, s conversion.Scope) error { + out.Name = in.Name + out.Key = in.Key + return nil +} + +// Convert_v1beta2_SecretFileSource_To_v1beta1_SecretFileSource is an autogenerated conversion function. +func Convert_v1beta2_SecretFileSource_To_v1beta1_SecretFileSource(in *v1beta2.SecretFileSource, out *SecretFileSource, s conversion.Scope) error { + return autoConvert_v1beta2_SecretFileSource_To_v1beta1_SecretFileSource(in, out, s) +} diff --git a/bootstrap/api/v1beta1/zz_generated.deepcopy.go b/bootstrap/api/v1beta1/zz_generated.deepcopy.go index 846d1eb2..5b7c52d6 100644 --- a/bootstrap/api/v1beta1/zz_generated.deepcopy.go +++ b/bootstrap/api/v1beta1/zz_generated.deepcopy.go @@ -21,7 +21,7 @@ limitations under the License. package v1beta1 import ( - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" ) diff --git a/bootstrap/api/v1beta2/condition_consts.go b/bootstrap/api/v1beta2/condition_consts.go new file mode 100644 index 00000000..187eeda0 --- /dev/null +++ b/bootstrap/api/v1beta2/condition_consts.go @@ -0,0 +1,71 @@ +/* + + +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 v1beta2 + +import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + +// Conditions and condition Reasons for the KThreesConfig object. + +const ( + // DataSecretAvailableCondition documents the status of the bootstrap secret generation process. + // + // NOTE: When the DataSecret generation starts the process completes immediately and within the + // same reconciliation, so the user will always see a transition from Wait to Generated without having + // evidence that BootstrapSecret generation is started/in progress. + DataSecretAvailableCondition clusterv1.ConditionType = "DataSecretAvailable" + + // WaitingForClusterInfrastructureReason (Severity=Info) document a bootstrap secret generation process + // waiting for the cluster infrastructure to be ready. + // + // NOTE: Having the cluster infrastructure ready is a pre-condition for starting to create machines; + // the KThreesConfig controller ensure this pre-condition is satisfied. + WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure" + + // WaitingForControlPlaneAvailableReason (Severity=Info) document a bootstrap secret generation process + // waiting for the control plane machine to be available. + // + // NOTE: Having the control plane machine available is a pre-condition for joining additional control planes + // or workers nodes. + // Deprecated: This has been deprecated in v1beta1 and will be removed in a future version. + // Switch to WaitingForControlPlaneAvailableReason constant from the `sigs.k8s.io/cluster-api/api/v1beta1` + // package. + WaitingForControlPlaneAvailableReason = clusterv1.WaitingForControlPlaneAvailableReason + + // DataSecretGenerationFailedReason (Severity=Warning) documents a KThreesConfig controller detecting + // an error while generating a data secret; those kind of errors are usually due to misconfigurations + // and user intervention is required to get them fixed. + DataSecretGenerationFailedReason = "DataSecretGenerationFailed" +) + +const ( + // CertificatesAvailableCondition documents that cluster certificates are available. + // + // NOTE: Cluster certificates are generated only for the KThreesConfig object linked to the initial control plane + // machine, if the cluster is not using a control plane ref object, if the certificates are not provided + // by the users. + // IMPORTANT: This condition won't be re-created after clusterctl move. + CertificatesAvailableCondition clusterv1.ConditionType = "CertificatesAvailable" + + // CertificatesGenerationFailedReason (Severity=Warning) documents a KThreesConfig controller detecting + // an error while generating certificates; those kind of errors are usually temporary and the controller + // automatically recover from them. + CertificatesGenerationFailedReason = "CertificatesGenerationFailed" + + // CertificatesCorruptedReason (Severity=Error) documents a KThreesConfig controller detecting + // an error while retrieving certificates for a joining node. + CertificatesCorruptedReason = "CertificatesCorrupted" +) diff --git a/bootstrap/api/v1beta2/conversion.go b/bootstrap/api/v1beta2/conversion.go new file mode 100644 index 00000000..6627491e --- /dev/null +++ b/bootstrap/api/v1beta2/conversion.go @@ -0,0 +1,29 @@ +/* + + +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 v1beta2 + +// Hub marks KThreesConfig as a conversion hub. +func (*KThreesConfig) Hub() {} + +// Hub marks KThreesConfigList as a conversion hub. +func (*KThreesConfigList) Hub() {} + +// Hub marks KThreesConfigTemplate as a conversion hub. +func (*KThreesConfigTemplate) Hub() {} + +// Hub marks KThreesConfigTemplateList as a conversion hub. +func (*KThreesConfigTemplateList) Hub() {} diff --git a/bootstrap/api/v1beta2/doc.go b/bootstrap/api/v1beta2/doc.go new file mode 100644 index 00000000..8386d859 --- /dev/null +++ b/bootstrap/api/v1beta2/doc.go @@ -0,0 +1,21 @@ +/* + + +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 v1beta2 contains API Schema definitions for the bootstrap v1beta2 API group +// +kubebuilder:object:generate=true +// +groupName=bootstrap.cluster.x-k8s.io +// +k8s:defaulter-gen=TypeMeta +package v1beta2 diff --git a/bootstrap/api/v1beta2/groupversion_info.go b/bootstrap/api/v1beta2/groupversion_info.go new file mode 100644 index 00000000..eff67ac7 --- /dev/null +++ b/bootstrap/api/v1beta2/groupversion_info.go @@ -0,0 +1,33 @@ +/* + + +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 v1beta2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "bootstrap.cluster.x-k8s.io", Version: "v1beta2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/bootstrap/api/v1beta2/kthreesconfig_types.go b/bootstrap/api/v1beta2/kthreesconfig_types.go new file mode 100644 index 00000000..369495bf --- /dev/null +++ b/bootstrap/api/v1beta2/kthreesconfig_types.go @@ -0,0 +1,270 @@ +/* + + +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 v1beta2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// KThreesConfigSpec defines the desired state of KThreesConfig. +type KThreesConfigSpec struct { + // Files specifies extra files to be passed to user_data upon creation. + // +optional + Files []File `json:"files,omitempty"` + + // PreK3sCommands specifies extra commands to run before k3s setup runs + // +optional + PreK3sCommands []string `json:"preK3sCommands,omitempty"` + + // PostK3sCommands specifies extra commands to run after k3s setup runs + // +optional + PostK3sCommands []string `json:"postK3sCommands,omitempty"` + + // AgentConfig specifies configuration for the agent nodes + // +optional + AgentConfig KThreesAgentConfig `json:"agentConfig,omitempty"` + + // ServerConfig specifies configuration for the agent nodes + // +optional + ServerConfig KThreesServerConfig `json:"serverConfig,omitempty"` + + // Version specifies the k3s version + // +optional + Version string `json:"version,omitempty"` +} + +// TODO +// Will need extend this func when implementing other k3s database options. +func (c *KThreesConfigSpec) IsEtcdEmbedded() bool { + return true +} + +type KThreesServerConfig struct { + // KubeAPIServerArgs is a customized flag for kube-apiserver process + // +optional + KubeAPIServerArgs []string `json:"kubeAPIServerArg,omitempty"` + + // KubeControllerManagerArgs is a customized flag for kube-controller-manager process + // +optional + KubeControllerManagerArgs []string `json:"kubeControllerManagerArgs,omitempty"` + + // KubeSchedulerArgs is a customized flag for kube-scheduler process + // +optional + KubeSchedulerArgs []string `json:"kubeSchedulerArgs,omitempty"` + + // TLSSan Add additional hostname or IP as a Subject Alternative Name in the TLS cert + // +optional + TLSSan []string `json:"tlsSan,omitempty"` + + // BindAddress k3s bind address (default: 0.0.0.0) + // +optional + BindAddress string `json:"bindAddress,omitempty"` + + // HTTPSListenPort HTTPS listen port (default: 6443) + // +optional + HTTPSListenPort string `json:"httpsListenPort,omitempty"` + + // AdvertiseAddress IP address that apiserver uses to advertise to members of the cluster (default: node-external-ip/node-ip) + // +optional + AdvertiseAddress string `json:"advertiseAddress,omitempty"` + + // AdvertisePort Port that apiserver uses to advertise to members of the cluster (default: listen-port) (default: 0) + // +optional + AdvertisePort string `json:"advertisePort,omitempty"` + + // ClusterCidr Network CIDR to use for pod IPs (default: "10.42.0.0/16") + // +optional + ClusterCidr string `json:"clusterCidr,omitempty"` + + // ServiceCidr Network CIDR to use for services IPs (default: "10.43.0.0/16") + // +optional + ServiceCidr string `json:"serviceCidr,omitempty"` + + // ClusterDNS Cluster IP for coredns service. Should be in your service-cidr range (default: 10.43.0.10) + // +optional + ClusterDNS string `json:"clusterDNS,omitempty"` + + // ClusterDomain Cluster Domain (default: "cluster.local") + // +optional + ClusterDomain string `json:"clusterDomain,omitempty"` + + // DisableComponents specifies extra commands to run before k3s setup runs + // +optional + DisableComponents []string `json:"disableComponents,omitempty"` + + // DisableExternalCloudProvider suppresses the 'cloud-provider=external' kubelet argument. (default: false) + // +optional + DisableExternalCloudProvider bool `json:"disableExternalCloudProvider,omitempty"` +} + +type KThreesAgentConfig struct { + // NodeLabels Registering and starting kubelet with set of labels + // +optional + NodeLabels []string `json:"nodeLabels,omitempty"` + + // NodeTaints Registering kubelet with set of taints + // +optional + NodeTaints []string `json:"nodeTaints,omitempty"` + + // TODO: take in a object or secret and write to file. this is not useful + // PrivateRegistry registry configuration file (default: "/etc/rancher/k3s/registries.yaml") + // +optional + PrivateRegistry string `json:"privateRegistry,omitempty"` + + // KubeletArgs Customized flag for kubelet process + // +optional + KubeletArgs []string `json:"kubeletArgs,omitempty"` + + // KubeProxyArgs Customized flag for kube-proxy process + // +optional + KubeProxyArgs []string `json:"kubeProxyArgs,omitempty"` + + // NodeName Name of the Node + // +optional + NodeName string `json:"nodeName,omitempty"` + + // AirGapped is a boolean value to define if the bootstrapping should be air-gapped, + // basically supposing that online container registries and k3s install scripts are not reachable. + // User should prepare docker image, k3s binary, and put the install script in `/opt/install.sh` + // on all nodes in the air-gap environment. + // +optional + AirGapped bool `json:"airGapped,omitempty"` +} + +// KThreesConfigStatus defines the observed state of KThreesConfig. +type KThreesConfigStatus struct { + // Ready indicates the BootstrapData field is ready to be consumed + Ready bool `json:"ready,omitempty"` + + BootstrapData []byte `json:"bootstrapData,omitempty"` + + // DataSecretName is the name of the secret that stores the bootstrap data script. + // +optional + DataSecretName *string `json:"dataSecretName,omitempty"` + + // FailureReason will be set on non-retryable errors + // +optional + FailureReason string `json:"failureReason,omitempty"` + + // FailureMessage will be set on non-retryable errors + // +optional + FailureMessage string `json:"failureMessage,omitempty"` + + // ObservedGeneration is the latest generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions defines current service state of the KThreesConfig. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// KThreesConfig is the Schema for the kthreesconfigs API. +type KThreesConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KThreesConfigSpec `json:"spec,omitempty"` + Status KThreesConfigStatus `json:"status,omitempty"` +} + +func (c *KThreesConfig) GetConditions() clusterv1.Conditions { + return c.Status.Conditions +} + +func (c *KThreesConfig) SetConditions(conditions clusterv1.Conditions) { + c.Status.Conditions = conditions +} + +// +kubebuilder:object:root=true + +// KThreesConfigList contains a list of KThreesConfig. +type KThreesConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KThreesConfig `json:"items"` +} + +// Encoding specifies the cloud-init file encoding. +// +kubebuilder:validation:Enum=base64;gzip;gzip+base64 +type Encoding string + +const ( + // Base64 implies the contents of the file are encoded as base64. + Base64 Encoding = "base64" + // Gzip implies the contents of the file are encoded with gzip. + Gzip Encoding = "gzip" + // GzipBase64 implies the contents of the file are first base64 encoded and then gzip encoded. + GzipBase64 Encoding = "gzip+base64" +) + +// File defines the input for generating write_files in cloud-init. +type File struct { + // Path specifies the full path on disk where to store the file. + Path string `json:"path"` + + // Owner specifies the ownership of the file, e.g. "root:root". + // +optional + Owner string `json:"owner,omitempty"` + + // Permissions specifies the permissions to assign to the file, e.g. "0640". + // +optional + Permissions string `json:"permissions,omitempty"` + + // Encoding specifies the encoding of the file contents. + // +optional + Encoding Encoding `json:"encoding,omitempty"` + + // Content is the actual content of the file. + // +optional + Content string `json:"content,omitempty"` + + // ContentFrom is a referenced source of content to populate the file. + // +optional + ContentFrom *FileSource `json:"contentFrom,omitempty"` +} + +// FileSource is a union of all possible external source types for file data. +// Only one field may be populated in any given instance. Developers adding new +// sources of data for target systems should add them here. +type FileSource struct { + // Secret represents a secret that should populate this file. + Secret SecretFileSource `json:"secret"` +} + +// Adapts a Secret into a FileSource. +// +// The contents of the target Secret's Data field will be presented +// as files using the keys in the Data field as the file names. +type SecretFileSource struct { + // Name of the secret in the KThreesBootstrapConfig's namespace to use. + Name string `json:"name"` + + // Key is the key in the secret's data map for this value. + Key string `json:"key"` +} + +func init() { + SchemeBuilder.Register(&KThreesConfig{}, &KThreesConfigList{}) +} diff --git a/bootstrap/api/v1beta2/kthreesconfig_webhook.go b/bootstrap/api/v1beta2/kthreesconfig_webhook.go new file mode 100644 index 00000000..29a40278 --- /dev/null +++ b/bootstrap/api/v1beta2/kthreesconfig_webhook.go @@ -0,0 +1,56 @@ +/* + + +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 v1beta2 + +import ( + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// SetupWebhookWithManager will setup the webhooks for the KThreesControlPlane. +func (c *KThreesConfig) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfig,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=bootstrap.cluster.x-k8s.io,resources=kthreesconfig,versions=v1beta2,name=validation.kthreesconfig.bootstrap.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta2 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfig,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=bootstrap.cluster.x-k8s.io,resources=kthreesconfig,versions=v1beta2,name=default.kthreesconfig.bootstrap.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta2 + +var _ webhook.Defaulter = &KThreesConfig{} +var _ webhook.Validator = &KThreesConfig{} + +// ValidateCreate will do any extra validation when creating a KThreesControlPlane. +func (c *KThreesConfig) ValidateCreate() (admission.Warnings, error) { + return []string{}, nil +} + +// ValidateUpdate will do any extra validation when updating a KThreesControlPlane. +func (c *KThreesConfig) ValidateUpdate(runtime.Object) (admission.Warnings, error) { + return []string{}, nil +} + +// ValidateDelete allows you to add any extra validation when deleting. +func (c *KThreesConfig) ValidateDelete() (admission.Warnings, error) { + return []string{}, nil +} + +// Default will set default values for the KThreesControlPlane. +func (c *KThreesConfig) Default() { +} diff --git a/bootstrap/api/v1beta2/kthreesconfigtemplate_types.go b/bootstrap/api/v1beta2/kthreesconfigtemplate_types.go new file mode 100644 index 00000000..74a77702 --- /dev/null +++ b/bootstrap/api/v1beta2/kthreesconfigtemplate_types.go @@ -0,0 +1,57 @@ +/* + + +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 v1beta2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// KThreesConfigTemplateSpec defines the desired state of KThreesConfigTemplate. +type KThreesConfigTemplateSpec struct { + // Important: Run "make" to regenerate code after modifying this file + + Template KThreesConfigTemplateResource `json:"template"` +} + +// KThreesConfigTemplateResource defines the Template structure. +type KThreesConfigTemplateResource struct { + Spec KThreesConfigSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// KThreesConfigTemplate is the Schema for the kthreesconfigtemplates API. +type KThreesConfigTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KThreesConfigTemplateSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// KThreesConfigTemplateList contains a list of KThreesConfigTemplate. +type KThreesConfigTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KThreesConfigTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&KThreesConfigTemplate{}, &KThreesConfigTemplateList{}) +} diff --git a/bootstrap/api/v1beta2/kthreesconfigtemplate_webhook.go b/bootstrap/api/v1beta2/kthreesconfigtemplate_webhook.go new file mode 100644 index 00000000..33674cbc --- /dev/null +++ b/bootstrap/api/v1beta2/kthreesconfigtemplate_webhook.go @@ -0,0 +1,56 @@ +/* + + +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 v1beta2 + +import ( + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// SetupWebhookWithManager will setup the webhooks for the KThreesControlPlane. +func (c *KThreesConfigTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfigtemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=bootstrap.cluster.x-k8s.io,resources=kthreesconfigtemplate,versions=v1beta2,name=validation.kthreesconfigtemplate.bootstrap.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta2 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfigtemplate,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=bootstrap.cluster.x-k8s.io,resources=kthreesconfigtemplate,versions=v1beta2,name=default.kthreesconfigtemplate.bootstrap.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta2 + +var _ webhook.Defaulter = &KThreesConfigTemplate{} +var _ webhook.Validator = &KThreesConfigTemplate{} + +// ValidateCreate will do any extra validation when creating a KThreesControlPlane. +func (c *KThreesConfigTemplate) ValidateCreate() (admission.Warnings, error) { + return []string{}, nil +} + +// ValidateUpdate will do any extra validation when updating a KThreesControlPlane. +func (c *KThreesConfigTemplate) ValidateUpdate(runtime.Object) (admission.Warnings, error) { + return []string{}, nil +} + +// ValidateDelete allows you to add any extra validation when deleting. +func (c *KThreesConfigTemplate) ValidateDelete() (admission.Warnings, error) { + return []string{}, nil +} + +// Default will set default values for the KThreesControlPlane. +func (c *KThreesConfigTemplate) Default() { +} diff --git a/bootstrap/api/v1beta2/zz_generated.deepcopy.go b/bootstrap/api/v1beta2/zz_generated.deepcopy.go new file mode 100644 index 00000000..06b83495 --- /dev/null +++ b/bootstrap/api/v1beta2/zz_generated.deepcopy.go @@ -0,0 +1,367 @@ +//go:build !ignore_autogenerated + +/* + + +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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cluster-api/api/v1beta1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *File) DeepCopyInto(out *File) { + *out = *in + if in.ContentFrom != nil { + in, out := &in.ContentFrom, &out.ContentFrom + *out = new(FileSource) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new File. +func (in *File) DeepCopy() *File { + if in == nil { + return nil + } + out := new(File) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FileSource) DeepCopyInto(out *FileSource) { + *out = *in + out.Secret = in.Secret +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FileSource. +func (in *FileSource) DeepCopy() *FileSource { + if in == nil { + return nil + } + out := new(FileSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesAgentConfig) DeepCopyInto(out *KThreesAgentConfig) { + *out = *in + if in.NodeLabels != nil { + in, out := &in.NodeLabels, &out.NodeLabels + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.NodeTaints != nil { + in, out := &in.NodeTaints, &out.NodeTaints + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.KubeletArgs != nil { + in, out := &in.KubeletArgs, &out.KubeletArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.KubeProxyArgs != nil { + in, out := &in.KubeProxyArgs, &out.KubeProxyArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesAgentConfig. +func (in *KThreesAgentConfig) DeepCopy() *KThreesAgentConfig { + if in == nil { + return nil + } + out := new(KThreesAgentConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfig) DeepCopyInto(out *KThreesConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfig. +func (in *KThreesConfig) DeepCopy() *KThreesConfig { + if in == nil { + return nil + } + out := new(KThreesConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigList) DeepCopyInto(out *KThreesConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KThreesConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigList. +func (in *KThreesConfigList) DeepCopy() *KThreesConfigList { + if in == nil { + return nil + } + out := new(KThreesConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigSpec) DeepCopyInto(out *KThreesConfigSpec) { + *out = *in + if in.Files != nil { + in, out := &in.Files, &out.Files + *out = make([]File, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PreK3sCommands != nil { + in, out := &in.PreK3sCommands, &out.PreK3sCommands + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PostK3sCommands != nil { + in, out := &in.PostK3sCommands, &out.PostK3sCommands + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.AgentConfig.DeepCopyInto(&out.AgentConfig) + in.ServerConfig.DeepCopyInto(&out.ServerConfig) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigSpec. +func (in *KThreesConfigSpec) DeepCopy() *KThreesConfigSpec { + if in == nil { + return nil + } + out := new(KThreesConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigStatus) DeepCopyInto(out *KThreesConfigStatus) { + *out = *in + if in.BootstrapData != nil { + in, out := &in.BootstrapData, &out.BootstrapData + *out = make([]byte, len(*in)) + copy(*out, *in) + } + if in.DataSecretName != nil { + in, out := &in.DataSecretName, &out.DataSecretName + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigStatus. +func (in *KThreesConfigStatus) DeepCopy() *KThreesConfigStatus { + if in == nil { + return nil + } + out := new(KThreesConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigTemplate) DeepCopyInto(out *KThreesConfigTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigTemplate. +func (in *KThreesConfigTemplate) DeepCopy() *KThreesConfigTemplate { + if in == nil { + return nil + } + out := new(KThreesConfigTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesConfigTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigTemplateList) DeepCopyInto(out *KThreesConfigTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KThreesConfigTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigTemplateList. +func (in *KThreesConfigTemplateList) DeepCopy() *KThreesConfigTemplateList { + if in == nil { + return nil + } + out := new(KThreesConfigTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesConfigTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigTemplateResource) DeepCopyInto(out *KThreesConfigTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigTemplateResource. +func (in *KThreesConfigTemplateResource) DeepCopy() *KThreesConfigTemplateResource { + if in == nil { + return nil + } + out := new(KThreesConfigTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesConfigTemplateSpec) DeepCopyInto(out *KThreesConfigTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesConfigTemplateSpec. +func (in *KThreesConfigTemplateSpec) DeepCopy() *KThreesConfigTemplateSpec { + if in == nil { + return nil + } + out := new(KThreesConfigTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesServerConfig) DeepCopyInto(out *KThreesServerConfig) { + *out = *in + if in.KubeAPIServerArgs != nil { + in, out := &in.KubeAPIServerArgs, &out.KubeAPIServerArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.KubeControllerManagerArgs != nil { + in, out := &in.KubeControllerManagerArgs, &out.KubeControllerManagerArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.KubeSchedulerArgs != nil { + in, out := &in.KubeSchedulerArgs, &out.KubeSchedulerArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.TLSSan != nil { + in, out := &in.TLSSan, &out.TLSSan + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.DisableComponents != nil { + in, out := &in.DisableComponents, &out.DisableComponents + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesServerConfig. +func (in *KThreesServerConfig) DeepCopy() *KThreesServerConfig { + if in == nil { + return nil + } + out := new(KThreesServerConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecretFileSource) DeepCopyInto(out *SecretFileSource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretFileSource. +func (in *SecretFileSource) DeepCopy() *SecretFileSource { + if in == nil { + return nil + } + out := new(SecretFileSource) + in.DeepCopyInto(out) + return out +} diff --git a/bootstrap/config/certmanager/certificate.yaml b/bootstrap/config/certmanager/certificate.yaml index 58db114f..f90715a5 100644 --- a/bootstrap/config/certmanager/certificate.yaml +++ b/bootstrap/config/certmanager/certificate.yaml @@ -1,8 +1,6 @@ # The following manifests contain a self-signed issuer CR and a certificate CR. # More document can be found at https://docs.cert-manager.io -# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for -# breaking changes -apiVersion: cert-manager.io/v1alpha2 +apiVersion: cert-manager.io/v1 kind: Issuer metadata: name: selfsigned-issuer @@ -10,7 +8,7 @@ metadata: spec: selfSigned: {} --- -apiVersion: cert-manager.io/v1alpha2 +apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml @@ -23,4 +21,4 @@ spec: issuerRef: kind: Issuer name: selfsigned-issuer - secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize + secretName: $(SERVICE_NAME)-cert diff --git a/bootstrap/config/certmanager/kustomizeconfig.yaml b/bootstrap/config/certmanager/kustomizeconfig.yaml index 90d7c313..d6109c9d 100644 --- a/bootstrap/config/certmanager/kustomizeconfig.yaml +++ b/bootstrap/config/certmanager/kustomizeconfig.yaml @@ -14,3 +14,6 @@ varReference: - kind: Certificate group: cert-manager.io path: spec/dnsNames +- kind: Certificate + group: cert-manager.io + path: spec/secretName diff --git a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml index d5a716af..8a9d1e39 100644 --- a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml +++ b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml @@ -291,6 +291,286 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesConfig is the Schema for the kthreesconfigs API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: KThreesConfigSpec defines the desired state of KThreesConfig. + properties: + agentConfig: + description: AgentConfig specifies configuration for the agent nodes + properties: + airGapped: + description: |- + AirGapped is a boolean value to define if the bootstrapping should be air-gapped, + basically supposing that online container registries and k3s install scripts are not reachable. + User should prepare docker image, k3s binary, and put the install script in `/opt/install.sh` + on all nodes in the air-gap environment. + type: boolean + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting kubelet with + set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set of taints + items: + type: string + type: array + privateRegistry: + description: |- + TODO: take in a object or secret and write to file. this is not useful + PrivateRegistry registry configuration file (default: "/etc/rancher/k3s/registries.yaml") + type: string + type: object + files: + description: Files specifies extra files to be passed to user_data + upon creation. + items: + description: File defines the input for generating write_files in + cloud-init. + properties: + content: + description: Content is the actual content of the file. + type: string + contentFrom: + description: ContentFrom is a referenced source of content to + populate the file. + properties: + secret: + description: Secret represents a secret that should populate + this file. + properties: + key: + description: Key is the key in the secret's data map + for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of the file contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the file, e.g. + "root:root". + type: string + path: + description: Path specifies the full path on disk where to store + the file. + type: string + permissions: + description: Permissions specifies the permissions to assign + to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands to run after + k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to run before + k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for the agent nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver uses + to advertise to members of the cluster (default: node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses to advertise + to members of the cluster (default: listen-port) (default: 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for pod IPs (default: + "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. Should + be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands to run + before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses the ''cloud-provider=external'' + kubelet argument. (default: false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag for kube-apiserver + process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized flag for + kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag for kube-scheduler + process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for services IPs + (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP as a Subject + Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + status: + description: KThreesConfigStatus defines the observed state of KThreesConfig. + properties: + bootstrapData: + format: byte + type: string + conditions: + description: Conditions defines current service state of the KThreesConfig. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + dataSecretName: + description: DataSecretName is the name of the secret that stores + the bootstrap data script. + type: string + failureMessage: + description: FailureMessage will be set on non-retryable errors + type: string + failureReason: + description: FailureReason will be set on non-retryable errors + type: string + observedGeneration: + description: ObservedGeneration is the latest generation observed + by the controller. + format: int64 + type: integer + ready: + description: Ready indicates the BootstrapData field is ready to be + consumed + type: boolean + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml index 48c72a0f..8ede6b8e 100644 --- a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml +++ b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml @@ -240,4 +240,231 @@ spec: type: object type: object served: true + storage: false + - name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesConfigTemplate is the Schema for the kthreesconfigtemplates + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: KThreesConfigTemplateSpec defines the desired state of KThreesConfigTemplate. + properties: + template: + description: KThreesConfigTemplateResource defines the Template structure. + properties: + spec: + description: KThreesConfigSpec defines the desired state of KThreesConfig. + properties: + agentConfig: + description: AgentConfig specifies configuration for the agent + nodes + properties: + airGapped: + description: |- + AirGapped is a boolean value to define if the bootstrapping should be air-gapped, + basically supposing that online container registries and k3s install scripts are not reachable. + User should prepare docker image, k3s binary, and put the install script in `/opt/install.sh` + on all nodes in the air-gap environment. + type: boolean + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy + process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting kubelet + with set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set of + taints + items: + type: string + type: array + privateRegistry: + description: |- + TODO: take in a object or secret and write to file. this is not useful + PrivateRegistry registry configuration file (default: "/etc/rancher/k3s/registries.yaml") + type: string + type: object + files: + description: Files specifies extra files to be passed to user_data + upon creation. + items: + description: File defines the input for generating write_files + in cloud-init. + properties: + content: + description: Content is the actual content of the file. + type: string + contentFrom: + description: ContentFrom is a referenced source of content + to populate the file. + properties: + secret: + description: Secret represents a secret that should + populate this file. + properties: + key: + description: Key is the key in the secret's + data map for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of the + file contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the file, + e.g. "root:root". + type: string + path: + description: Path specifies the full path on disk where + to store the file. + type: string + permissions: + description: Permissions specifies the permissions to + assign to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands to run + after k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to run + before k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for the + agent nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver + uses to advertise to members of the cluster (default: + node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses to + advertise to members of the cluster (default: listen-port) + (default: 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for pod + IPs (default: "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. + Should be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands + to run before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses + the ''cloud-provider=external'' kubelet argument. (default: + false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: + 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag for + kube-apiserver process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized + flag for kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag for + kube-scheduler process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for services + IPs (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP as a + Subject Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + type: object + required: + - template + type: object + type: object + served: true storage: true diff --git a/bootstrap/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml b/bootstrap/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml index e13f2fd7..3e77d823 100644 --- a/bootstrap/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml +++ b/bootstrap/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml @@ -73,54 +73,512 @@ spec: description: KThreesControlPlaneSpec defines the desired state of KThreesControlPlane. properties: infrastructureTemplate: - description: |- - InfrastructureTemplate is a required reference to a custom resource - offered by an infrastructure provider. - In the next API version we will move this into the - `KThreesControlPlaneMachineTemplate` struct. See - https://github.com/k3s-io/cluster-api-k3s/issues/62 + description: InfrastructureTemplate is a required reference to a custom + resource offered by an infrastructure provider. In the next API + version we will move this into the `KThreesControlPlaneMachineTemplate` + struct. See https://github.com/cluster-api-provider-k3s/cluster-api-k3s/issues/62 properties: apiVersion: description: API version of the referent. type: string fieldPath: - description: |- - If referring to a piece of an object instead of an entire object, this string - should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within a pod, this would take on a value like: - "spec.containers{name}" (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" (container with - index 2 in this pod). This syntax is chosen only to have some well-defined way of - referencing a part of an object. - TODO: this design is not final and this field is subject to change in the future. + description: 'If referring to a piece of an object instead of + an entire object, this string should contain a valid JSON/Go + field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen + only to have some well-defined way of referencing a part of + an object. TODO: this design is not final and this field is + subject to change in the future.' type: string kind: - description: |- - Kind of the referent. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' type: string namespace: - description: |- - Namespace of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' type: string resourceVersion: - description: |- - Specific resourceVersion to which this reference is made, if any. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + description: 'Specific resourceVersion to which this reference + is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency' type: string uid: - description: |- - UID of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' type: string type: object x-kubernetes-map-type: atomic + kthreesConfigSpec: + description: KThreesConfigSpec is a KThreesConfigSpec to use for initializing + and joining machines to the control plane. + properties: + agentConfig: + description: AgentConfig specifies configuration for the agent + nodes + properties: + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy + process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting kubelet + with set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set of taints + items: + type: string + type: array + privateRegistry: + description: 'TODO: take in a object or secret and write to + file. this is not useful PrivateRegistry registry configuration + file (default: "/etc/rancher/k3s/registries.yaml")' + type: string + type: object + files: + description: Files specifies extra files to be passed to user_data + upon creation. + items: + description: File defines the input for generating write_files + in cloud-init. + properties: + content: + description: Content is the actual content of the file. + type: string + contentFrom: + description: ContentFrom is a referenced source of content + to populate the file. + properties: + secret: + description: Secret represents a secret that should + populate this file. + properties: + key: + description: Key is the key in the secret's data + map for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of the file + contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the file, + e.g. "root:root". + type: string + path: + description: Path specifies the full path on disk where + to store the file. + type: string + permissions: + description: Permissions specifies the permissions to assign + to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands to run after + k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to run before + k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for the agent + nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver uses + to advertise to members of the cluster (default: node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses to advertise + to members of the cluster (default: listen-port) (default: + 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for pod IPs + (default: "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. + Should be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands to + run before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses the + ''cloud-provider=external'' kubelet argument. (default: + false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: + 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag for kube-apiserver + process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized flag + for kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag for kube-scheduler + process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for services + IPs (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP as a Subject + Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + machineTemplate: + description: MachineTemplate contains information about how machines + should be shaped when creating or updating a control plane. + properties: + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + properties: + annotations: + additionalProperties: + type: string + description: 'Annotations is an unstructured key value map + stored with a resource that may be set by external tools + to store and retrieve arbitrary metadata. They are not queryable + and should be preserved when modifying objects. More info: + http://kubernetes.io/docs/user-guide/annotations' + type: object + labels: + additionalProperties: + type: string + description: 'Map of string keys and values that can be used + to organize and categorize (scope and select) objects. May + match selectors of replication controllers and services. + More info: http://kubernetes.io/docs/user-guide/labels' + type: object + type: object + type: object + nodeDrainTimeout: + description: 'NodeDrainTimeout is the total amount of time that the + controller will spend on draining a controlplane node The default + value is 0, meaning that the node can be drained without any time + limitations. NOTE: NodeDrainTimeout is different from `kubectl drain + --timeout`' + type: string + remediationStrategy: + description: The RemediationStrategy that controls how control plane + machine remediation happens. + properties: + maxRetry: + description: "MaxRetry is the Max number of retries while attempting + to remediate an unhealthy machine. A retry happens when a machine + that was created as a replacement for an unhealthy machine also + fails. For example, given a control plane with three machines + M1, M2, M3: \n M1 become unhealthy; remediation happens, and + M1-1 is created as a replacement. If M1-1 (replacement of M1) + has problems while bootstrapping it will become unhealthy, and + then be remediated; such operation is considered a retry, remediation-retry + #1. If M1-2 (replacement of M1-1) becomes unhealthy, remediation-retry + #2 will happen, etc. \n A retry could happen only after RetryPeriod + from the previous retry. If a machine is marked as unhealthy + after MinHealthyPeriod from the previous remediation expired, + this is not considered a retry anymore because the new issue + is assumed unrelated from the previous one. \n If not set, the + remedation will be retried infinitely." + format: int32 + type: integer + minHealthyPeriod: + description: "MinHealthyPeriod defines the duration after which + KCP will consider any failure to a machine unrelated from the + previous one. In this case the remediation is not considered + a retry anymore, and thus the retry counter restarts from 0. + For example, assuming MinHealthyPeriod is set to 1h (default) + \n M1 become unhealthy; remediation happens, and M1-1 is created + as a replacement. If M1-1 (replacement of M1) has problems within + the 1hr after the creation, also this machine will be remediated + and this operation is considered a retry - a problem related + to the original issue happened to M1 -. \n If instead the problem + on M1-1 is happening after MinHealthyPeriod expired, e.g. four + days after m1-1 has been created as a remediation of M1, the + problem on M1-1 is considered unrelated to the original issue + happened to M1. \n If not set, this value is defaulted to 1h." + type: string + retryPeriod: + description: "RetryPeriod is the duration that KCP should wait + before remediating a machine being created as a replacement + for an unhealthy machine (a retry). \n If not set, a retry will + happen immediately." + type: string + type: object + replicas: + description: Number of desired machines. Defaults to 1. When stacked + etcd is used only odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members). + This is a pointer to distinguish between explicit zero and not specified. + format: int32 + type: integer + upgradeAfter: + description: UpgradeAfter is a field to indicate an upgrade should + be performed after the specified time even if no changes have been + made to the KThreesControlPlane + format: date-time + type: string + version: + description: Version defines the desired Kubernetes version. + type: string + required: + - infrastructureTemplate + - version + type: object + status: + description: KThreesControlPlaneStatus defines the observed state of KThreesControlPlane. + properties: + conditions: + description: Conditions defines current service state of the KThreesControlPlane. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. This should be when the underlying condition changed. + If that is not known, then using the time when the API field + changed is acceptable. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. This field may be empty. + type: string + reason: + description: The reason for the condition's last transition + in CamelCase. The specific API may choose whether or not this + field is considered a guaranteed API. This field may not be + empty. + type: string + severity: + description: Severity provides an explicit classification of + Reason code, so the users or machines can immediately understand + the current situation and act accordingly. The Severity field + MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: ErrorMessage indicates that there is a terminal problem + reconciling the state, and will be set to a descriptive error message. + type: string + failureReason: + description: FailureReason indicates that there is a terminal problem + reconciling the state, and will be set to a token value suitable + for programmatic interpretation. + type: string + initialized: + description: Initialized denotes whether or not the k3s server is + initialized. + type: boolean + lastRemediation: + description: LastRemediation stores info about last remediation performed. + properties: + machine: + description: Machine is the machine name of the latest machine + being remediated. + type: string + retryCount: + description: RetryCount used to keep track of remediation retry + for the last remediated machine. A retry happens when a machine + that was created as a replacement for an unhealthy machine also + fails. + format: int32 + type: integer + timestamp: + description: Timestamp is when last remediation happened. It is + represented in RFC3339 form and is in UTC. + format: date-time + type: string + required: + - machine + - retryCount + - timestamp + type: object + observedGeneration: + description: ObservedGeneration is the latest generation observed + by the controller. + format: int64 + type: integer + ready: + description: Ready denotes that the KThreesControlPlane API Server + is ready to receive requests. + type: boolean + readyReplicas: + description: Total number of fully running and ready control plane + machines. + format: int32 + type: integer + replicas: + description: Total number of non-terminated machines targeted by this + control plane (their labels match the selector). + format: int32 + type: integer + selector: + description: 'Selector is the label selector in string format to avoid + introspection by clients, and is used to provide the CRD-based integration + for the scale subresource and additional integrations for things + like kubectl describe.. The string will be in the same format as + the query-param syntax. More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors' + type: string + unavailableReplicas: + description: Total number of unavailable machines targeted by this + control plane. This is the total number of machines that are still + required for the deployment to have 100% available capacity. They + may either be machines that are running but not yet ready or machines + that still have not been created. + format: int32 + type: integer + updatedReplicas: + description: Total number of non-terminated machines targeted by this + control plane that have the desired template spec. + format: int32 + type: integer + type: object + type: object + served: true + storage: false + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas + status: {} + - additionalPrinterColumns: + - description: This denotes whether or not the control plane has completed the + k3s server initialization + jsonPath: .status.initialized + name: Initialized + type: boolean + - description: KThreesControlPlane API Server is ready to receive requests + jsonPath: .status.ready + name: API Server Available + type: boolean + - description: Kubernetes version associated with this control plane + jsonPath: .spec.version + name: Version + type: string + - description: Total number of non-terminated machines targeted by this control + plane + jsonPath: .status.replicas + name: Replicas + type: integer + - description: Total number of fully running and ready control plane machines + jsonPath: .status.readyReplicas + name: Ready + type: integer + - description: Total number of non-terminated machines targeted by this control + plane that have the desired template spec + jsonPath: .status.updatedReplicas + name: Updated + type: integer + - description: Total number of unavailable machines targeted by this control plane + jsonPath: .status.unavailableReplicas + name: Unavailable + type: integer + name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesControlPlane is the Schema for the kthreescontrolplanes + API. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: KThreesControlPlaneSpec defines the desired state of KThreesControlPlane. + properties: kthreesConfigSpec: description: |- KThreesConfigSpec is a KThreesConfigSpec @@ -317,6 +775,44 @@ spec: MachineTemplate contains information about how machines should be shaped when creating or updating a control plane. properties: + infrastructureRef: + description: InfrastructureRef is a required reference to a custom + resource offered by an infrastructure provider. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead + of an entire object, this string should contain a valid + JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen + only to have some well-defined way of referencing a part + of an object. TODO: this design is not final and this field + is subject to change in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference + is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + x-kubernetes-map-type: atomic metadata: description: |- Standard object's metadata. @@ -341,13 +837,16 @@ spec: More info: http://kubernetes.io/docs/user-guide/labels type: object type: object + nodeDrainTimeout: + description: 'NodeDrainTimeout is the total amount of time that + the controller will spend on draining a controlplane node The + default value is 0, meaning that the node can be drained without + any time limitations. NOTE: NodeDrainTimeout is different from + `kubectl drain --timeout`' + type: string + required: + - infrastructureRef type: object - nodeDrainTimeout: - description: |- - NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node - The default value is 0, meaning that the node can be drained without any time limitations. - NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` - type: string remediationStrategy: description: The RemediationStrategy that controls how control plane machine remediation happens. @@ -415,7 +914,6 @@ spec: description: Version defines the desired Kubernetes version. type: string required: - - infrastructureTemplate - version type: object status: diff --git a/bootstrap/config/crd/kustomization.yaml b/bootstrap/config/crd/kustomization.yaml index 9a498c19..d27ea4c4 100644 --- a/bootstrap/config/crd/kustomization.yaml +++ b/bootstrap/config/crd/kustomization.yaml @@ -1,5 +1,5 @@ commonLabels: - cluster.x-k8s.io/v1beta1: v1beta1 + cluster.x-k8s.io/v1beta1: v1beta1_v1beta2 clusterctl.cluster.x-k8s.io: "" # This kustomization.yaml is not intended to be run by itself, @@ -13,14 +13,14 @@ resources: patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -#- patches/webhook_in_kthreesconfigs.yaml -#- patches/webhook_in_kthreesconfigtemplates.yaml +- patches/webhook_in_kthreesconfigs.yaml +- patches/webhook_in_kthreesconfigtemplates.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- patches/cainjection_in_kthreesconfigs.yaml -#- patches/cainjection_in_kthreesconfigtemplates.yaml +- patches/cainjection_in_kthreesconfigs.yaml +- patches/cainjection_in_kthreesconfigtemplates.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/bootstrap/config/crd/kustomizeconfig.yaml b/bootstrap/config/crd/kustomizeconfig.yaml index e9cda712..8e2d8d6b 100644 --- a/bootstrap/config/crd/kustomizeconfig.yaml +++ b/bootstrap/config/crd/kustomizeconfig.yaml @@ -1,17 +1,17 @@ # This file is for teaching kustomize how to substitute name and namespace reference in CRD nameReference: - - kind: Service - version: v1 - fieldSpecs: - - kind: CustomResourceDefinition - group: apiextensions.k8s.io - path: spec/conversion/webhookClientConfig/service/name - -namespace: +- kind: Service + version: v1 + fieldSpecs: - kind: CustomResourceDefinition group: apiextensions.k8s.io - path: spec/conversion/webhookClientConfig/service/namespace - create: false + path: spec/conversion/webhook/clientConfig/service/name + +namespace: +- kind: CustomResourceDefinition + group: apiextensions.k8s.io + path: spec/conversion/webhook/clientConfig/service/namespace + create: false varReference: - - path: metadata/annotations +- path: metadata/annotations diff --git a/bootstrap/config/crd/patches/cainjection_in_kthreesconfigs.yaml b/bootstrap/config/crd/patches/cainjection_in_kthreesconfigs.yaml index eaa093f6..5001e83d 100644 --- a/bootstrap/config/crd/patches/cainjection_in_kthreesconfigs.yaml +++ b/bootstrap/config/crd/patches/cainjection_in_kthreesconfigs.yaml @@ -1,6 +1,5 @@ # The following patch adds a directive for certmanager to inject CA into the CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: diff --git a/bootstrap/config/crd/patches/cainjection_in_kthreesconfigtemplates.yaml b/bootstrap/config/crd/patches/cainjection_in_kthreesconfigtemplates.yaml index 3d10c38e..511bff24 100644 --- a/bootstrap/config/crd/patches/cainjection_in_kthreesconfigtemplates.yaml +++ b/bootstrap/config/crd/patches/cainjection_in_kthreesconfigtemplates.yaml @@ -1,6 +1,5 @@ # The following patch adds a directive for certmanager to inject CA into the CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: diff --git a/bootstrap/config/crd/patches/webhook_in_kthreesconfigs.yaml b/bootstrap/config/crd/patches/webhook_in_kthreesconfigs.yaml index 7ddd71bf..50206f4a 100644 --- a/bootstrap/config/crd/patches/webhook_in_kthreesconfigs.yaml +++ b/bootstrap/config/crd/patches/webhook_in_kthreesconfigs.yaml @@ -1,17 +1,17 @@ -# The following patch enables conversion webhook for CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1beta1 +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: kthreesconfigs.bootstrap.cluster.x-k8s.io spec: conversion: strategy: Webhook - webhookClientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== - service: - namespace: system - name: webhook-service - path: /convert + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1beta1 + - v1beta2 diff --git a/bootstrap/config/crd/patches/webhook_in_kthreesconfigtemplates.yaml b/bootstrap/config/crd/patches/webhook_in_kthreesconfigtemplates.yaml index e777a645..824ab7bf 100644 --- a/bootstrap/config/crd/patches/webhook_in_kthreesconfigtemplates.yaml +++ b/bootstrap/config/crd/patches/webhook_in_kthreesconfigtemplates.yaml @@ -1,17 +1,17 @@ -# The following patch enables conversion webhook for CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1beta1 +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: kthreesconfigtemplates.bootstrap.cluster.x-k8s.io spec: conversion: strategy: Webhook - webhookClientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== - service: - namespace: system - name: webhook-service - path: /convert + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1beta1 + - v1beta2 diff --git a/bootstrap/config/default/kustomization.yaml b/bootstrap/config/default/kustomization.yaml index 50bcd2e8..805b16c9 100644 --- a/bootstrap/config/default/kustomization.yaml +++ b/bootstrap/config/default/kustomization.yaml @@ -18,9 +18,9 @@ bases: - ../manager # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -#- ../webhook +- ../webhook # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. -#- ../certmanager +- ../certmanager # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. #- ../prometheus @@ -32,39 +32,42 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -#- manager_webhook_patch.yaml +- manager_webhook_patch.yaml # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. # 'CERTMANAGER' needs to be enabled to use ca injection -#- webhookcainjection_patch.yaml +- webhookcainjection_patch.yaml # the following config is for teaching kustomize how to do var substitution -vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1alpha2 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldref: -# fieldpath: metadata.namespace -#- name: CERTIFICATE_NAME -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1alpha2 -# name: serving-cert # this name should match the one in certificate.yaml -#- name: SERVICE_NAMESPACE # namespace of the service -# objref: -# kind: Service -# version: v1 -# name: webhook-service -# fieldref: -# fieldpath: metadata.namespace -#- name: SERVICE_NAME -# objref: -# kind: Service -# version: v1 -# name: webhook-service +configurations: + - kustomizeconfig.yaml +vars: + - name: CERTIFICATE_NAMESPACE # namespace of the certificate CR + objref: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + fieldref: + fieldpath: metadata.namespace + - name: CERTIFICATE_NAME + objref: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + - name: SERVICE_NAMESPACE # namespace of the service + objref: + kind: Service + version: v1 + name: webhook-service + fieldref: + fieldpath: metadata.namespace + - name: SERVICE_NAME + objref: + kind: Service + version: v1 + name: webhook-service + diff --git a/bootstrap/config/default/kustomizeconfig.yaml b/bootstrap/config/default/kustomizeconfig.yaml new file mode 100644 index 00000000..524d39cc --- /dev/null +++ b/bootstrap/config/default/kustomizeconfig.yaml @@ -0,0 +1,4 @@ +# This configuration is for teaching kustomize how to update name ref and var substitution +varReference: + - kind: Deployment + path: spec/template/spec/volumes/secret/secretName diff --git a/bootstrap/config/default/manager_webhook_patch.yaml b/bootstrap/config/default/manager_webhook_patch.yaml index 738de350..b387eb0e 100644 --- a/bootstrap/config/default/manager_webhook_patch.yaml +++ b/bootstrap/config/default/manager_webhook_patch.yaml @@ -20,4 +20,4 @@ spec: - name: cert secret: defaultMode: 420 - secretName: webhook-server-cert + secretName: $(SERVICE_NAME)-cert diff --git a/bootstrap/config/default/webhookcainjection_patch.yaml b/bootstrap/config/default/webhookcainjection_patch.yaml index 7e79bf99..02ab515d 100644 --- a/bootstrap/config/default/webhookcainjection_patch.yaml +++ b/bootstrap/config/default/webhookcainjection_patch.yaml @@ -1,13 +1,13 @@ # This patch add annotation to admission webhook config and # the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. -apiVersion: admissionregistration.k8s.io/v1beta1 +apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: name: mutating-webhook-configuration annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) --- -apiVersion: admissionregistration.k8s.io/v1beta1 +apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: name: validating-webhook-configuration diff --git a/bootstrap/config/rbac/role.yaml b/bootstrap/config/rbac/role.yaml index e255dfa8..0e359c91 100644 --- a/bootstrap/config/rbac/role.yaml +++ b/bootstrap/config/rbac/role.yaml @@ -18,14 +18,6 @@ rules: - patch - update - watch -- apiGroups: - - apiextensions.k8s.io - resources: - - customresourcedefinitions - verbs: - - get - - list - - watch - apiGroups: - bootstrap.cluster.x-k8s.io resources: @@ -50,73 +42,16 @@ rules: - patch - update - watch -- apiGroups: - - bootstrap.cluster.x-k8s.io - - controlplane.cluster.x-k8s.io - - infrastructure.cluster.x-k8s.io - resources: - - '*' - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - cluster.x-k8s.io resources: - clusters - clusters/status - verbs: - - get - - list - - watch -- apiGroups: - - cluster.x-k8s.io - resources: - - clusters - - clusters/status - - machines - - machines/status - verbs: - - get - - list - - watch -- apiGroups: - - cluster.x-k8s.io - resources: - machines - machines/status verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - events - verbs: - - create - get - list - - patch - - watch -- apiGroups: - - "" - resources: - - secrets - verbs: - - create - - get - - list - - patch - - update - watch - apiGroups: - exp.cluster.x-k8s.io diff --git a/bootstrap/config/webhook/manifests.yaml b/bootstrap/config/webhook/manifests.yaml new file mode 100644 index 00000000..b8b0c4ac --- /dev/null +++ b/bootstrap/config/webhook/manifests.yaml @@ -0,0 +1,100 @@ +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + name: mutating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + - v1beta2 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfig + failurePolicy: Fail + matchPolicy: Equivalent + name: default.kthreesconfig.bootstrap.cluster.x-k8s.io + rules: + - apiGroups: + - bootstrap.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - kthreesconfig + sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta2 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfigtemplate + failurePolicy: Fail + matchPolicy: Equivalent + name: default.kthreesconfigtemplate.bootstrap.cluster.x-k8s.io + rules: + - apiGroups: + - bootstrap.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - kthreesconfigtemplate + sideEffects: None +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: validating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + - v1beta2 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfig + failurePolicy: Fail + matchPolicy: Equivalent + name: validation.kthreesconfig.bootstrap.cluster.x-k8s.io + rules: + - apiGroups: + - bootstrap.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - kthreesconfig + sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta2 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-controlplane-cluster-x-k8s-io-v1beta2-kthreesconfigtemplate + failurePolicy: Fail + matchPolicy: Equivalent + name: validation.kthreesconfigtemplate.bootstrap.cluster.x-k8s.io + rules: + - apiGroups: + - bootstrap.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - kthreesconfigtemplate + sideEffects: None diff --git a/bootstrap/controllers/kthreesconfig_controller.go b/bootstrap/controllers/kthreesconfig_controller.go index c9077e32..e054f181 100644 --- a/bootstrap/controllers/kthreesconfig_controller.go +++ b/bootstrap/controllers/kthreesconfig_controller.go @@ -41,7 +41,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" kubeyaml "sigs.k8s.io/yaml" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" "github.com/k3s-io/cluster-api-k3s/pkg/cloudinit" "github.com/k3s-io/cluster-api-k3s/pkg/etcd" "github.com/k3s-io/cluster-api-k3s/pkg/k3s" diff --git a/bootstrap/controllers/suite_test.go b/bootstrap/controllers/suite_test.go index f2d9c79f..d229a723 100644 --- a/bootstrap/controllers/suite_test.go +++ b/bootstrap/controllers/suite_test.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" bootstrapv1beta1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -57,8 +58,8 @@ var _ = BeforeSuite(func(done Done) { Expect(err).ToNot(HaveOccurred()) Expect(cfg).ToNot(BeNil()) - err = bootstrapv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) + Expect(bootstrapv1beta1.AddToScheme(scheme.Scheme)).Should(Succeed()) + Expect(bootstrapv1.AddToScheme(scheme.Scheme)).Should(Succeed()) // +kubebuilder:scaffold:scheme diff --git a/bootstrap/main.go b/bootstrap/main.go index 9d95b8c1..7b2578e1 100644 --- a/bootstrap/main.go +++ b/bootstrap/main.go @@ -33,6 +33,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" bootstrapv1beta1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" "github.com/k3s-io/cluster-api-k3s/bootstrap/controllers" ) @@ -46,6 +47,7 @@ func init() { _ = clusterv1beta1.AddToScheme(scheme) _ = expv1beta1.AddToScheme(scheme) _ = bootstrapv1beta1.AddToScheme(scheme) + _ = bootstrapv1.AddToScheme(scheme) // +kubebuilder:scaffold:scheme } @@ -93,6 +95,17 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "KThreesConfig") os.Exit(1) } + + if os.Getenv("ENABLE_WEBHOOKS") != "false" { + if err = (&bootstrapv1.KThreesConfig{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "KThreesConfig") + os.Exit(1) + } + if err = (&bootstrapv1.KThreesConfigTemplate{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "KThreesConfigTemplate") + os.Exit(1) + } + } // +kubebuilder:scaffold:builder setupLog.Info("starting manager") diff --git a/controlplane/PROJECT b/controlplane/PROJECT index 61b7a3dc..be56ccc1 100644 --- a/controlplane/PROJECT +++ b/controlplane/PROJECT @@ -4,4 +4,10 @@ resources: - group: controlplane kind: KThreesControlPlane version: v1beta1 +- group: controlplane + kind: KThreesControlPlane + version: v1beta2 +- group: controlplane + kind: KThreesControlPlaneTemplate + version: v1beta2 version: "2" diff --git a/controlplane/api/v1beta1/condition_consts.go b/controlplane/api/v1beta1/condition_consts.go index d8efb422..a9d7c70e 100644 --- a/controlplane/api/v1beta1/condition_consts.go +++ b/controlplane/api/v1beta1/condition_consts.go @@ -1,5 +1,5 @@ /* -Copyright 2020 The Kubernetes Authors. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/controlplane/api/v1beta1/conversion.go b/controlplane/api/v1beta1/conversion.go new file mode 100644 index 00000000..4a6fbd27 --- /dev/null +++ b/controlplane/api/v1beta1/conversion.go @@ -0,0 +1,107 @@ +/* +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 ( + "fmt" + unsafe "unsafe" + + "k8s.io/apimachinery/pkg/conversion" + ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion" + + bootstrapv1beta1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1beta2 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + cabp3v1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" +) + +func Convert_v1beta1_KThreesControlPlaneSpec_To_v1beta2_KThreesControlPlaneSpec(in *KThreesControlPlaneSpec, out *cabp3v1.KThreesControlPlaneSpec, s conversion.Scope) error { //nolint: stylecheck + out.Replicas = in.Replicas + out.Version = in.Version + if err := Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(&in.KThreesConfigSpec, &out.KThreesConfigSpec, s); err != nil { + return fmt.Errorf("converting KThreesConfigSpec field from v1beta1 to v1beta2: %w", err) + } + out.UpgradeAfter = in.UpgradeAfter + if err := Convert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate(&in.MachineTemplate, &out.MachineTemplate, s); err != nil { + return fmt.Errorf("converting KThreesControlPlaneMachineTemplate field from v1beta1 to v1beta2: %w", err) + } + out.MachineTemplate.NodeDrainTimeout = in.NodeDrainTimeout + out.MachineTemplate.InfrastructureRef = in.InfrastructureTemplate + out.RemediationStrategy = (*cabp3v1.RemediationStrategy)(unsafe.Pointer(in.RemediationStrategy)) + return nil +} + +func Convert_v1beta2_KThreesControlPlaneSpec_To_v1beta1_KThreesControlPlaneSpec(in *cabp3v1.KThreesControlPlaneSpec, out *KThreesControlPlaneSpec, s conversion.Scope) error { //nolint: stylecheck + out.Replicas = in.Replicas + out.Version = in.Version + out.InfrastructureTemplate = in.MachineTemplate.InfrastructureRef + if err := Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(&in.KThreesConfigSpec, &out.KThreesConfigSpec, s); err != nil { + return fmt.Errorf("converting KThreesConfigSpec field from v1beta2 to v1beta1: %w", err) + } + out.UpgradeAfter = in.UpgradeAfter + out.NodeDrainTimeout = in.MachineTemplate.NodeDrainTimeout + if err := Convert_v1beta2_KThreesControlPlaneMachineTemplate_To_v1beta1_KThreesControlPlaneMachineTemplate(&in.MachineTemplate, &out.MachineTemplate, s); err != nil { + return fmt.Errorf("converting KThreesControlPlaneMachineTemplate field from v1beta2 to v1beta1: %w", err) + } + out.RemediationStrategy = (*RemediationStrategy)(unsafe.Pointer(in.RemediationStrategy)) + return nil +} + +func Convert_v1beta2_KThreesControlPlaneMachineTemplate_To_v1beta1_KThreesControlPlaneMachineTemplate(in *cabp3v1.KThreesControlPlaneMachineTemplate, out *KThreesControlPlaneMachineTemplate, s conversion.Scope) error { //nolint: stylecheck + out.ObjectMeta = in.ObjectMeta + return nil +} + +func Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(in *bootstrapv1beta1.KThreesConfigSpec, out *bootstrapv1beta2.KThreesConfigSpec, s conversion.Scope) error { //nolint: stylecheck + return bootstrapv1beta1.Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(in, out, s) +} + +func Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(in *bootstrapv1beta2.KThreesConfigSpec, out *bootstrapv1beta1.KThreesConfigSpec, s conversion.Scope) error { //nolint: stylecheck + return bootstrapv1beta1.Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(in, out, s) +} + +// ConvertTo converts the v1beta1 KThreesControlPlane receiver to a v1beta2 KThreesControlPlane. +func (in *KThreesControlPlane) ConvertTo(dstRaw ctrlconversion.Hub) error { + dst := dstRaw.(*cabp3v1.KThreesControlPlane) + if err := Convert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane(in, dst, nil); err != nil { + return fmt.Errorf("converting KThreesControlPlane v1beta1 to v1beta2: %w", err) + } + return nil +} + +// ConvertFrom converts the v1beta1 KThreesControlPlane receiver from a v1beta2 KThreesControlPlane. +func (in *KThreesControlPlane) ConvertFrom(srcRaw ctrlconversion.Hub) error { + src := srcRaw.(*cabp3v1.KThreesControlPlane) + if err := Convert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane(src, in, nil); err != nil { + return fmt.Errorf("converting KThreesControlPlane v1beta1 from v1beta2: %w", err) + } + return nil +} + +// ConvertTo converts the v1beta1 KThreesControlPlaneList receiver to a v1beta2 KThreesControlPlaneList. +func (in *KThreesControlPlaneList) ConvertTo(dstRaw ctrlconversion.Hub) error { + dst := dstRaw.(*cabp3v1.KThreesControlPlaneList) + if err := Convert_v1beta1_KThreesControlPlaneList_To_v1beta2_KThreesControlPlaneList(in, dst, nil); err != nil { + return fmt.Errorf("converting KThreesControlPlaneList v1beta1 to v1beta2: %w", err) + } + return nil +} + +// ConvertFrom converts the v1beta1 KThreesControlPlaneList receiver from a v1beta2 KThreesControlPlaneList. +func (in *KThreesControlPlaneList) ConvertFrom(srcRaw ctrlconversion.Hub) error { + src := srcRaw.(*cabp3v1.KThreesControlPlaneList) + if err := Convert_v1beta2_KThreesControlPlaneList_To_v1beta1_KThreesControlPlaneList(src, in, nil); err != nil { + return fmt.Errorf("converting KThreesControlPlaneList v1beta1 from v1beta2: %w", err) + } + return nil +} diff --git a/controlplane/api/v1beta1/conversion_test.go b/controlplane/api/v1beta1/conversion_test.go new file mode 100644 index 00000000..8be11453 --- /dev/null +++ b/controlplane/api/v1beta1/conversion_test.go @@ -0,0 +1,39 @@ +/* +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 ( + "testing" + + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + "k8s.io/apimachinery/pkg/runtime" + utilconversion "sigs.k8s.io/cluster-api/util/conversion" + + cabp3v1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" +) + +func TestFuzzyConversion(t *testing.T) { + g := NewWithT(t) + scheme := runtime.NewScheme() + g.Expect(AddToScheme(scheme)).To(Succeed()) + g.Expect(cabp3v1.AddToScheme(scheme)).To(Succeed()) + + t.Run("for KThreesControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ + Scheme: scheme, + Hub: &cabp3v1.KThreesControlPlane{}, + Spoke: &KThreesControlPlane{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + })) +} diff --git a/controlplane/api/v1beta1/doc.go b/controlplane/api/v1beta1/doc.go new file mode 100644 index 00000000..064d2310 --- /dev/null +++ b/controlplane/api/v1beta1/doc.go @@ -0,0 +1,22 @@ +/* + + +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 contains API Schema definitions for the controlplane v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=controlplane.cluster.x-k8s.io +// +k8s:defaulter-gen=TypeMeta +// +k8s:conversion-gen=github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2 +package v1beta1 diff --git a/controlplane/api/v1beta1/groupversion_info.go b/controlplane/api/v1beta1/groupversion_info.go index 318dec14..802a7195 100644 --- a/controlplane/api/v1beta1/groupversion_info.go +++ b/controlplane/api/v1beta1/groupversion_info.go @@ -14,9 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1beta1 contains API Schema definitions for the controlplane v1beta1 API group -// +kubebuilder:object:generate=true -// +groupName=controlplane.cluster.x-k8s.io package v1beta1 import ( @@ -33,4 +30,7 @@ var ( // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme + + // localSchemeBuilder is used by the conversion-gen tool. + localSchemeBuilder = SchemeBuilder.SchemeBuilder ) diff --git a/controlplane/api/v1beta1/zz_generated.conversion.go b/controlplane/api/v1beta1/zz_generated.conversion.go new file mode 100644 index 00000000..69c2361d --- /dev/null +++ b/controlplane/api/v1beta1/zz_generated.conversion.go @@ -0,0 +1,335 @@ +//go:build !ignore_autogenerated_conversions +// +build !ignore_autogenerated_conversions + +/* + + +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. +*/ +// Code generated by conversion-gen-v0.29.0. DO NOT EDIT. + +package v1beta1 + +import ( + unsafe "unsafe" + + apiv1beta1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + apiv1beta2 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + v1beta2 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" + errors "github.com/k3s-io/cluster-api-k3s/pkg/errors" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + clusterapiapiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*KThreesControlPlane)(nil), (*v1beta2.KThreesControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane(a.(*KThreesControlPlane), b.(*v1beta2.KThreesControlPlane), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesControlPlane)(nil), (*KThreesControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane(a.(*v1beta2.KThreesControlPlane), b.(*KThreesControlPlane), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesControlPlaneList)(nil), (*v1beta2.KThreesControlPlaneList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesControlPlaneList_To_v1beta2_KThreesControlPlaneList(a.(*KThreesControlPlaneList), b.(*v1beta2.KThreesControlPlaneList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesControlPlaneList)(nil), (*KThreesControlPlaneList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesControlPlaneList_To_v1beta1_KThreesControlPlaneList(a.(*v1beta2.KThreesControlPlaneList), b.(*KThreesControlPlaneList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesControlPlaneMachineTemplate)(nil), (*v1beta2.KThreesControlPlaneMachineTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate(a.(*KThreesControlPlaneMachineTemplate), b.(*v1beta2.KThreesControlPlaneMachineTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KThreesControlPlaneStatus)(nil), (*v1beta2.KThreesControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesControlPlaneStatus_To_v1beta2_KThreesControlPlaneStatus(a.(*KThreesControlPlaneStatus), b.(*v1beta2.KThreesControlPlaneStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KThreesControlPlaneStatus)(nil), (*KThreesControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesControlPlaneStatus_To_v1beta1_KThreesControlPlaneStatus(a.(*v1beta2.KThreesControlPlaneStatus), b.(*KThreesControlPlaneStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*LastRemediationStatus)(nil), (*v1beta2.LastRemediationStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(a.(*LastRemediationStatus), b.(*v1beta2.LastRemediationStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.LastRemediationStatus)(nil), (*LastRemediationStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(a.(*v1beta2.LastRemediationStatus), b.(*LastRemediationStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*RemediationStrategy)(nil), (*v1beta2.RemediationStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_RemediationStrategy_To_v1beta2_RemediationStrategy(a.(*RemediationStrategy), b.(*v1beta2.RemediationStrategy), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.RemediationStrategy)(nil), (*RemediationStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_RemediationStrategy_To_v1beta1_RemediationStrategy(a.(*v1beta2.RemediationStrategy), b.(*RemediationStrategy), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiv1beta1.KThreesConfigSpec)(nil), (*apiv1beta2.KThreesConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(a.(*apiv1beta1.KThreesConfigSpec), b.(*apiv1beta2.KThreesConfigSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*KThreesControlPlaneSpec)(nil), (*v1beta2.KThreesControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KThreesControlPlaneSpec_To_v1beta2_KThreesControlPlaneSpec(a.(*KThreesControlPlaneSpec), b.(*v1beta2.KThreesControlPlaneSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiv1beta2.KThreesConfigSpec)(nil), (*apiv1beta1.KThreesConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(a.(*apiv1beta2.KThreesConfigSpec), b.(*apiv1beta1.KThreesConfigSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.KThreesControlPlaneMachineTemplate)(nil), (*KThreesControlPlaneMachineTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesControlPlaneMachineTemplate_To_v1beta1_KThreesControlPlaneMachineTemplate(a.(*v1beta2.KThreesControlPlaneMachineTemplate), b.(*KThreesControlPlaneMachineTemplate), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.KThreesControlPlaneSpec)(nil), (*KThreesControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KThreesControlPlaneSpec_To_v1beta1_KThreesControlPlaneSpec(a.(*v1beta2.KThreesControlPlaneSpec), b.(*KThreesControlPlaneSpec), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane(in *KThreesControlPlane, out *v1beta2.KThreesControlPlane, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_KThreesControlPlaneSpec_To_v1beta2_KThreesControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta1_KThreesControlPlaneStatus_To_v1beta2_KThreesControlPlaneStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane is an autogenerated conversion function. +func Convert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane(in *KThreesControlPlane, out *v1beta2.KThreesControlPlane, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane(in, out, s) +} + +func autoConvert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane(in *v1beta2.KThreesControlPlane, out *KThreesControlPlane, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_KThreesControlPlaneSpec_To_v1beta1_KThreesControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta2_KThreesControlPlaneStatus_To_v1beta1_KThreesControlPlaneStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane is an autogenerated conversion function. +func Convert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane(in *v1beta2.KThreesControlPlane, out *KThreesControlPlane, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane(in, out, s) +} + +func autoConvert_v1beta1_KThreesControlPlaneList_To_v1beta2_KThreesControlPlaneList(in *KThreesControlPlaneList, out *v1beta2.KThreesControlPlaneList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.KThreesControlPlane, len(*in)) + for i := range *in { + if err := Convert_v1beta1_KThreesControlPlane_To_v1beta2_KThreesControlPlane(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta1_KThreesControlPlaneList_To_v1beta2_KThreesControlPlaneList is an autogenerated conversion function. +func Convert_v1beta1_KThreesControlPlaneList_To_v1beta2_KThreesControlPlaneList(in *KThreesControlPlaneList, out *v1beta2.KThreesControlPlaneList, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesControlPlaneList_To_v1beta2_KThreesControlPlaneList(in, out, s) +} + +func autoConvert_v1beta2_KThreesControlPlaneList_To_v1beta1_KThreesControlPlaneList(in *v1beta2.KThreesControlPlaneList, out *KThreesControlPlaneList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KThreesControlPlane, len(*in)) + for i := range *in { + if err := Convert_v1beta2_KThreesControlPlane_To_v1beta1_KThreesControlPlane(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta2_KThreesControlPlaneList_To_v1beta1_KThreesControlPlaneList is an autogenerated conversion function. +func Convert_v1beta2_KThreesControlPlaneList_To_v1beta1_KThreesControlPlaneList(in *v1beta2.KThreesControlPlaneList, out *KThreesControlPlaneList, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesControlPlaneList_To_v1beta1_KThreesControlPlaneList(in, out, s) +} + +func autoConvert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate(in *KThreesControlPlaneMachineTemplate, out *v1beta2.KThreesControlPlaneMachineTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + return nil +} + +// Convert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate is an autogenerated conversion function. +func Convert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate(in *KThreesControlPlaneMachineTemplate, out *v1beta2.KThreesControlPlaneMachineTemplate, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate(in, out, s) +} + +func autoConvert_v1beta2_KThreesControlPlaneMachineTemplate_To_v1beta1_KThreesControlPlaneMachineTemplate(in *v1beta2.KThreesControlPlaneMachineTemplate, out *KThreesControlPlaneMachineTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + // WARNING: in.InfrastructureRef requires manual conversion: does not exist in peer-type + // WARNING: in.NodeDrainTimeout requires manual conversion: does not exist in peer-type + return nil +} + +func autoConvert_v1beta1_KThreesControlPlaneSpec_To_v1beta2_KThreesControlPlaneSpec(in *KThreesControlPlaneSpec, out *v1beta2.KThreesControlPlaneSpec, s conversion.Scope) error { + out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) + out.Version = in.Version + // WARNING: in.InfrastructureTemplate requires manual conversion: does not exist in peer-type + if err := Convert_v1beta1_KThreesConfigSpec_To_v1beta2_KThreesConfigSpec(&in.KThreesConfigSpec, &out.KThreesConfigSpec, s); err != nil { + return err + } + out.UpgradeAfter = (*v1.Time)(unsafe.Pointer(in.UpgradeAfter)) + // WARNING: in.NodeDrainTimeout requires manual conversion: does not exist in peer-type + if err := Convert_v1beta1_KThreesControlPlaneMachineTemplate_To_v1beta2_KThreesControlPlaneMachineTemplate(&in.MachineTemplate, &out.MachineTemplate, s); err != nil { + return err + } + out.RemediationStrategy = (*v1beta2.RemediationStrategy)(unsafe.Pointer(in.RemediationStrategy)) + return nil +} + +func autoConvert_v1beta2_KThreesControlPlaneSpec_To_v1beta1_KThreesControlPlaneSpec(in *v1beta2.KThreesControlPlaneSpec, out *KThreesControlPlaneSpec, s conversion.Scope) error { + out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) + out.Version = in.Version + if err := Convert_v1beta2_KThreesConfigSpec_To_v1beta1_KThreesConfigSpec(&in.KThreesConfigSpec, &out.KThreesConfigSpec, s); err != nil { + return err + } + out.UpgradeAfter = (*v1.Time)(unsafe.Pointer(in.UpgradeAfter)) + if err := Convert_v1beta2_KThreesControlPlaneMachineTemplate_To_v1beta1_KThreesControlPlaneMachineTemplate(&in.MachineTemplate, &out.MachineTemplate, s); err != nil { + return err + } + out.RemediationStrategy = (*RemediationStrategy)(unsafe.Pointer(in.RemediationStrategy)) + return nil +} + +func autoConvert_v1beta1_KThreesControlPlaneStatus_To_v1beta2_KThreesControlPlaneStatus(in *KThreesControlPlaneStatus, out *v1beta2.KThreesControlPlaneStatus, s conversion.Scope) error { + out.Selector = in.Selector + out.Replicas = in.Replicas + out.UpdatedReplicas = in.UpdatedReplicas + out.ReadyReplicas = in.ReadyReplicas + out.UnavailableReplicas = in.UnavailableReplicas + out.Initialized = in.Initialized + out.Ready = in.Ready + out.FailureReason = errors.KThreesControlPlaneStatusError(in.FailureReason) + out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + out.ObservedGeneration = in.ObservedGeneration + out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + out.LastRemediation = (*v1beta2.LastRemediationStatus)(unsafe.Pointer(in.LastRemediation)) + return nil +} + +// Convert_v1beta1_KThreesControlPlaneStatus_To_v1beta2_KThreesControlPlaneStatus is an autogenerated conversion function. +func Convert_v1beta1_KThreesControlPlaneStatus_To_v1beta2_KThreesControlPlaneStatus(in *KThreesControlPlaneStatus, out *v1beta2.KThreesControlPlaneStatus, s conversion.Scope) error { + return autoConvert_v1beta1_KThreesControlPlaneStatus_To_v1beta2_KThreesControlPlaneStatus(in, out, s) +} + +func autoConvert_v1beta2_KThreesControlPlaneStatus_To_v1beta1_KThreesControlPlaneStatus(in *v1beta2.KThreesControlPlaneStatus, out *KThreesControlPlaneStatus, s conversion.Scope) error { + out.Selector = in.Selector + out.Replicas = in.Replicas + out.UpdatedReplicas = in.UpdatedReplicas + out.ReadyReplicas = in.ReadyReplicas + out.UnavailableReplicas = in.UnavailableReplicas + out.Initialized = in.Initialized + out.Ready = in.Ready + out.FailureReason = errors.KThreesControlPlaneStatusError(in.FailureReason) + out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + out.ObservedGeneration = in.ObservedGeneration + out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + out.LastRemediation = (*LastRemediationStatus)(unsafe.Pointer(in.LastRemediation)) + return nil +} + +// Convert_v1beta2_KThreesControlPlaneStatus_To_v1beta1_KThreesControlPlaneStatus is an autogenerated conversion function. +func Convert_v1beta2_KThreesControlPlaneStatus_To_v1beta1_KThreesControlPlaneStatus(in *v1beta2.KThreesControlPlaneStatus, out *KThreesControlPlaneStatus, s conversion.Scope) error { + return autoConvert_v1beta2_KThreesControlPlaneStatus_To_v1beta1_KThreesControlPlaneStatus(in, out, s) +} + +func autoConvert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in *LastRemediationStatus, out *v1beta2.LastRemediationStatus, s conversion.Scope) error { + out.Machine = in.Machine + out.Timestamp = in.Timestamp + out.RetryCount = in.RetryCount + return nil +} + +// Convert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus is an autogenerated conversion function. +func Convert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in *LastRemediationStatus, out *v1beta2.LastRemediationStatus, s conversion.Scope) error { + return autoConvert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in, out, s) +} + +func autoConvert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in *v1beta2.LastRemediationStatus, out *LastRemediationStatus, s conversion.Scope) error { + out.Machine = in.Machine + out.Timestamp = in.Timestamp + out.RetryCount = in.RetryCount + return nil +} + +// Convert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus is an autogenerated conversion function. +func Convert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in *v1beta2.LastRemediationStatus, out *LastRemediationStatus, s conversion.Scope) error { + return autoConvert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in, out, s) +} + +func autoConvert_v1beta1_RemediationStrategy_To_v1beta2_RemediationStrategy(in *RemediationStrategy, out *v1beta2.RemediationStrategy, s conversion.Scope) error { + out.MaxRetry = (*int32)(unsafe.Pointer(in.MaxRetry)) + out.RetryPeriod = in.RetryPeriod + out.MinHealthyPeriod = (*v1.Duration)(unsafe.Pointer(in.MinHealthyPeriod)) + return nil +} + +// Convert_v1beta1_RemediationStrategy_To_v1beta2_RemediationStrategy is an autogenerated conversion function. +func Convert_v1beta1_RemediationStrategy_To_v1beta2_RemediationStrategy(in *RemediationStrategy, out *v1beta2.RemediationStrategy, s conversion.Scope) error { + return autoConvert_v1beta1_RemediationStrategy_To_v1beta2_RemediationStrategy(in, out, s) +} + +func autoConvert_v1beta2_RemediationStrategy_To_v1beta1_RemediationStrategy(in *v1beta2.RemediationStrategy, out *RemediationStrategy, s conversion.Scope) error { + out.MaxRetry = (*int32)(unsafe.Pointer(in.MaxRetry)) + out.RetryPeriod = in.RetryPeriod + out.MinHealthyPeriod = (*v1.Duration)(unsafe.Pointer(in.MinHealthyPeriod)) + return nil +} + +// Convert_v1beta2_RemediationStrategy_To_v1beta1_RemediationStrategy is an autogenerated conversion function. +func Convert_v1beta2_RemediationStrategy_To_v1beta1_RemediationStrategy(in *v1beta2.RemediationStrategy, out *RemediationStrategy, s conversion.Scope) error { + return autoConvert_v1beta2_RemediationStrategy_To_v1beta1_RemediationStrategy(in, out, s) +} diff --git a/controlplane/api/v1beta1/zz_generated.deepcopy.go b/controlplane/api/v1beta1/zz_generated.deepcopy.go index ca729dfe..8663dfb3 100644 --- a/controlplane/api/v1beta1/zz_generated.deepcopy.go +++ b/controlplane/api/v1beta1/zz_generated.deepcopy.go @@ -22,7 +22,7 @@ package v1beta1 import ( "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" ) diff --git a/controlplane/api/v1beta2/condition_consts.go b/controlplane/api/v1beta2/condition_consts.go new file mode 100644 index 00000000..b181cf78 --- /dev/null +++ b/controlplane/api/v1beta2/condition_consts.go @@ -0,0 +1,130 @@ +/* + + +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 v1beta2 + +import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + +// Conditions and condition Reasons for the KThreesControlPlane object. + +const ( + // MachinesReady reports an aggregate of current status of the machines controlled by the KThreesControlPlane. + MachinesReadyCondition clusterv1.ConditionType = "MachinesReady" +) + +const ( + // CertificatesAvailableCondition documents that cluster certificates were generated as part of the + // processing of a KThreesControlPlane object. + CertificatesAvailableCondition clusterv1.ConditionType = "CertificatesAvailable" + + // CertificatesGenerationFailedReason (Severity=Warning) documents a KThreesControlPlane controller detecting + // an error while generating certificates; those kind of errors are usually temporary and the controller + // automatically recover from them. + CertificatesGenerationFailedReason = "CertificatesGenerationFailed" +) + +const ( + // AvailableCondition documents that the first control plane instance has completed the server init operation + // and so the control plane is available and an API server instance is ready for processing requests. + AvailableCondition clusterv1.ConditionType = "Available" + + // WaitingForKthreesServerReason (Severity=Info) documents a KThreesControlPlane object waiting for the first + // control plane instance to complete the k3s server operation. + WaitingForKthreesServerReason = "WaitingForKthreesServer" +) + +const ( + // MachinesSpecUpToDateCondition documents that the spec of the machines controlled by the KThreesControlPlane + // is up to date. Whe this condition is false, the KThreesControlPlane is executing a rolling upgrade. + MachinesSpecUpToDateCondition clusterv1.ConditionType = "MachinesSpecUpToDate" + + // RollingUpdateInProgressReason (Severity=Warning) documents a KThreesControlPlane object executing a + // rolling upgrade for aligning the machines spec to the desired state. + RollingUpdateInProgressReason = "RollingUpdateInProgress" +) + +const ( + // ResizedCondition documents a KThreesControlPlane that is resizing the set of controlled machines. + ResizedCondition clusterv1.ConditionType = "Resized" + + // ScalingUpReason (Severity=Info) documents a KThreesControlPlane that is increasing the number of replicas. + ScalingUpReason = "ScalingUp" + + // ScalingDownReason (Severity=Info) documents a KThreesControlPlane that is decreasing the number of replicas. + ScalingDownReason = "ScalingDown" +) + +const ( + // ControlPlaneComponentsHealthyCondition reports the overall status of the k3s server. + ControlPlaneComponentsHealthyCondition clusterv1.ConditionType = "ControlPlaneComponentsHealthy" + + // ControlPlaneComponentsUnhealthyReason (Severity=Error) documents a control plane component not healthy. + ControlPlaneComponentsUnhealthyReason = "ControlPlaneComponentsUnhealthy" + + // ControlPlaneComponentsUnknownReason reports a control plane component in unknown status. + ControlPlaneComponentsUnknownReason = "ControlPlaneComponentsUnknown" + + // ControlPlaneComponentsInspectionFailedReason documents a failure in inspecting the control plane component status. + ControlPlaneComponentsInspectionFailedReason = "ControlPlaneComponentsInspectionFailed" + + // MachineAgentHealthyCondition reports a machine's k3s agent's operational status. + MachineAgentHealthyCondition clusterv1.ConditionType = "AgentHealthy" + + // PodProvisioningReason (Severity=Info) documents a pod waiting to be provisioned i.e., Pod is in "Pending" phase. + PodProvisioningReason = "PodProvisioning" + + // PodMissingReason (Severity=Error) documents a pod does not exist. + PodMissingReason = "PodMissing" + + // PodFailedReason (Severity=Error) documents if a pod failed during provisioning i.e., e.g CrashLoopbackOff, ImagePullBackOff + // or if all the containers in a pod have terminated. + PodFailedReason = "PodFailed" + + // PodInspectionFailedReason documents a failure in inspecting the pod status. + PodInspectionFailedReason = "PodInspectionFailed" +) + +const ( + // EtcdClusterHealthyCondition documents the overall etcd cluster's health. + EtcdClusterHealthyCondition clusterv1.ConditionType = "EtcdClusterHealthyCondition" + + // EtcdClusterInspectionFailedReason documents a failure in inspecting the etcd cluster status. + EtcdClusterInspectionFailedReason = "EtcdClusterInspectionFailed" + + // EtcdClusterUnknownReason reports an etcd cluster in unknown status. + EtcdClusterUnknownReason = "EtcdClusterUnknown" + + // EtcdClusterUnhealthyReason (Severity=Error) is set when the etcd cluster is unhealthy. + EtcdClusterUnhealthyReason = "EtcdClusterUnhealthy" + + // MachineEtcdMemberHealthyCondition report the machine's etcd member's health status. + // NOTE: This conditions exists only if a stacked etcd cluster is used. + MachineEtcdMemberHealthyCondition clusterv1.ConditionType = "EtcdMemberHealthy" + + // EtcdMemberInspectionFailedReason documents a failure in inspecting the etcd member status. + EtcdMemberInspectionFailedReason = "MemberInspectionFailed" + + // EtcdMemberUnhealthyReason (Severity=Error) documents a Machine's etcd member is unhealthy. + EtcdMemberUnhealthyReason = "EtcdMemberUnhealthy" +) + +const ( + // TokenAvailableCondition documents whether the token required for nodes to join the cluster is available. + TokenAvailableCondition clusterv1.ConditionType = "TokenAvailable" + + // TokenGenerationFailedReason documents that the token required for nodes to join the cluster could not be generated. + TokenGenerationFailedReason = "TokenGenerationFailed" +) diff --git a/controlplane/api/v1beta2/conversion.go b/controlplane/api/v1beta2/conversion.go new file mode 100644 index 00000000..74e5d9f7 --- /dev/null +++ b/controlplane/api/v1beta2/conversion.go @@ -0,0 +1,23 @@ +/* + + +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 v1beta2 + +// Hub marks KThreesControlPlane as a conversion hub. +func (*KThreesControlPlane) Hub() {} + +// Hub marks KThreesControlPlaneList as a conversion hub. +func (*KThreesControlPlaneList) Hub() {} diff --git a/controlplane/api/v1beta2/doc.go b/controlplane/api/v1beta2/doc.go new file mode 100644 index 00000000..238de720 --- /dev/null +++ b/controlplane/api/v1beta2/doc.go @@ -0,0 +1,21 @@ +/* + + +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 contains API Schema definitions for the controlplane v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=controlplane.cluster.x-k8s.io +// +k8s:defaulter-gen=TypeMeta +package v1beta2 diff --git a/controlplane/api/v1beta2/groupversion_info.go b/controlplane/api/v1beta2/groupversion_info.go new file mode 100644 index 00000000..58f2bc51 --- /dev/null +++ b/controlplane/api/v1beta2/groupversion_info.go @@ -0,0 +1,33 @@ +/* + + +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 v1beta2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "controlplane.cluster.x-k8s.io", Version: "v1beta2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/controlplane/api/v1beta2/kthreescontrolplane_types.go b/controlplane/api/v1beta2/kthreescontrolplane_types.go new file mode 100644 index 00000000..63a7fe84 --- /dev/null +++ b/controlplane/api/v1beta2/kthreescontrolplane_types.go @@ -0,0 +1,270 @@ +/* + + +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 v1beta2 + +import ( + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + + cabp3v1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + "github.com/k3s-io/cluster-api-k3s/pkg/errors" +) + +const ( + KThreesControlPlaneFinalizer = "kthrees.controlplane.cluster.x-k8s.io" + + // KThreesServerConfigurationAnnotation is a machine annotation that stores the json-marshalled string of KCP ClusterConfiguration. + // This annotation is used to detect any changes in ClusterConfiguration and trigger machine rollout in KCP. + KThreesServerConfigurationAnnotation = "controlplane.cluster.x-k8s.io/kthrees-server-configuration" + + // SkipCoreDNSAnnotation annotation explicitly skips reconciling CoreDNS if set. + SkipCoreDNSAnnotation = "controlplane.cluster.x-k8s.io/skip-coredns" + + // RemediationInProgressAnnotation is used to keep track that a KCP remediation is in progress, and more + // specifically it tracks that the system is in between having deleted an unhealthy machine and recreating its replacement. + // NOTE: if something external to CAPI removes this annotation the system cannot detect the above situation; this can lead to + // failures in updating remediation retry or remediation count (both counters restart from zero). + RemediationInProgressAnnotation = "controlplane.cluster.x-k8s.io/remediation-in-progress" + + // RemediationForAnnotation is used to link a new machine to the unhealthy machine it is replacing; + // please note that in case of retry, when also the remediating machine fails, the system keeps track of + // the first machine of the sequence only. + // NOTE: if something external to CAPI removes this annotation the system this can lead to + // failures in updating remediation retry (the counter restarts from zero). + RemediationForAnnotation = "controlplane.cluster.x-k8s.io/remediation-for" + + // DefaultMinHealthyPeriod defines the default minimum period before we consider a remediation on a + // machine unrelated from the previous remediation. + DefaultMinHealthyPeriod = 1 * time.Hour +) + +// KThreesControlPlaneSpec defines the desired state of KThreesControlPlane. +type KThreesControlPlaneSpec struct { + // Number of desired machines. Defaults to 1. When stacked etcd is used only + // odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members). + // This is a pointer to distinguish between explicit zero and not specified. + // +optional + Replicas *int32 `json:"replicas,omitempty"` + + // Version defines the desired Kubernetes version. + Version string `json:"version"` + + // KThreesConfigSpec is a KThreesConfigSpec + // to use for initializing and joining machines to the control plane. + // +optional + KThreesConfigSpec cabp3v1.KThreesConfigSpec `json:"kthreesConfigSpec,omitempty"` + + // UpgradeAfter is a field to indicate an upgrade should be performed + // after the specified time even if no changes have been made to the + // KThreesControlPlane + // +optional + UpgradeAfter *metav1.Time `json:"upgradeAfter,omitempty"` + + // MachineTemplate contains information about how machines should be shaped + // when creating or updating a control plane. + MachineTemplate KThreesControlPlaneMachineTemplate `json:"machineTemplate,omitempty"` + + // The RemediationStrategy that controls how control plane machine remediation happens. + // +optional + RemediationStrategy *RemediationStrategy `json:"remediationStrategy,omitempty"` +} + +// MachineTemplate contains information about how machines should be shaped +// when creating or updating a control plane. +type KThreesControlPlaneMachineTemplate struct { + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` + // InfrastructureRef is a required reference to a custom resource + // offered by an infrastructure provider. + InfrastructureRef corev1.ObjectReference `json:"infrastructureRef"` + // NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node + // The default value is 0, meaning that the node can be drained without any time limitations. + // NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` + // +optional + NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"` +} + +// RemediationStrategy allows to define how control plane machine remediation happens. +type RemediationStrategy struct { + // MaxRetry is the Max number of retries while attempting to remediate an unhealthy machine. + // A retry happens when a machine that was created as a replacement for an unhealthy machine also fails. + // For example, given a control plane with three machines M1, M2, M3: + // + // M1 become unhealthy; remediation happens, and M1-1 is created as a replacement. + // If M1-1 (replacement of M1) has problems while bootstrapping it will become unhealthy, and then be + // remediated; such operation is considered a retry, remediation-retry #1. + // If M1-2 (replacement of M1-1) becomes unhealthy, remediation-retry #2 will happen, etc. + // + // A retry could happen only after RetryPeriod from the previous retry. + // If a machine is marked as unhealthy after MinHealthyPeriod from the previous remediation expired, + // this is not considered a retry anymore because the new issue is assumed unrelated from the previous one. + // + // If not set, the remedation will be retried infinitely. + // +optional + MaxRetry *int32 `json:"maxRetry,omitempty"` + + // RetryPeriod is the duration that KCP should wait before remediating a machine being created as a replacement + // for an unhealthy machine (a retry). + // + // If not set, a retry will happen immediately. + // +optional + RetryPeriod metav1.Duration `json:"retryPeriod,omitempty"` + + // MinHealthyPeriod defines the duration after which KCP will consider any failure to a machine unrelated + // from the previous one. In this case the remediation is not considered a retry anymore, and thus the retry + // counter restarts from 0. For example, assuming MinHealthyPeriod is set to 1h (default) + // + // M1 become unhealthy; remediation happens, and M1-1 is created as a replacement. + // If M1-1 (replacement of M1) has problems within the 1hr after the creation, also + // this machine will be remediated and this operation is considered a retry - a problem related + // to the original issue happened to M1 -. + // + // If instead the problem on M1-1 is happening after MinHealthyPeriod expired, e.g. four days after + // m1-1 has been created as a remediation of M1, the problem on M1-1 is considered unrelated to + // the original issue happened to M1. + // + // If not set, this value is defaulted to 1h. + // +optional + MinHealthyPeriod *metav1.Duration `json:"minHealthyPeriod,omitempty"` +} + +// KThreesControlPlaneStatus defines the observed state of KThreesControlPlane. +type KThreesControlPlaneStatus struct { + // Selector is the label selector in string format to avoid introspection + // by clients, and is used to provide the CRD-based integration for the + // scale subresource and additional integrations for things like kubectl + // describe.. The string will be in the same format as the query-param syntax. + // More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors + // +optional + Selector string `json:"selector,omitempty"` + + // Total number of non-terminated machines targeted by this control plane + // (their labels match the selector). + // +optional + Replicas int32 `json:"replicas,omitempty"` + + // Total number of non-terminated machines targeted by this control plane + // that have the desired template spec. + // +optional + UpdatedReplicas int32 `json:"updatedReplicas,omitempty"` + + // Total number of fully running and ready control plane machines. + // +optional + ReadyReplicas int32 `json:"readyReplicas,omitempty"` + + // Total number of unavailable machines targeted by this control plane. + // This is the total number of machines that are still required for + // the deployment to have 100% available capacity. They may either + // be machines that are running but not yet ready or machines + // that still have not been created. + // +optional + UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"` + + // Initialized denotes whether or not the k3s server is initialized. + // +optional + Initialized bool `json:"initialized"` + + // Ready denotes that the KThreesControlPlane API Server is ready to + // receive requests. + // +optional + Ready bool `json:"ready"` + + // FailureReason indicates that there is a terminal problem reconciling the + // state, and will be set to a token value suitable for + // programmatic interpretation. + // +optional + FailureReason errors.KThreesControlPlaneStatusError `json:"failureReason,omitempty"` + + // ErrorMessage indicates that there is a terminal problem reconciling the + // state, and will be set to a descriptive error message. + // +optional + FailureMessage *string `json:"failureMessage,omitempty"` + + // ObservedGeneration is the latest generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions defines current service state of the KThreesControlPlane. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` + + // LastRemediation stores info about last remediation performed. + // +optional + LastRemediation *LastRemediationStatus `json:"lastRemediation,omitempty"` +} + +// LastRemediationStatus stores info about last remediation performed. +// NOTE: if for any reason information about last remediation are lost, RetryCount is going to restart from 0 and thus +// more remediations than expected might happen. +type LastRemediationStatus struct { + // Machine is the machine name of the latest machine being remediated. + Machine string `json:"machine"` + + // Timestamp is when last remediation happened. It is represented in RFC3339 form and is in UTC. + Timestamp metav1.Time `json:"timestamp"` + + // RetryCount used to keep track of remediation retry for the last remediated machine. + // A retry happens when a machine that was created as a replacement for an unhealthy machine also fails. + RetryCount int32 `json:"retryCount"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector +// +kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=".status.initialized",description="This denotes whether or not the control plane has completed the k3s server initialization" +// +kubebuilder:printcolumn:name="API Server Available",type=boolean,JSONPath=".status.ready",description="KThreesControlPlane API Server is ready to receive requests" +// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="Kubernetes version associated with this control plane" +// +kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=".status.replicas",description="Total number of non-terminated machines targeted by this control plane" +// +kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=".status.readyReplicas",description="Total number of fully running and ready control plane machines" +// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.updatedReplicas",description="Total number of non-terminated machines targeted by this control plane that have the desired template spec" +// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.unavailableReplicas",description="Total number of unavailable machines targeted by this control plane" + +// KThreesControlPlane is the Schema for the kthreescontrolplanes API. +type KThreesControlPlane struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KThreesControlPlaneSpec `json:"spec,omitempty"` + Status KThreesControlPlaneStatus `json:"status,omitempty"` +} + +func (in *KThreesControlPlane) GetConditions() clusterv1.Conditions { + return in.Status.Conditions +} + +func (in *KThreesControlPlane) SetConditions(conditions clusterv1.Conditions) { + in.Status.Conditions = conditions +} + +// +kubebuilder:object:root=true + +// KThreesControlPlaneList contains a list of KThreesControlPlane. +type KThreesControlPlaneList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KThreesControlPlane `json:"items"` +} + +func init() { + SchemeBuilder.Register(&KThreesControlPlane{}, &KThreesControlPlaneList{}) +} diff --git a/controlplane/api/v1beta2/kthreescontrolplane_webhook.go b/controlplane/api/v1beta2/kthreescontrolplane_webhook.go new file mode 100644 index 00000000..c05f6aba --- /dev/null +++ b/controlplane/api/v1beta2/kthreescontrolplane_webhook.go @@ -0,0 +1,56 @@ +/* + + +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 v1beta2 + +import ( + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// SetupWebhookWithManager will setup the webhooks for the KThreesControlPlane. +func (in *KThreesControlPlane) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(in). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-controlplane-cluster-x-k8s-io-v1beta2-kthreescontrolplane,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=controlplane.cluster.x-k8s.io,resources=kthreescontrolplane,versions=v1beta2,name=validation.kthreescontrolplane.controlplane.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta2 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-controlplane-cluster-x-k8s-io-v1beta2-kthreescontrolplane,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=controlplane.cluster.x-k8s.io,resources=kthreescontrolplane,versions=v1beta2,name=default.kthreescontrolplane.controlplane.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta2 + +var _ webhook.Defaulter = &KThreesControlPlane{} +var _ webhook.Validator = &KThreesControlPlane{} + +// ValidateCreate will do any extra validation when creating a KThreesControlPlane. +func (in *KThreesControlPlane) ValidateCreate() (admission.Warnings, error) { + return []string{}, nil +} + +// ValidateUpdate will do any extra validation when updating a KThreesControlPlane. +func (in *KThreesControlPlane) ValidateUpdate(runtime.Object) (admission.Warnings, error) { + return []string{}, nil +} + +// ValidateDelete allows you to add any extra validation when deleting. +func (in *KThreesControlPlane) ValidateDelete() (admission.Warnings, error) { + return []string{}, nil +} + +// Default will set default values for the KThreesControlPlane. +func (in *KThreesControlPlane) Default() { +} diff --git a/controlplane/api/v1beta2/kthreescontrolplanetemplate_types.go b/controlplane/api/v1beta2/kthreescontrolplanetemplate_types.go new file mode 100644 index 00000000..13a5ead8 --- /dev/null +++ b/controlplane/api/v1beta2/kthreescontrolplanetemplate_types.go @@ -0,0 +1,82 @@ +/* + + +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 v1beta2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + cabp3v1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" +) + +// KThreesControlPlaneTemplateSpec defines the desired state of KThreesControlPlaneTemplateSpec. +type KThreesControlPlaneTemplateSpec struct { + Template KThreesControlPlaneTemplateResource `json:"template"` +} + +type KThreesControlPlaneTemplateResource struct { + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"` + Spec KThreesControlPlaneTemplateResourceSpec `json:"spec"` +} + +type KThreesControlPlaneTemplateResourceSpec struct { + // KThreesConfigSpec is a KThreesConfigSpec + // to use for initializing and joining machines to the control plane. + // +optional + KThreesConfigSpec cabp3v1.KThreesConfigSpec `json:"kthreesConfigSpec,omitempty"` + + // UpgradeAfter is a field to indicate an upgrade should be performed + // after the specified time even if no changes have been made to the + // KThreesControlPlane + // +optional + UpgradeAfter *metav1.Time `json:"upgradeAfter,omitempty"` + + // MachineTemplate contains information about how machines should be shaped + // when creating or updating a control plane. + MachineTemplate KThreesControlPlaneMachineTemplate `json:"machineTemplate,omitempty"` + + // The RemediationStrategy that controls how control plane machine remediation happens. + // +optional + RemediationStrategy *RemediationStrategy `json:"remediationStrategy,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// KThreesControlPlaneTemplate is the Schema for the kthreescontrolplanetemplate API. +type KThreesControlPlaneTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KThreesControlPlaneTemplateSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// KThreesControlPlaneTemplateList contains a list of KThreesControlPlaneTemplate. +type KThreesControlPlaneTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KThreesControlPlaneTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&KThreesControlPlaneTemplate{}, &KThreesControlPlaneTemplateList{}) +} diff --git a/controlplane/api/v1beta2/zz_generated.deepcopy.go b/controlplane/api/v1beta2/zz_generated.deepcopy.go new file mode 100644 index 00000000..248a01f6 --- /dev/null +++ b/controlplane/api/v1beta2/zz_generated.deepcopy.go @@ -0,0 +1,330 @@ +//go:build !ignore_autogenerated + +/* + + +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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cluster-api/api/v1beta1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlane) DeepCopyInto(out *KThreesControlPlane) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlane. +func (in *KThreesControlPlane) DeepCopy() *KThreesControlPlane { + if in == nil { + return nil + } + out := new(KThreesControlPlane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesControlPlane) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneList) DeepCopyInto(out *KThreesControlPlaneList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KThreesControlPlane, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneList. +func (in *KThreesControlPlaneList) DeepCopy() *KThreesControlPlaneList { + if in == nil { + return nil + } + out := new(KThreesControlPlaneList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesControlPlaneList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneMachineTemplate) DeepCopyInto(out *KThreesControlPlaneMachineTemplate) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.InfrastructureRef = in.InfrastructureRef + if in.NodeDrainTimeout != nil { + in, out := &in.NodeDrainTimeout, &out.NodeDrainTimeout + *out = new(v1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneMachineTemplate. +func (in *KThreesControlPlaneMachineTemplate) DeepCopy() *KThreesControlPlaneMachineTemplate { + if in == nil { + return nil + } + out := new(KThreesControlPlaneMachineTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneSpec) DeepCopyInto(out *KThreesControlPlaneSpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + in.KThreesConfigSpec.DeepCopyInto(&out.KThreesConfigSpec) + if in.UpgradeAfter != nil { + in, out := &in.UpgradeAfter, &out.UpgradeAfter + *out = (*in).DeepCopy() + } + in.MachineTemplate.DeepCopyInto(&out.MachineTemplate) + if in.RemediationStrategy != nil { + in, out := &in.RemediationStrategy, &out.RemediationStrategy + *out = new(RemediationStrategy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneSpec. +func (in *KThreesControlPlaneSpec) DeepCopy() *KThreesControlPlaneSpec { + if in == nil { + return nil + } + out := new(KThreesControlPlaneSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneStatus) DeepCopyInto(out *KThreesControlPlaneStatus) { + *out = *in + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.LastRemediation != nil { + in, out := &in.LastRemediation, &out.LastRemediation + *out = new(LastRemediationStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneStatus. +func (in *KThreesControlPlaneStatus) DeepCopy() *KThreesControlPlaneStatus { + if in == nil { + return nil + } + out := new(KThreesControlPlaneStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneTemplate) DeepCopyInto(out *KThreesControlPlaneTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneTemplate. +func (in *KThreesControlPlaneTemplate) DeepCopy() *KThreesControlPlaneTemplate { + if in == nil { + return nil + } + out := new(KThreesControlPlaneTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesControlPlaneTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneTemplateList) DeepCopyInto(out *KThreesControlPlaneTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KThreesControlPlaneTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneTemplateList. +func (in *KThreesControlPlaneTemplateList) DeepCopy() *KThreesControlPlaneTemplateList { + if in == nil { + return nil + } + out := new(KThreesControlPlaneTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KThreesControlPlaneTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneTemplateResource) DeepCopyInto(out *KThreesControlPlaneTemplateResource) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneTemplateResource. +func (in *KThreesControlPlaneTemplateResource) DeepCopy() *KThreesControlPlaneTemplateResource { + if in == nil { + return nil + } + out := new(KThreesControlPlaneTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneTemplateResourceSpec) DeepCopyInto(out *KThreesControlPlaneTemplateResourceSpec) { + *out = *in + in.KThreesConfigSpec.DeepCopyInto(&out.KThreesConfigSpec) + if in.UpgradeAfter != nil { + in, out := &in.UpgradeAfter, &out.UpgradeAfter + *out = (*in).DeepCopy() + } + in.MachineTemplate.DeepCopyInto(&out.MachineTemplate) + if in.RemediationStrategy != nil { + in, out := &in.RemediationStrategy, &out.RemediationStrategy + *out = new(RemediationStrategy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneTemplateResourceSpec. +func (in *KThreesControlPlaneTemplateResourceSpec) DeepCopy() *KThreesControlPlaneTemplateResourceSpec { + if in == nil { + return nil + } + out := new(KThreesControlPlaneTemplateResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KThreesControlPlaneTemplateSpec) DeepCopyInto(out *KThreesControlPlaneTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KThreesControlPlaneTemplateSpec. +func (in *KThreesControlPlaneTemplateSpec) DeepCopy() *KThreesControlPlaneTemplateSpec { + if in == nil { + return nil + } + out := new(KThreesControlPlaneTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LastRemediationStatus) DeepCopyInto(out *LastRemediationStatus) { + *out = *in + in.Timestamp.DeepCopyInto(&out.Timestamp) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LastRemediationStatus. +func (in *LastRemediationStatus) DeepCopy() *LastRemediationStatus { + if in == nil { + return nil + } + out := new(LastRemediationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemediationStrategy) DeepCopyInto(out *RemediationStrategy) { + *out = *in + if in.MaxRetry != nil { + in, out := &in.MaxRetry, &out.MaxRetry + *out = new(int32) + **out = **in + } + out.RetryPeriod = in.RetryPeriod + if in.MinHealthyPeriod != nil { + in, out := &in.MinHealthyPeriod, &out.MinHealthyPeriod + *out = new(v1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemediationStrategy. +func (in *RemediationStrategy) DeepCopy() *RemediationStrategy { + if in == nil { + return nil + } + out := new(RemediationStrategy) + in.DeepCopyInto(out) + return out +} diff --git a/controlplane/config/certmanager/certificate.yaml b/controlplane/config/certmanager/certificate.yaml index 58db114f..f90715a5 100644 --- a/controlplane/config/certmanager/certificate.yaml +++ b/controlplane/config/certmanager/certificate.yaml @@ -1,8 +1,6 @@ # The following manifests contain a self-signed issuer CR and a certificate CR. # More document can be found at https://docs.cert-manager.io -# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for -# breaking changes -apiVersion: cert-manager.io/v1alpha2 +apiVersion: cert-manager.io/v1 kind: Issuer metadata: name: selfsigned-issuer @@ -10,7 +8,7 @@ metadata: spec: selfSigned: {} --- -apiVersion: cert-manager.io/v1alpha2 +apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml @@ -23,4 +21,4 @@ spec: issuerRef: kind: Issuer name: selfsigned-issuer - secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize + secretName: $(SERVICE_NAME)-cert diff --git a/controlplane/config/certmanager/kustomizeconfig.yaml b/controlplane/config/certmanager/kustomizeconfig.yaml index 90d7c313..d6109c9d 100644 --- a/controlplane/config/certmanager/kustomizeconfig.yaml +++ b/controlplane/config/certmanager/kustomizeconfig.yaml @@ -14,3 +14,6 @@ varReference: - kind: Certificate group: cert-manager.io path: spec/dnsNames +- kind: Certificate + group: cert-manager.io + path: spec/secretName diff --git a/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml b/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml index d5a716af..9682528b 100644 --- a/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml +++ b/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigs.yaml @@ -291,6 +291,274 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesConfig is the Schema for the kthreesconfigs API. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: KThreesConfigSpec defines the desired state of KThreesConfig. + properties: + agentConfig: + description: AgentConfig specifies configuration for the agent nodes + properties: + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting kubelet with + set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set of taints + items: + type: string + type: array + privateRegistry: + description: 'TODO: take in a object or secret and write to file. + this is not useful PrivateRegistry registry configuration file + (default: "/etc/rancher/k3s/registries.yaml")' + type: string + type: object + files: + description: Files specifies extra files to be passed to user_data + upon creation. + items: + description: File defines the input for generating write_files in + cloud-init. + properties: + content: + description: Content is the actual content of the file. + type: string + contentFrom: + description: ContentFrom is a referenced source of content to + populate the file. + properties: + secret: + description: Secret represents a secret that should populate + this file. + properties: + key: + description: Key is the key in the secret's data map + for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of the file contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the file, e.g. + "root:root". + type: string + path: + description: Path specifies the full path on disk where to store + the file. + type: string + permissions: + description: Permissions specifies the permissions to assign + to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands to run after + k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to run before + k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for the agent nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver uses + to advertise to members of the cluster (default: node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses to advertise + to members of the cluster (default: listen-port) (default: 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for pod IPs (default: + "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. Should + be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands to run + before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses the ''cloud-provider=external'' + kubelet argument. (default: false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag for kube-apiserver + process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized flag for + kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag for kube-scheduler + process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for services IPs + (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP as a Subject + Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + status: + description: KThreesConfigStatus defines the observed state of KThreesConfig. + properties: + bootstrapData: + format: byte + type: string + conditions: + description: Conditions defines current service state of the KThreesConfig. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. This should be when the underlying condition changed. + If that is not known, then using the time when the API field + changed is acceptable. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. This field may be empty. + type: string + reason: + description: The reason for the condition's last transition + in CamelCase. The specific API may choose whether or not this + field is considered a guaranteed API. This field may not be + empty. + type: string + severity: + description: Severity provides an explicit classification of + Reason code, so the users or machines can immediately understand + the current situation and act accordingly. The Severity field + MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + dataSecretName: + description: DataSecretName is the name of the secret that stores + the bootstrap data script. + type: string + failureMessage: + description: FailureMessage will be set on non-retryable errors + type: string + failureReason: + description: FailureReason will be set on non-retryable errors + type: string + observedGeneration: + description: ObservedGeneration is the latest generation observed + by the controller. + format: int64 + type: integer + ready: + description: Ready indicates the BootstrapData field is ready to be + consumed + type: boolean + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml b/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml index 48c72a0f..68b402d3 100644 --- a/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml +++ b/controlplane/config/crd/bases/bootstrap.cluster.x-k8s.io_kthreesconfigtemplates.yaml @@ -240,4 +240,219 @@ spec: type: object type: object served: true + storage: false + - name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesConfigTemplate is the Schema for the kthreesconfigtemplates + API. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: KThreesConfigTemplateSpec defines the desired state of KThreesConfigTemplate. + properties: + template: + description: KThreesConfigTemplateResource defines the Template structure. + properties: + spec: + description: KThreesConfigSpec defines the desired state of KThreesConfig. + properties: + agentConfig: + description: AgentConfig specifies configuration for the agent + nodes + properties: + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy + process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting kubelet + with set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set of + taints + items: + type: string + type: array + privateRegistry: + description: 'TODO: take in a object or secret and write + to file. this is not useful PrivateRegistry registry + configuration file (default: "/etc/rancher/k3s/registries.yaml")' + type: string + type: object + files: + description: Files specifies extra files to be passed to user_data + upon creation. + items: + description: File defines the input for generating write_files + in cloud-init. + properties: + content: + description: Content is the actual content of the file. + type: string + contentFrom: + description: ContentFrom is a referenced source of content + to populate the file. + properties: + secret: + description: Secret represents a secret that should + populate this file. + properties: + key: + description: Key is the key in the secret's + data map for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of the + file contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the file, + e.g. "root:root". + type: string + path: + description: Path specifies the full path on disk where + to store the file. + type: string + permissions: + description: Permissions specifies the permissions to + assign to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands to run + after k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to run + before k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for the + agent nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver + uses to advertise to members of the cluster (default: + node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses to + advertise to members of the cluster (default: listen-port) + (default: 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for pod + IPs (default: "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. + Should be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands + to run before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses + the ''cloud-provider=external'' kubelet argument. (default: + false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: + 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag for + kube-apiserver process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized + flag for kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag for + kube-scheduler process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for services + IPs (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP as a + Subject Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + type: object + required: + - template + type: object + type: object + served: true storage: true diff --git a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml index e13f2fd7..77e2509a 100644 --- a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml +++ b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml @@ -551,6 +551,548 @@ spec: type: object type: object served: true + storage: false + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas + status: {} + - additionalPrinterColumns: + - description: This denotes whether or not the control plane has completed the + k3s server initialization + jsonPath: .status.initialized + name: Initialized + type: boolean + - description: KThreesControlPlane API Server is ready to receive requests + jsonPath: .status.ready + name: API Server Available + type: boolean + - description: Kubernetes version associated with this control plane + jsonPath: .spec.version + name: Version + type: string + - description: Total number of non-terminated machines targeted by this control + plane + jsonPath: .status.replicas + name: Replicas + type: integer + - description: Total number of fully running and ready control plane machines + jsonPath: .status.readyReplicas + name: Ready + type: integer + - description: Total number of non-terminated machines targeted by this control + plane that have the desired template spec + jsonPath: .status.updatedReplicas + name: Updated + type: integer + - description: Total number of unavailable machines targeted by this control plane + jsonPath: .status.unavailableReplicas + name: Unavailable + type: integer + name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesControlPlane is the Schema for the kthreescontrolplanes + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: KThreesControlPlaneSpec defines the desired state of KThreesControlPlane. + properties: + kthreesConfigSpec: + description: |- + KThreesConfigSpec is a KThreesConfigSpec + to use for initializing and joining machines to the control plane. + properties: + agentConfig: + description: AgentConfig specifies configuration for the agent + nodes + properties: + airGapped: + description: |- + AirGapped is a boolean value to define if the bootstrapping should be air-gapped, + basically supposing that online container registries and k3s install scripts are not reachable. + User should prepare docker image, k3s binary, and put the install script in `/opt/install.sh` + on all nodes in the air-gap environment. + type: boolean + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy + process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting kubelet + with set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set of taints + items: + type: string + type: array + privateRegistry: + description: |- + TODO: take in a object or secret and write to file. this is not useful + PrivateRegistry registry configuration file (default: "/etc/rancher/k3s/registries.yaml") + type: string + type: object + files: + description: Files specifies extra files to be passed to user_data + upon creation. + items: + description: File defines the input for generating write_files + in cloud-init. + properties: + content: + description: Content is the actual content of the file. + type: string + contentFrom: + description: ContentFrom is a referenced source of content + to populate the file. + properties: + secret: + description: Secret represents a secret that should + populate this file. + properties: + key: + description: Key is the key in the secret's data + map for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of the file + contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the file, + e.g. "root:root". + type: string + path: + description: Path specifies the full path on disk where + to store the file. + type: string + permissions: + description: Permissions specifies the permissions to assign + to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands to run after + k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to run before + k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for the agent + nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver uses + to advertise to members of the cluster (default: node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses to advertise + to members of the cluster (default: listen-port) (default: + 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for pod IPs + (default: "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. + Should be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands to + run before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses the + ''cloud-provider=external'' kubelet argument. (default: + false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: + 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag for kube-apiserver + process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized flag + for kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag for kube-scheduler + process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for services + IPs (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP as a Subject + Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + machineTemplate: + description: |- + MachineTemplate contains information about how machines should be shaped + when creating or updating a control plane. + properties: + infrastructureRef: + description: |- + InfrastructureRef is a required reference to a custom resource + offered by an infrastructure provider. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + metadata: + description: |- + Standard object's metadata. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations is an unstructured key value map stored with a resource that may be + set by external tools to store and retrieve arbitrary metadata. They are not + queryable and should be preserved when modifying objects. + More info: http://kubernetes.io/docs/user-guide/annotations + type: object + labels: + additionalProperties: + type: string + description: |- + Map of string keys and values that can be used to organize and categorize + (scope and select) objects. May match selectors of replication controllers + and services. + More info: http://kubernetes.io/docs/user-guide/labels + type: object + type: object + nodeDrainTimeout: + description: |- + NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node + The default value is 0, meaning that the node can be drained without any time limitations. + NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` + type: string + required: + - infrastructureRef + type: object + remediationStrategy: + description: The RemediationStrategy that controls how control plane + machine remediation happens. + properties: + maxRetry: + description: "MaxRetry is the Max number of retries while attempting + to remediate an unhealthy machine.\nA retry happens when a machine + that was created as a replacement for an unhealthy machine also + fails.\nFor example, given a control plane with three machines + M1, M2, M3:\n\n\n\tM1 become unhealthy; remediation happens, + and M1-1 is created as a replacement.\n\tIf M1-1 (replacement + of M1) has problems while bootstrapping it will become unhealthy, + and then be\n\tremediated; such operation is considered a retry, + remediation-retry #1.\n\tIf M1-2 (replacement of M1-1) becomes + unhealthy, remediation-retry #2 will happen, etc.\n\n\nA retry + could happen only after RetryPeriod from the previous retry.\nIf + a machine is marked as unhealthy after MinHealthyPeriod from + the previous remediation expired,\nthis is not considered a + retry anymore because the new issue is assumed unrelated from + the previous one.\n\n\nIf not set, the remedation will be retried + infinitely." + format: int32 + type: integer + minHealthyPeriod: + description: "MinHealthyPeriod defines the duration after which + KCP will consider any failure to a machine unrelated\nfrom the + previous one. In this case the remediation is not considered + a retry anymore, and thus the retry\ncounter restarts from 0. + For example, assuming MinHealthyPeriod is set to 1h (default)\n\n\n\tM1 + become unhealthy; remediation happens, and M1-1 is created as + a replacement.\n\tIf M1-1 (replacement of M1) has problems within + the 1hr after the creation, also\n\tthis machine will be remediated + and this operation is considered a retry - a problem related\n\tto + the original issue happened to M1 -.\n\n\n\tIf instead the problem + on M1-1 is happening after MinHealthyPeriod expired, e.g. four + days after\n\tm1-1 has been created as a remediation of M1, + the problem on M1-1 is considered unrelated to\n\tthe original + issue happened to M1.\n\n\nIf not set, this value is defaulted + to 1h." + type: string + retryPeriod: + description: |- + RetryPeriod is the duration that KCP should wait before remediating a machine being created as a replacement + for an unhealthy machine (a retry). + + + If not set, a retry will happen immediately. + type: string + type: object + replicas: + description: |- + Number of desired machines. Defaults to 1. When stacked etcd is used only + odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members). + This is a pointer to distinguish between explicit zero and not specified. + format: int32 + type: integer + upgradeAfter: + description: |- + UpgradeAfter is a field to indicate an upgrade should be performed + after the specified time even if no changes have been made to the + KThreesControlPlane + format: date-time + type: string + version: + description: Version defines the desired Kubernetes version. + type: string + required: + - version + type: object + status: + description: KThreesControlPlaneStatus defines the observed state of KThreesControlPlane. + properties: + conditions: + description: Conditions defines current service state of the KThreesControlPlane. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + ErrorMessage indicates that there is a terminal problem reconciling the + state, and will be set to a descriptive error message. + type: string + failureReason: + description: |- + FailureReason indicates that there is a terminal problem reconciling the + state, and will be set to a token value suitable for + programmatic interpretation. + type: string + initialized: + description: Initialized denotes whether or not the k3s server is + initialized. + type: boolean + lastRemediation: + description: LastRemediation stores info about last remediation performed. + properties: + machine: + description: Machine is the machine name of the latest machine + being remediated. + type: string + retryCount: + description: |- + RetryCount used to keep track of remediation retry for the last remediated machine. + A retry happens when a machine that was created as a replacement for an unhealthy machine also fails. + format: int32 + type: integer + timestamp: + description: Timestamp is when last remediation happened. It is + represented in RFC3339 form and is in UTC. + format: date-time + type: string + required: + - machine + - retryCount + - timestamp + type: object + observedGeneration: + description: ObservedGeneration is the latest generation observed + by the controller. + format: int64 + type: integer + ready: + description: |- + Ready denotes that the KThreesControlPlane API Server is ready to + receive requests. + type: boolean + readyReplicas: + description: Total number of fully running and ready control plane + machines. + format: int32 + type: integer + replicas: + description: |- + Total number of non-terminated machines targeted by this control plane + (their labels match the selector). + format: int32 + type: integer + selector: + description: |- + Selector is the label selector in string format to avoid introspection + by clients, and is used to provide the CRD-based integration for the + scale subresource and additional integrations for things like kubectl + describe.. The string will be in the same format as the query-param syntax. + More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors + type: string + unavailableReplicas: + description: |- + Total number of unavailable machines targeted by this control plane. + This is the total number of machines that are still required for + the deployment to have 100% available capacity. They may either + be machines that are running but not yet ready or machines + that still have not been created. + format: int32 + type: integer + updatedReplicas: + description: |- + Total number of non-terminated machines targeted by this control plane + that have the desired template spec. + format: int32 + type: integer + type: object + type: object + served: true storage: true subresources: scale: diff --git a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml new file mode 100644 index 00000000..8350a0bb --- /dev/null +++ b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml @@ -0,0 +1,404 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: kthreescontrolplanetemplates.controlplane.cluster.x-k8s.io +spec: + group: controlplane.cluster.x-k8s.io + names: + kind: KThreesControlPlaneTemplate + listKind: KThreesControlPlaneTemplateList + plural: kthreescontrolplanetemplates + singular: kthreescontrolplanetemplate + scope: Namespaced + versions: + - name: v1beta2 + schema: + openAPIV3Schema: + description: KThreesControlPlaneTemplate is the Schema for the kthreescontrolplanetemplate + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: KThreesControlPlaneTemplateSpec defines the desired state + of KThreesControlPlaneTemplateSpec. + properties: + template: + properties: + metadata: + description: |- + Standard object's metadata. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + type: object + spec: + properties: + kthreesConfigSpec: + description: |- + KThreesConfigSpec is a KThreesConfigSpec + to use for initializing and joining machines to the control plane. + properties: + agentConfig: + description: AgentConfig specifies configuration for the + agent nodes + properties: + airGapped: + description: |- + AirGapped is a boolean value to define if the bootstrapping should be air-gapped, + basically supposing that online container registries and k3s install scripts are not reachable. + User should prepare docker image, k3s binary, and put the install script in `/opt/install.sh` + on all nodes in the air-gap environment. + type: boolean + kubeProxyArgs: + description: KubeProxyArgs Customized flag for kube-proxy + process + items: + type: string + type: array + kubeletArgs: + description: KubeletArgs Customized flag for kubelet + process + items: + type: string + type: array + nodeLabels: + description: NodeLabels Registering and starting + kubelet with set of labels + items: + type: string + type: array + nodeName: + description: NodeName Name of the Node + type: string + nodeTaints: + description: NodeTaints Registering kubelet with set + of taints + items: + type: string + type: array + privateRegistry: + description: |- + TODO: take in a object or secret and write to file. this is not useful + PrivateRegistry registry configuration file (default: "/etc/rancher/k3s/registries.yaml") + type: string + type: object + files: + description: Files specifies extra files to be passed + to user_data upon creation. + items: + description: File defines the input for generating write_files + in cloud-init. + properties: + content: + description: Content is the actual content of the + file. + type: string + contentFrom: + description: ContentFrom is a referenced source + of content to populate the file. + properties: + secret: + description: Secret represents a secret that + should populate this file. + properties: + key: + description: Key is the key in the secret's + data map for this value. + type: string + name: + description: Name of the secret in the KThreesBootstrapConfig's + namespace to use. + type: string + required: + - key + - name + type: object + required: + - secret + type: object + encoding: + description: Encoding specifies the encoding of + the file contents. + enum: + - base64 + - gzip + - gzip+base64 + type: string + owner: + description: Owner specifies the ownership of the + file, e.g. "root:root". + type: string + path: + description: Path specifies the full path on disk + where to store the file. + type: string + permissions: + description: Permissions specifies the permissions + to assign to the file, e.g. "0640". + type: string + required: + - path + type: object + type: array + postK3sCommands: + description: PostK3sCommands specifies extra commands + to run after k3s setup runs + items: + type: string + type: array + preK3sCommands: + description: PreK3sCommands specifies extra commands to + run before k3s setup runs + items: + type: string + type: array + serverConfig: + description: ServerConfig specifies configuration for + the agent nodes + properties: + advertiseAddress: + description: 'AdvertiseAddress IP address that apiserver + uses to advertise to members of the cluster (default: + node-external-ip/node-ip)' + type: string + advertisePort: + description: 'AdvertisePort Port that apiserver uses + to advertise to members of the cluster (default: + listen-port) (default: 0)' + type: string + bindAddress: + description: 'BindAddress k3s bind address (default: + 0.0.0.0)' + type: string + clusterCidr: + description: 'ClusterCidr Network CIDR to use for + pod IPs (default: "10.42.0.0/16")' + type: string + clusterDNS: + description: 'ClusterDNS Cluster IP for coredns service. + Should be in your service-cidr range (default: 10.43.0.10)' + type: string + clusterDomain: + description: 'ClusterDomain Cluster Domain (default: + "cluster.local")' + type: string + disableComponents: + description: DisableComponents specifies extra commands + to run before k3s setup runs + items: + type: string + type: array + disableExternalCloudProvider: + description: 'DisableExternalCloudProvider suppresses + the ''cloud-provider=external'' kubelet argument. + (default: false)' + type: boolean + httpsListenPort: + description: 'HTTPSListenPort HTTPS listen port (default: + 6443)' + type: string + kubeAPIServerArg: + description: KubeAPIServerArgs is a customized flag + for kube-apiserver process + items: + type: string + type: array + kubeControllerManagerArgs: + description: KubeControllerManagerArgs is a customized + flag for kube-controller-manager process + items: + type: string + type: array + kubeSchedulerArgs: + description: KubeSchedulerArgs is a customized flag + for kube-scheduler process + items: + type: string + type: array + serviceCidr: + description: 'ServiceCidr Network CIDR to use for + services IPs (default: "10.43.0.0/16")' + type: string + tlsSan: + description: TLSSan Add additional hostname or IP + as a Subject Alternative Name in the TLS cert + items: + type: string + type: array + type: object + version: + description: Version specifies the k3s version + type: string + type: object + machineTemplate: + description: |- + MachineTemplate contains information about how machines should be shaped + when creating or updating a control plane. + properties: + infrastructureRef: + description: |- + InfrastructureRef is a required reference to a custom resource + offered by an infrastructure provider. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + metadata: + description: |- + Standard object's metadata. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations is an unstructured key value map stored with a resource that may be + set by external tools to store and retrieve arbitrary metadata. They are not + queryable and should be preserved when modifying objects. + More info: http://kubernetes.io/docs/user-guide/annotations + type: object + labels: + additionalProperties: + type: string + description: |- + Map of string keys and values that can be used to organize and categorize + (scope and select) objects. May match selectors of replication controllers + and services. + More info: http://kubernetes.io/docs/user-guide/labels + type: object + type: object + nodeDrainTimeout: + description: |- + NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node + The default value is 0, meaning that the node can be drained without any time limitations. + NOTE: NodeDrainTimeout is different from `kubectl drain --timeout` + type: string + required: + - infrastructureRef + type: object + remediationStrategy: + description: The RemediationStrategy that controls how control + plane machine remediation happens. + properties: + maxRetry: + description: "MaxRetry is the Max number of retries while + attempting to remediate an unhealthy machine.\nA retry + happens when a machine that was created as a replacement + for an unhealthy machine also fails.\nFor example, given + a control plane with three machines M1, M2, M3:\n\n\n\tM1 + become unhealthy; remediation happens, and M1-1 is created + as a replacement.\n\tIf M1-1 (replacement of M1) has + problems while bootstrapping it will become unhealthy, + and then be\n\tremediated; such operation is considered + a retry, remediation-retry #1.\n\tIf M1-2 (replacement + of M1-1) becomes unhealthy, remediation-retry #2 will + happen, etc.\n\n\nA retry could happen only after RetryPeriod + from the previous retry.\nIf a machine is marked as + unhealthy after MinHealthyPeriod from the previous remediation + expired,\nthis is not considered a retry anymore because + the new issue is assumed unrelated from the previous + one.\n\n\nIf not set, the remedation will be retried + infinitely." + format: int32 + type: integer + minHealthyPeriod: + description: "MinHealthyPeriod defines the duration after + which KCP will consider any failure to a machine unrelated\nfrom + the previous one. In this case the remediation is not + considered a retry anymore, and thus the retry\ncounter + restarts from 0. For example, assuming MinHealthyPeriod + is set to 1h (default)\n\n\n\tM1 become unhealthy; remediation + happens, and M1-1 is created as a replacement.\n\tIf + M1-1 (replacement of M1) has problems within the 1hr + after the creation, also\n\tthis machine will be remediated + and this operation is considered a retry - a problem + related\n\tto the original issue happened to M1 -.\n\n\n\tIf + instead the problem on M1-1 is happening after MinHealthyPeriod + expired, e.g. four days after\n\tm1-1 has been created + as a remediation of M1, the problem on M1-1 is considered + unrelated to\n\tthe original issue happened to M1.\n\n\nIf + not set, this value is defaulted to 1h." + type: string + retryPeriod: + description: |- + RetryPeriod is the duration that KCP should wait before remediating a machine being created as a replacement + for an unhealthy machine (a retry). + + + If not set, a retry will happen immediately. + type: string + type: object + upgradeAfter: + description: |- + UpgradeAfter is a field to indicate an upgrade should be performed + after the specified time even if no changes have been made to the + KThreesControlPlane + format: date-time + type: string + type: object + required: + - spec + type: object + required: + - template + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/controlplane/config/crd/kustomization.yaml b/controlplane/config/crd/kustomization.yaml index 85f7c5b3..382c6f74 100644 --- a/controlplane/config/crd/kustomization.yaml +++ b/controlplane/config/crd/kustomization.yaml @@ -1,5 +1,5 @@ commonLabels: - cluster.x-k8s.io/v1beta1: v1beta1 + cluster.x-k8s.io/v1beta1: v1beta1_v1beta2 clusterctl.cluster.x-k8s.io: "" # This kustomization.yaml is not intended to be run by itself, @@ -7,17 +7,18 @@ commonLabels: # It should be run by config/default resources: - bases/controlplane.cluster.x-k8s.io_kthreescontrolplanes.yaml + - bases/controlplane.cluster.x-k8s.io_kthreescontrolplanetemplates.yaml # +kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -#- patches/webhook_in_kthreescontrolplanes.yaml +- patches/webhook_in_kthreescontrolplanes.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- patches/cainjection_in_kthreescontrolplanes.yaml +- patches/cainjection_in_kthreescontrolplanes.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/controlplane/config/crd/kustomizeconfig.yaml b/controlplane/config/crd/kustomizeconfig.yaml index e9cda712..8e2d8d6b 100644 --- a/controlplane/config/crd/kustomizeconfig.yaml +++ b/controlplane/config/crd/kustomizeconfig.yaml @@ -1,17 +1,17 @@ # This file is for teaching kustomize how to substitute name and namespace reference in CRD nameReference: - - kind: Service - version: v1 - fieldSpecs: - - kind: CustomResourceDefinition - group: apiextensions.k8s.io - path: spec/conversion/webhookClientConfig/service/name - -namespace: +- kind: Service + version: v1 + fieldSpecs: - kind: CustomResourceDefinition group: apiextensions.k8s.io - path: spec/conversion/webhookClientConfig/service/namespace - create: false + path: spec/conversion/webhook/clientConfig/service/name + +namespace: +- kind: CustomResourceDefinition + group: apiextensions.k8s.io + path: spec/conversion/webhook/clientConfig/service/namespace + create: false varReference: - - path: metadata/annotations +- path: metadata/annotations diff --git a/controlplane/config/crd/patches/cainjection_in_kthreescontrolplanes.yaml b/controlplane/config/crd/patches/cainjection_in_kthreescontrolplanes.yaml index 1815cd4e..4e515ea2 100644 --- a/controlplane/config/crd/patches/cainjection_in_kthreescontrolplanes.yaml +++ b/controlplane/config/crd/patches/cainjection_in_kthreescontrolplanes.yaml @@ -1,6 +1,5 @@ # The following patch adds a directive for certmanager to inject CA into the CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: diff --git a/controlplane/config/crd/patches/webhook_in_kthreescontrolplanes.yaml b/controlplane/config/crd/patches/webhook_in_kthreescontrolplanes.yaml index caacca2e..26039e02 100644 --- a/controlplane/config/crd/patches/webhook_in_kthreescontrolplanes.yaml +++ b/controlplane/config/crd/patches/webhook_in_kthreescontrolplanes.yaml @@ -1,17 +1,17 @@ -# The following patch enables conversion webhook for CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1beta1 +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: kthreescontrolplanes.controlplane.cluster.x-k8s.io spec: conversion: strategy: Webhook - webhookClientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== - service: - namespace: system - name: webhook-service - path: /convert + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1beta1 + - v1beta2 diff --git a/controlplane/config/default/kustomization.yaml b/controlplane/config/default/kustomization.yaml index 3e4692d1..7153d5fb 100644 --- a/controlplane/config/default/kustomization.yaml +++ b/controlplane/config/default/kustomization.yaml @@ -18,9 +18,9 @@ bases: - ../manager # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -#- ../webhook +- ../webhook # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. -#- ../certmanager +- ../certmanager # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. #- ../prometheus @@ -32,39 +32,41 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -#- manager_webhook_patch.yaml +- manager_webhook_patch.yaml # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. # 'CERTMANAGER' needs to be enabled to use ca injection -#- webhookcainjection_patch.yaml +- webhookcainjection_patch.yaml # the following config is for teaching kustomize how to do var substitution -vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1alpha2 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldref: -# fieldpath: metadata.namespace -#- name: CERTIFICATE_NAME -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1alpha2 -# name: serving-cert # this name should match the one in certificate.yaml -#- name: SERVICE_NAMESPACE # namespace of the service -# objref: -# kind: Service -# version: v1 -# name: webhook-service -# fieldref: -# fieldpath: metadata.namespace -#- name: SERVICE_NAME -# objref: -# kind: Service -# version: v1 -# name: webhook-service +configurations: + - kustomizeconfig.yaml +vars: + - name: CERTIFICATE_NAMESPACE # namespace of the certificate CR + objref: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + fieldref: + fieldpath: metadata.namespace + - name: CERTIFICATE_NAME + objref: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + - name: SERVICE_NAMESPACE # namespace of the service + objref: + kind: Service + version: v1 + name: webhook-service + fieldref: + fieldpath: metadata.namespace + - name: SERVICE_NAME + objref: + kind: Service + version: v1 + name: webhook-service diff --git a/controlplane/config/default/kustomizeconfig.yaml b/controlplane/config/default/kustomizeconfig.yaml new file mode 100644 index 00000000..524d39cc --- /dev/null +++ b/controlplane/config/default/kustomizeconfig.yaml @@ -0,0 +1,4 @@ +# This configuration is for teaching kustomize how to update name ref and var substitution +varReference: + - kind: Deployment + path: spec/template/spec/volumes/secret/secretName diff --git a/controlplane/config/default/manager_webhook_patch.yaml b/controlplane/config/default/manager_webhook_patch.yaml index 738de350..b387eb0e 100644 --- a/controlplane/config/default/manager_webhook_patch.yaml +++ b/controlplane/config/default/manager_webhook_patch.yaml @@ -20,4 +20,4 @@ spec: - name: cert secret: defaultMode: 420 - secretName: webhook-server-cert + secretName: $(SERVICE_NAME)-cert diff --git a/controlplane/config/default/webhookcainjection_patch.yaml b/controlplane/config/default/webhookcainjection_patch.yaml index 7e79bf99..02ab515d 100644 --- a/controlplane/config/default/webhookcainjection_patch.yaml +++ b/controlplane/config/default/webhookcainjection_patch.yaml @@ -1,13 +1,13 @@ # This patch add annotation to admission webhook config and # the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. -apiVersion: admissionregistration.k8s.io/v1beta1 +apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: name: mutating-webhook-configuration annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) --- -apiVersion: admissionregistration.k8s.io/v1beta1 +apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: name: validating-webhook-configuration diff --git a/controlplane/config/rbac/role.yaml b/controlplane/config/rbac/role.yaml index e255dfa8..ec2334e9 100644 --- a/controlplane/config/rbac/role.yaml +++ b/controlplane/config/rbac/role.yaml @@ -4,20 +4,6 @@ kind: ClusterRole metadata: name: manager-role rules: -- apiGroups: - - "" - resources: - - configmaps - - events - - secrets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - apiextensions.k8s.io resources: @@ -26,30 +12,6 @@ rules: - get - list - watch -- apiGroups: - - bootstrap.cluster.x-k8s.io - resources: - - kthreesconfigs - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - bootstrap.cluster.x-k8s.io - resources: - - kthreesconfigs/status - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - bootstrap.cluster.x-k8s.io - controlplane.cluster.x-k8s.io @@ -73,17 +35,6 @@ rules: - get - list - watch -- apiGroups: - - cluster.x-k8s.io - resources: - - clusters - - clusters/status - - machines - - machines/status - verbs: - - get - - list - - watch - apiGroups: - cluster.x-k8s.io resources: @@ -118,12 +69,3 @@ rules: - patch - update - watch -- apiGroups: - - exp.cluster.x-k8s.io - resources: - - machinepools - - machinepools/status - verbs: - - get - - list - - watch diff --git a/controlplane/config/webhook/manifests.yaml b/controlplane/config/webhook/manifests.yaml new file mode 100644 index 00000000..1a14a82d --- /dev/null +++ b/controlplane/config/webhook/manifests.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + name: mutating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + - v1beta2 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-controlplane-cluster-x-k8s-io-v1beta2-kthreescontrolplane + failurePolicy: Fail + matchPolicy: Equivalent + name: default.kthreescontrolplane.controlplane.cluster.x-k8s.io + rules: + - apiGroups: + - controlplane.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - kthreescontrolplane + sideEffects: None +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: validating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + - v1beta2 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-controlplane-cluster-x-k8s-io-v1beta2-kthreescontrolplane + failurePolicy: Fail + matchPolicy: Equivalent + name: validation.kthreescontrolplane.controlplane.cluster.x-k8s.io + rules: + - apiGroups: + - controlplane.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - kthreescontrolplane + sideEffects: None diff --git a/controlplane/controllers/kthreescontrolplane_controller.go b/controlplane/controllers/kthreescontrolplane_controller.go index 2bf1a205..5df9faab 100644 --- a/controlplane/controllers/kthreescontrolplane_controller.go +++ b/controlplane/controllers/kthreescontrolplane_controller.go @@ -45,7 +45,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" k3s "github.com/k3s-io/cluster-api-k3s/pkg/k3s" "github.com/k3s-io/cluster-api-k3s/pkg/kubeconfig" "github.com/k3s-io/cluster-api-k3s/pkg/machinefilters" @@ -412,7 +412,7 @@ func (r *KThreesControlPlaneReconciler) reconcile(ctx context.Context, cluster * logger.Info("Reconcile KThreesControlPlane") // Make sure to reconcile the external infrastructure reference. - if err := r.reconcileExternalReference(ctx, cluster, kcp.Spec.InfrastructureTemplate); err != nil { + if err := r.reconcileExternalReference(ctx, cluster, kcp.Spec.MachineTemplate.InfrastructureRef); err != nil { return reconcile.Result{}, err } diff --git a/controlplane/controllers/remediation.go b/controlplane/controllers/remediation.go index 57bd9a80..89f90a71 100644 --- a/controlplane/controllers/remediation.go +++ b/controlplane/controllers/remediation.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/cluster-api/util/patch" ctrl "sigs.k8s.io/controller-runtime" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" k3s "github.com/k3s-io/cluster-api-k3s/pkg/k3s" ) diff --git a/controlplane/controllers/scale.go b/controlplane/controllers/scale.go index 4e64fdae..5f832d5c 100644 --- a/controlplane/controllers/scale.go +++ b/controlplane/controllers/scale.go @@ -36,8 +36,8 @@ import ( "sigs.k8s.io/cluster-api/util/patch" ctrl "sigs.k8s.io/controller-runtime" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" k3s "github.com/k3s-io/cluster-api-k3s/pkg/k3s" "github.com/k3s-io/cluster-api-k3s/pkg/machinefilters" ) @@ -265,7 +265,7 @@ func (r *KThreesControlPlaneReconciler) cloneConfigsAndGenerateMachine(ctx conte // Clone the infrastructure template infraRef, err := external.CreateFromTemplate(ctx, &external.CreateFromTemplateInput{ Client: r.Client, - TemplateRef: &kcp.Spec.InfrastructureTemplate, + TemplateRef: &kcp.Spec.MachineTemplate.InfrastructureRef, Namespace: kcp.Namespace, OwnerRef: infraCloneOwner, ClusterName: cluster.Name, @@ -373,7 +373,7 @@ func (r *KThreesControlPlaneReconciler) generateMachine(ctx context.Context, kcp ConfigRef: bootstrapRef, }, FailureDomain: failureDomain, - NodeDrainTimeout: kcp.Spec.NodeDrainTimeout, + NodeDrainTimeout: kcp.Spec.MachineTemplate.NodeDrainTimeout, }, } diff --git a/controlplane/controllers/suite_test.go b/controlplane/controllers/suite_test.go index 3a7afb0a..467d0d46 100644 --- a/controlplane/controllers/suite_test.go +++ b/controlplane/controllers/suite_test.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" controlplanev1beta1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -57,8 +58,8 @@ var _ = BeforeSuite(func(done Done) { Expect(err).ToNot(HaveOccurred()) Expect(cfg).ToNot(BeNil()) - err = controlplanev1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) + Expect(controlplanev1beta1.AddToScheme(scheme.Scheme)).Should(Succeed()) + Expect(controlplanev1.AddToScheme(scheme.Scheme)).Should(Succeed()) // +kubebuilder:scaffold:scheme diff --git a/controlplane/main.go b/controlplane/main.go index 7ba1ae6c..e94e345c 100644 --- a/controlplane/main.go +++ b/controlplane/main.go @@ -33,7 +33,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" bootstrapv1beta1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" controlplanev1beta1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" "github.com/k3s-io/cluster-api-k3s/controlplane/controllers" "github.com/k3s-io/cluster-api-k3s/pkg/etcd" ) @@ -48,8 +50,10 @@ func init() { _ = clusterv1beta1.AddToScheme(scheme) _ = expv1beta1.AddToScheme(scheme) _ = bootstrapv1beta1.AddToScheme(scheme) + _ = bootstrapv1.AddToScheme(scheme) _ = controlplanev1beta1.AddToScheme(scheme) + _ = controlplanev1.AddToScheme(scheme) // +kubebuilder:scaffold:scheme } @@ -122,6 +126,13 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "Machine") os.Exit(1) } + + if os.Getenv("ENABLE_WEBHOOKS") != "false" { + if err = (&controlplanev1.KThreesControlPlane{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "KThreesControlPlane") + os.Exit(1) + } + } // +kubebuilder:scaffold:builder setupLog.Info("starting manager") diff --git a/pkg/cloudinit/cloudinit.go b/pkg/cloudinit/cloudinit.go index ef3ea5e9..079c165e 100644 --- a/pkg/cloudinit/cloudinit.go +++ b/pkg/cloudinit/cloudinit.go @@ -22,7 +22,7 @@ import ( "strings" "text/template" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" ) var ( diff --git a/pkg/cloudinit/controlplane_init_test.go b/pkg/cloudinit/controlplane_init_test.go index 4f12060b..328c84e5 100644 --- a/pkg/cloudinit/controlplane_init_test.go +++ b/pkg/cloudinit/controlplane_init_test.go @@ -21,7 +21,7 @@ import ( . "github.com/onsi/gomega" - infrav1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + infrav1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" "github.com/k3s-io/cluster-api-k3s/pkg/secret" ) diff --git a/pkg/k3s/config.go b/pkg/k3s/config.go index 63b9b04b..33be68bb 100644 --- a/pkg/k3s/config.go +++ b/pkg/k3s/config.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" ) const DefaultK3sConfigLocation = "/etc/rancher/k3s/config.yaml" diff --git a/pkg/k3s/control_plane.go b/pkg/k3s/control_plane.go index 6b78646e..3a98eefd 100644 --- a/pkg/k3s/control_plane.go +++ b/pkg/k3s/control_plane.go @@ -34,8 +34,8 @@ import ( "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" "github.com/k3s-io/cluster-api-k3s/pkg/machinefilters" ) @@ -131,7 +131,7 @@ func (c *ControlPlane) Version() *string { // InfrastructureTemplate returns the KThreesControlPlane's infrastructure template. func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference { - return &c.KCP.Spec.InfrastructureTemplate + return &c.KCP.Spec.MachineTemplate.InfrastructureRef } // AsOwnerReference returns an owner reference to the KThreesControlPlane. diff --git a/pkg/k3s/workload_cluster.go b/pkg/k3s/workload_cluster.go index ed6d917c..a8d95258 100644 --- a/pkg/k3s/workload_cluster.go +++ b/pkg/k3s/workload_cluster.go @@ -25,7 +25,7 @@ import ( "sigs.k8s.io/cluster-api/util/conditions" ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" "github.com/k3s-io/cluster-api-k3s/pkg/etcd" etcdutil "github.com/k3s-io/cluster-api-k3s/pkg/etcd/util" ) diff --git a/pkg/k3s/workload_cluster_coredns.go b/pkg/k3s/workload_cluster_coredns.go index 1d23257b..1329d888 100644 --- a/pkg/k3s/workload_cluster_coredns.go +++ b/pkg/k3s/workload_cluster_coredns.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/cluster-api/util/version" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" ) const ( diff --git a/pkg/machinefilters/machine_filters.go b/pkg/machinefilters/machine_filters.go index 8264f32a..0d1000dc 100644 --- a/pkg/machinefilters/machine_filters.go +++ b/pkg/machinefilters/machine_filters.go @@ -26,8 +26,8 @@ import ( "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" - controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" ) type Func func(machine *clusterv1.Machine) bool @@ -229,8 +229,8 @@ func MatchesTemplateClonedFrom(infraConfigs map[string]*unstructured.Unstructure } // Check if the machine's infrastructure reference has been created from the current KCP infrastructure template. - if clonedFromName != kcp.Spec.InfrastructureTemplate.Name || - clonedFromGroupKind != kcp.Spec.InfrastructureTemplate.GroupVersionKind().GroupKind().String() { + if clonedFromName != kcp.Spec.MachineTemplate.InfrastructureRef.Name || + clonedFromGroupKind != kcp.Spec.MachineTemplate.InfrastructureRef.GroupVersionKind().GroupKind().String() { return false } return true diff --git a/pkg/secret/certificates.go b/pkg/secret/certificates.go index 46558281..38ba1d92 100644 --- a/pkg/secret/certificates.go +++ b/pkg/secret/certificates.go @@ -39,7 +39,7 @@ import ( "sigs.k8s.io/cluster-api/util/certs" "sigs.k8s.io/controller-runtime/pkg/client" - bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta1" + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" ) const (