diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dc55850..c7d0260 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,18 +7,18 @@ updates: interval: "daily" open-pull-requests-limit: 10 reviewers: - - "onmetal/ccm-maintainers" + - "ironcore-dev/integration" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" open-pull-requests-limit: 10 reviewers: - - "onmetal/ccm-maintainers" + - "ironcore-dev/integration" - package-ecosystem: "docker" directory: "/" schedule: interval: "daily" open-pull-requests-limit: 10 reviewers: - - "onmetal/ccm-maintainers" + - "ironcore-dev/integration" diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index cc530f9..0e001e6 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -26,7 +26,7 @@ jobs: id: meta with: images: | - ghcr.io/${{ github.repository_owner }}/cloud-provider-onmetal + ghcr.io/${{ github.repository_owner }}/cloud-provider-ironcore tags: | type=semver,pattern={{version}} type=schedule diff --git a/.gitignore b/.gitignore index bbc844c..7c0d440 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,4 @@ dist/ dev/ config/kind/kubeconfig config/kind/cloud-config -config/kind/onmetal/kubeconfig +config/kind/ironcore/kubeconfig diff --git a/CODEOWNERS b/CODEOWNERS index 0eba442..a0ba79e 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,2 @@ -# onmetal-csi-driver maintainers -* @onmetal/ccm-maintainers +# cloud-provider-ironcore maintainers +* @ironcore-dev/integration diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f6059eb..eaa8e3e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1 +1 @@ -Please refer to the [Gardener on Metal code of conduct](https://onmetal.github.io/documentation/contribute/overview/#code-of-conduct). \ No newline at end of file +Please refer to the [IronCore code of conduct](https://ironcore-dev.github.io/documentation/contribute/overview/#code-of-conduct). \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 942ea49..b33d4f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,13 +23,13 @@ ARG TARGETARCH # Build RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ - CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -a -o manager ./cmd/cloud-provider-onmetal/main.go + CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -a -o manager ./cmd/cloud-provider-ironcore/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details FROM gcr.io/distroless/static:nonroot WORKDIR / -COPY --from=builder /workspace/manager /onmetal-cloud-controller-manager +COPY --from=builder /workspace/manager /ironcore-cloud-controller-manager USER 65532:65532 -ENTRYPOINT ["/onmetal-cloud-controller-manager"] \ No newline at end of file +ENTRYPOINT ["/ironcore-cloud-controller-manager"] \ No newline at end of file diff --git a/Makefile b/Makefile index f20ab24..ca4fa55 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BIN_NAME = "cloud-provider-onmetal" +BIN_NAME = "cloud-provider-ironcore" IMG ?= controller:latest # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. @@ -25,11 +25,11 @@ lint: ## Run golangci-lint against code. .PHONY: add-license add-license: addlicense ## Add license headers to all go files. - find . -name '*.go' -exec $(ADDLICENSE) -c 'OnMetal authors' {} + + find . -name '*.go' -exec $(ADDLICENSE) -c 'IronCore authors' {} + .PHONY: check-license check-license: addlicense ## Check that every file has a license header present. - find . -name '*.go' -exec $(ADDLICENSE) -check -c 'OnMetal authors' {} + + find . -name '*.go' -exec $(ADDLICENSE) -check -c 'IronCore authors' {} + .PHONY: check check: add-license fmt lint test # Generate manifests, code, lint, add licenses, test diff --git a/README.md b/README.md index 11f1c5f..3e43d6c 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ -# cloud-provider-onmetal +# cloud-provider-ironcore -[![Test](https://github.com/onmetal/cloud-provider-onmetal/actions/workflows/test.yml/badge.svg)](https://github.com/onmetal/cephlet/actions/workflows/test.yml) +[![Test](https://github.com/ironcore-dev/cloud-provider-ironcore/actions/workflows/test.yml/badge.svg)](https://github.com/ironcore-dev/ceph-provider/actions/workflows/test.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com) [![GitHub License](https://img.shields.io/static/v1?label=License&message=Apache-2.0&color=blue&style=flat-square)](LICENSE) -The `cloud-provider-onmetal` is the [Kubernetes cloud provider](https://github.com/kubernetes/cloud-provider) implementation for Gardener on Metal. +The `cloud-provider-ironcore` is the [Kubernetes cloud provider](https://github.com/kubernetes/cloud-provider) implementation for IronCore. ## Installation, Usage, and Development -For more details please refer to documentation folder [/docs](https://github.com/onmetal/cloud-provider-onmetal/tree/main/docs) +For more details please refer to documentation folder [/docs](https://github.com/ironcore-dev/cloud-provider-ironcore/tree/main/docs) ## Feedback and Support Feedback and contributions are always welcome! -Please report bugs, suggestions or post questions by opening a [Github issue](https://github.com/onmetal/cloud-provider-onmetal/issues). +Please report bugs, suggestions or post questions by opening a [Github issue](https://github.com/ironcore-dev/cloud-provider-ironcore/issues). ## License diff --git a/cmd/cloud-provider-onmetal/main.go b/cmd/cloud-provider-ironcore/main.go similarity index 94% rename from cmd/cloud-provider-onmetal/main.go rename to cmd/cloud-provider-ironcore/main.go index 020b0c0..a90ebda 100644 --- a/cmd/cloud-provider-onmetal/main.go +++ b/cmd/cloud-provider-ironcore/main.go @@ -15,7 +15,7 @@ package main import ( - "github.com/onmetal/cloud-provider-onmetal/pkg/cloudprovider/onmetal" + "github.com/ironcore-dev/cloud-provider-ironcore/pkg/cloudprovider/ironcore" "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/util/wait" cloudprovider "k8s.io/cloud-provider" @@ -42,7 +42,7 @@ func main() { controllerInitializers := app.DefaultInitFuncConstructors namedFlagSets := cliflag.NamedFlagSets{} - onmetal.AddExtraFlags(pflag.CommandLine) + ironcore.AddExtraFlags(pflag.CommandLine) controllerAliases := names.CCMControllerAliases() @@ -58,7 +58,7 @@ func cloudInitializer(config *cloudcontrollerconfig.CompletedConfig) cloudprovid providerName := cloudConfig.Name if providerName == "" { - providerName = onmetal.ProviderName + providerName = ironcore.ProviderName } // initialize cloud provider with the cloud provider name and config file provided diff --git a/config/config/secret.yaml b/config/config/secret.yaml index 7910f73..2df50be 100644 --- a/config/config/secret.yaml +++ b/config/config/secret.yaml @@ -3,8 +3,8 @@ kind: Secret metadata: labels: k8s-app: cloud-controller-manager - name: onmetal-ccm + name: ironcore-ccm stringData: - # onmetal-api kubeconfig goes here + # ironcore kubeconfig goes here config.yaml: |- \ No newline at end of file diff --git a/config/kind/kustomization.yaml b/config/kind/kustomization.yaml index f06ccd0..367a73f 100644 --- a/config/kind/kustomization.yaml +++ b/config/kind/kustomization.yaml @@ -15,7 +15,7 @@ secretGenerator: - name: cloud-config files: - cloud-config - - name: onmetalkubeconfig + - name: ironcore-kubeconfig files: - - onmetal/kubeconfig + - ironcore/kubeconfig diff --git a/config/kind/patch-manager.yaml b/config/kind/patch-manager.yaml index e6be0d4..fe1a5d4 100644 --- a/config/kind/patch-manager.yaml +++ b/config/kind/patch-manager.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: namespace: kube-system - name: onmetal-cloud-controller-manager + name: ironcore-cloud-controller-manager spec: template: spec: diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 4c074c3..f34fa8a 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -1,29 +1,29 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: onmetal-cloud-controller-manager + name: ironcore-cloud-controller-manager labels: - k8s-app: onmetal-cloud-controller-manager + k8s-app: ironcore-cloud-controller-manager spec: replicas: 1 selector: matchLabels: - k8s-app: onmetal-cloud-controller-manager + k8s-app: ironcore-cloud-controller-manager template: metadata: labels: - k8s-app: onmetal-cloud-controller-manager + k8s-app: ironcore-cloud-controller-manager spec: serviceAccountName: cloud-controller-manager hostNetwork: true containers: - name: manager command: - - /onmetal-cloud-controller-manager + - /ironcore-cloud-controller-manager args: - - --cloud-provider=onmetal + - --cloud-provider=ironcore - --cloud-config=/etc/cloud/cloud-config - - --onmetal-kubeconfig=/etc/onmetal/kubeconfig + - --ironcore-kubeconfig=/etc/ironcore/kubeconfig - --kubeconfig=/etc/kubernetes/kubeconfig - --authentication-kubeconfig=/etc/kubernetes/kubeconfig - --authorization-kubeconfig=/etc/kubernetes/kubeconfig @@ -55,8 +55,8 @@ spec: - mountPath: /etc/kubernetes name: kubeconfig readOnly: true - - mountPath: /etc/onmetal - name: onmetalkubeconfig + - mountPath: /etc/ironcore + name: ironcore-kubeconfig readOnly: true - mountPath: /etc/cloud name: cloud-config @@ -75,8 +75,8 @@ spec: secretName: kubeconfig name: kubeconfig - secret: - secretName: onmetalkubeconfig - name: onmetalkubeconfig + secretName: ironcore-kubeconfig + name: ironcore-kubeconfig - configMap: name: kube-root-ca.crt items: diff --git a/docs/deployment/deploy_manually.md b/docs/deployment/deploy_manually.md index 907f9f3..87692fe 100644 --- a/docs/deployment/deploy_manually.md +++ b/docs/deployment/deploy_manually.md @@ -23,20 +23,20 @@ $ systemctl restart kubelet ``` -## Steps to Deploy "Cloud-provider-onmetal" -* To deploy clone the repository [cloud-provider-onmetal](https://github.com/onmetal/cloud-provider-onmetal) +## Steps to Deploy "Cloud-provider-ironcore" +* To deploy clone the repository [cloud-provider-ironcore](https://github.com/ironcore-dev/cloud-provider-ironcore) ```shell -git clone git@github.com:onmetal/cloud-provider-onmetal.git -cd cloud-provider-onmetal +git clone git@github.com:ironcore-dev/cloud-provider-ironcore.git +cd cloud-provider-ironcore ``` -* Create folder ``config/kind/onmetal`` and create kubeconfig into folder ``config/kind/onmetal/kubeconfig``. +* Create folder ``config/kind/ironcore`` and create kubeconfig into folder ``config/kind/ironcore/kubeconfig``. - If you want to use onmetal-api server from different cluster then copy kubeconfig of that cluster into folder ``config/kind/onmetal/kubeconfig`` + If you want to use ironcore server from different cluster then copy kubeconfig of that cluster into folder ``config/kind/ironcore/kubeconfig`` - If you want to use onmetal-api server from local deployment then copy kubeconfig into folder ``config/kind/onmetal/kubeconfig`` using below command + If you want to use ironcore server from local deployment then copy kubeconfig into folder ``config/kind/ironcore/kubeconfig`` using below command ```shell -kind get kubeconfig > ./config/kind/onmetal/kubeconfig +kind get kubeconfig > ./config/kind/ironcore/kubeconfig ``` * Copy kubeconfig into folder ``config/kind/kubeconfig`` ```shell @@ -44,17 +44,17 @@ kind get kubeconfig > ./config/kind/kubeconfig ``` * Create cloud-config file under ``./config/kind/`` with the help of sample file present under ``./config/sample/cloud-config`` - **Note**: The kubeconfig content here is your onmetal-api cluster's kubeconfig incase of a real kubeadm cluster deployment + **Note**: The kubeconfig content here is your ironcore-api cluster's kubeconfig incase of a real kubeadm cluster deployment -* Run below make target to deploy the ``cloud-provider-onmetal`` +* Run below make target to deploy the ``cloud-provider-ironcore`` ```shell make docker-build kustomize build config/kind | kubectl apply -f - ``` **Validation:** ``` -kubectl get po -n kube-system -o wide| grep onmetal -onmetal-cloud-controller-manager-crws9 1/1 Running 4 (80s ago) 4m13s 10.244.225.76 csi-master +kubectl get po -n kube-system -o wide| grep ironcore +ironcore-cloud-controller-manager-crws9 1/1 Running 4 (80s ago) 4m13s 10.244.225.76 csi-master ``` **Note**: In case that there are multiple environments running, ensure that `kind get clusters` is pointing to the diff --git a/docs/development/setup.md b/docs/development/setup.md index a3afe19..53463f5 100644 --- a/docs/development/setup.md +++ b/docs/development/setup.md @@ -10,14 +10,14 @@ ## Clone the Repository -To bring up and start locally the `cloud-provider-onmetal` project for development purposes you first need to clone the repository. +To bring up and start locally the `cloud-provider-ironcore` project for development purposes you first need to clone the repository. ```shell -git clone git@github.com:onmetal/cloud-provider-onmetal.git -cd cloud-provider-onmetal +git clone git@github.com:ironcore-dev/cloud-provider-ironcore.git +cd cloud-provider-ironcore ``` -## Install cloud-provider-onmetal into the kind Cluster +## Install cloud-provider-ironcore into the kind Cluster For local development with `kind` follow below steps Copy kubeconfig to apply the config in kind diff --git a/go.mod b/go.mod index 40d919f..07c2b36 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -module github.com/onmetal/cloud-provider-onmetal +module github.com/ironcore-dev/cloud-provider-ironcore go 1.21 require ( - github.com/onmetal/controller-utils v0.8.3 - github.com/onmetal/onmetal-api v0.1.2-0.20231006124132-8ad37e778d15 + github.com/ironcore-dev/controller-utils v0.9.0 + github.com/ironcore-dev/ironcore v0.1.2-0.20231120144059-30dd02e88870 github.com/onsi/ginkgo/v2 v2.13.1 github.com/onsi/gomega v1.30.0 github.com/pkg/errors v0.9.1 @@ -69,7 +69,7 @@ require ( github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.10.1 // indirect - github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/cobra v1.8.0 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect go.etcd.io/etcd/api/v3 v3.5.9 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect @@ -90,7 +90,7 @@ require ( golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.11.0 // indirect - golang.org/x/sync v0.4.0 // indirect + golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.14.0 // indirect golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect @@ -107,14 +107,14 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.28.3 // indirect + k8s.io/apiextensions-apiserver v0.28.4 // indirect k8s.io/apiserver v0.28.4 // indirect k8s.io/component-helpers v0.28.4 // indirect k8s.io/kms v0.28.4 // indirect - k8s.io/kube-aggregator v0.28.2 // indirect + k8s.io/kube-aggregator v0.28.4 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index 7b3935c..cfdadff 100644 --- a/go.sum +++ b/go.sum @@ -31,7 +31,7 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -114,6 +114,10 @@ github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/ironcore-dev/controller-utils v0.9.0 h1:q8Ljk6UIS6WB0J/k/hVV13umHUn/Bfr2+PxdZls1C8U= +github.com/ironcore-dev/controller-utils v0.9.0/go.mod h1:06mPYdYCdjGHVz/msCG/MyDjPdOufRkUd4GaTqkzZwg= +github.com/ironcore-dev/ironcore v0.1.2-0.20231120144059-30dd02e88870 h1:yAFYucF/zthz9zdgHLbaQ5q9Ee0hFfbNHtxflm/lU5o= +github.com/ironcore-dev/ironcore v0.1.2-0.20231120144059-30dd02e88870/go.mod h1:+rMMEH846ihqB+P55EX/NIvKQs9QDjcIurhRoR3jorU= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= @@ -144,10 +148,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onmetal/controller-utils v0.8.3 h1:yIS9Gz+QO1oQEpXlfZFbnPz2fttpk4ZYBz0f80ovd48= -github.com/onmetal/controller-utils v0.8.3/go.mod h1:8Inx1jd9R85PjFoQLMNDCQnYI5wMYcmnhK8DD2V4l50= -github.com/onmetal/onmetal-api v0.1.2-0.20231006124132-8ad37e778d15 h1:zG9toJaugQ+mhvdPnRbeSsFIIs1GCUbe+MmV7liuSJE= -github.com/onmetal/onmetal-api v0.1.2-0.20231006124132-8ad37e778d15/go.mod h1:scZsrveTOe/CagZbqJ+pPEa/gDx6PGg4DpjOf7g4Mjs= github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= @@ -172,8 +172,8 @@ github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0 github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= @@ -272,8 +272,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -341,8 +341,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= -k8s.io/apiextensions-apiserver v0.28.3 h1:Od7DEnhXHnHPZG+W9I97/fSQkVpVPQx2diy+2EtmY08= -k8s.io/apiextensions-apiserver v0.28.3/go.mod h1:NE1XJZ4On0hS11aWWJUTNkmVB03j9LM7gJSisbRt8Lc= +k8s.io/apiextensions-apiserver v0.28.4 h1:AZpKY/7wQ8n+ZYDtNHbAJBb+N4AXXJvyZx6ww6yAJvU= +k8s.io/apiextensions-apiserver v0.28.4/go.mod h1:pgQIZ1U8eJSMQcENew/0ShUTlePcSGFq6dxSxf2mwPM= k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= k8s.io/apiserver v0.28.4 h1:BJXlaQbAU/RXYX2lRz+E1oPe3G3TKlozMMCZWu5GMgg= @@ -361,8 +361,8 @@ k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kms v0.28.4 h1:PMgY/3CQTWP9eIKmNQiTgjLIZ0ns6O+voagzD2/4mSg= k8s.io/kms v0.28.4/go.mod h1:HL4/lR/bhjAJPbqycKtfhWiKh1Sp21cpHOL8P4oo87w= -k8s.io/kube-aggregator v0.28.2 h1:tCjAfB1p/v18yD2NpegNQRuahzyA/szFfcRARnpjDeo= -k8s.io/kube-aggregator v0.28.2/go.mod h1:g4hZVjC4KhJtZHV2pyiRBiU6AdBA/sAjh9Y9GJC/SbU= +k8s.io/kube-aggregator v0.28.4 h1:VIGTKc3cDaJ44bvj988MTapJyRPbWXXcCvlp7HVLq5Q= +k8s.io/kube-aggregator v0.28.4/go.mod h1:SHehggsYGjVaE1CZTfhukAPpdhs7bflJiddLrabbQNY= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= @@ -373,7 +373,7 @@ sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigw sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= -sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/pkg/cloudprovider/onmetal/cloud.go b/pkg/cloudprovider/ironcore/cloud.go similarity index 63% rename from pkg/cloudprovider/onmetal/cloud.go rename to pkg/cloudprovider/ironcore/cloud.go index 32f572b..7586562 100644 --- a/pkg/cloudprovider/onmetal/cloud.go +++ b/pkg/cloudprovider/ironcore/cloud.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "context" @@ -20,36 +20,34 @@ import ( "io" "log" - "sigs.k8s.io/controller-runtime/pkg/cache" - + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" + storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" cloudprovider "k8s.io/cloud-provider" "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/cluster" - - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" - storagev1alpha1 "github.com/onmetal/onmetal-api/api/storage/v1alpha1" ) const ( - ProviderName = "onmetal" + ProviderName = "ironcore" machineMetadataUIDField = ".metadata.uid" networkInterfaceSpecNetworkRefNameField = "spec.networkRef.name" ) -var onmetalScheme = runtime.NewScheme() +var ironcoreScheme = runtime.NewScheme() func init() { - utilruntime.Must(computev1alpha1.AddToScheme(onmetalScheme)) - utilruntime.Must(storagev1alpha1.AddToScheme(onmetalScheme)) - utilruntime.Must(ipamv1alpha1.AddToScheme(onmetalScheme)) - utilruntime.Must(networkingv1alpha1.AddToScheme(onmetalScheme)) + utilruntime.Must(computev1alpha1.AddToScheme(ironcoreScheme)) + utilruntime.Must(storagev1alpha1.AddToScheme(ironcoreScheme)) + utilruntime.Must(ipamv1alpha1.AddToScheme(ironcoreScheme)) + utilruntime.Must(networkingv1alpha1.AddToScheme(ironcoreScheme)) cloudprovider.RegisterCloudProvider(ProviderName, func(config io.Reader) (cloudprovider.Interface, error) { cfg, err := LoadCloudProviderConfig(config) @@ -57,32 +55,32 @@ func init() { return nil, errors.Wrap(err, "failed to decode config") } - onmetalCluster, err := cluster.New(cfg.RestConfig, func(o *cluster.Options) { - o.Scheme = onmetalScheme + ironcoreCluster, err := cluster.New(cfg.RestConfig, func(o *cluster.Options) { + o.Scheme = ironcoreScheme o.Cache.DefaultNamespaces = map[string]cache.Config{ cfg.Namespace: {}, } }) if err != nil { - return nil, fmt.Errorf("unable to create onmetal cluster: %w", err) + return nil, fmt.Errorf("unable to create ironcore cluster: %w", err) } return &cloud{ - onmetalCluster: onmetalCluster, - onmetalNamespace: cfg.Namespace, - cloudConfig: cfg.cloudConfig, + ironcoreCluster: ironcoreCluster, + ironcoreNamespace: cfg.Namespace, + cloudConfig: cfg.cloudConfig, }, nil }) } type cloud struct { - targetCluster cluster.Cluster - onmetalCluster cluster.Cluster - onmetalNamespace string - cloudConfig CloudConfig - loadBalancer cloudprovider.LoadBalancer - instancesV2 cloudprovider.InstancesV2 - routes cloudprovider.Routes + targetCluster cluster.Cluster + ironcoreCluster cluster.Cluster + ironcoreNamespace string + cloudConfig CloudConfig + loadBalancer cloudprovider.LoadBalancer + instancesV2 cloudprovider.InstancesV2 + routes cloudprovider.Routes } func (o *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) { @@ -102,18 +100,18 @@ func (o *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, log.Fatalf("Failed to create new cluster: %v", err) } - o.instancesV2 = newOnmetalInstancesV2(o.targetCluster.GetClient(), o.onmetalCluster.GetClient(), o.onmetalNamespace, o.cloudConfig.ClusterName) - o.loadBalancer = newOnmetalLoadBalancer(o.targetCluster.GetClient(), o.onmetalCluster.GetClient(), o.onmetalNamespace, o.cloudConfig) - o.routes = newOnmetalRoutes(o.targetCluster.GetClient(), o.onmetalCluster.GetClient(), o.onmetalNamespace, o.cloudConfig) + o.instancesV2 = newIroncoreInstancesV2(o.targetCluster.GetClient(), o.ironcoreCluster.GetClient(), o.ironcoreNamespace, o.cloudConfig.ClusterName) + o.loadBalancer = newIroncoreLoadBalancer(o.targetCluster.GetClient(), o.ironcoreCluster.GetClient(), o.ironcoreNamespace, o.cloudConfig) + o.routes = newIroncoreRoutes(o.targetCluster.GetClient(), o.ironcoreCluster.GetClient(), o.ironcoreNamespace, o.cloudConfig) - if err := o.onmetalCluster.GetFieldIndexer().IndexField(ctx, &computev1alpha1.Machine{}, machineMetadataUIDField, func(object client.Object) []string { + if err := o.ironcoreCluster.GetFieldIndexer().IndexField(ctx, &computev1alpha1.Machine{}, machineMetadataUIDField, func(object client.Object) []string { machine := object.(*computev1alpha1.Machine) return []string{string(machine.UID)} }); err != nil { log.Fatalf("Failed to setup field indexer for machine: %v", err) } - if err := o.onmetalCluster.GetFieldIndexer().IndexField(ctx, &networkingv1alpha1.NetworkInterface{}, networkInterfaceSpecNetworkRefNameField, func(object client.Object) []string { + if err := o.ironcoreCluster.GetFieldIndexer().IndexField(ctx, &networkingv1alpha1.NetworkInterface{}, networkInterfaceSpecNetworkRefNameField, func(object client.Object) []string { nic := object.(*networkingv1alpha1.NetworkInterface) return []string{nic.Spec.NetworkRef.Name} }); err != nil { @@ -126,8 +124,8 @@ func (o *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, // TODO: setup informer for Services go func() { - if err := o.onmetalCluster.Start(ctx); err != nil { - log.Fatalf("Failed to start onmetal cluster: %v", err) + if err := o.ironcoreCluster.Start(ctx); err != nil { + log.Fatalf("Failed to start ironcore cluster: %v", err) } }() @@ -137,8 +135,8 @@ func (o *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, } }() - if !o.onmetalCluster.GetCache().WaitForCacheSync(ctx) { - log.Fatal("Failed to wait for onmetal cluster cache to sync") + if !o.ironcoreCluster.GetCache().WaitForCacheSync(ctx) { + log.Fatal("Failed to wait for ironcore cluster cache to sync") } if !o.targetCluster.GetCache().WaitForCacheSync(ctx) { log.Fatal("Failed to wait for target cluster cache to sync") @@ -150,7 +148,7 @@ func (o *cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) { return o.loadBalancer, true } -// Instances returns an implementation of Instances for onmetal +// Instances returns an implementation of Instances for ironcore func (o *cloud) Instances() (cloudprovider.Instances, bool) { return nil, false } @@ -163,7 +161,7 @@ func (o *cloud) InstancesV2() (cloudprovider.InstancesV2, bool) { return o.instancesV2, true } -// Zones returns an implementation of Zones for onmetal +// Zones returns an implementation of Zones for ironcore func (o *cloud) Zones() (cloudprovider.Zones, bool) { return nil, false } @@ -173,7 +171,7 @@ func (o *cloud) Clusters() (cloudprovider.Clusters, bool) { return nil, false } -// Routes returns an implementation of Routes for onmetal +// Routes returns an implementation of Routes for ironcore func (o *cloud) Routes() (cloudprovider.Routes, bool) { return o.routes, true } diff --git a/pkg/cloudprovider/onmetal/cloud_test.go b/pkg/cloudprovider/ironcore/cloud_test.go similarity index 94% rename from pkg/cloudprovider/onmetal/cloud_test.go rename to pkg/cloudprovider/ironcore/cloud_test.go index 8cd66b9..5d2277a 100644 --- a/pkg/cloudprovider/onmetal/cloud_test.go +++ b/pkg/cloudprovider/ironcore/cloud_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( . "github.com/onsi/ginkgo/v2" @@ -25,7 +25,7 @@ var _ = Describe("Cloud", func() { It("should ensure the correct cloud provider setup", func() { Expect((*cp).HasClusterID()).To(BeTrue()) - Expect((*cp).ProviderName()).To(Equal("onmetal")) + Expect((*cp).ProviderName()).To(Equal("ironcore")) clusters, ok := (*cp).Clusters() Expect(clusters).To(BeNil()) diff --git a/pkg/cloudprovider/onmetal/config.go b/pkg/cloudprovider/ironcore/config.go similarity index 73% rename from pkg/cloudprovider/onmetal/config.go rename to pkg/cloudprovider/ironcore/config.go index 0834b36..d4f2859 100644 --- a/pkg/cloudprovider/onmetal/config.go +++ b/pkg/cloudprovider/ironcore/config.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "fmt" @@ -40,11 +40,11 @@ type CloudConfig struct { } var ( - OnmetalKubeconfigPath string + IroncoreKubeconfigPath string ) func AddExtraFlags(fs *pflag.FlagSet) { - fs.StringVar(&OnmetalKubeconfigPath, "onmetal-kubeconfig", "", "Path to the onmetal kubeconfig.") + fs.StringVar(&IroncoreKubeconfigPath, "ironcore-kubeconfig", "", "Path to the ironcore kubeconfig.") } func LoadCloudProviderConfig(f io.Reader) (*cloudProviderConfig, error) { @@ -67,31 +67,31 @@ func LoadCloudProviderConfig(f io.Reader) (*cloudProviderConfig, error) { return nil, fmt.Errorf("clusterName missing in cloud config") } - onmetalKubeconfigData, err := os.ReadFile(OnmetalKubeconfigPath) + ironcoreKubeconfigData, err := os.ReadFile(IroncoreKubeconfigPath) if err != nil { - return nil, fmt.Errorf("failed to read onmetal kubeconfig %s: %w", OnmetalKubeconfigPath, err) + return nil, fmt.Errorf("failed to read ironcore kubeconfig %s: %w", IroncoreKubeconfigPath, err) } - onmetalKubeconfig, err := clientcmd.Load(onmetalKubeconfigData) + ironcoreKubeconfig, err := clientcmd.Load(ironcoreKubeconfigData) if err != nil { - return nil, fmt.Errorf("unable to read onmetal cluster kubeconfig: %w", err) + return nil, fmt.Errorf("unable to read ironcore cluster kubeconfig: %w", err) } - clientConfig := clientcmd.NewDefaultClientConfig(*onmetalKubeconfig, nil) + clientConfig := clientcmd.NewDefaultClientConfig(*ironcoreKubeconfig, nil) if err != nil { - return nil, fmt.Errorf("unable to serialize onmetal cluster kubeconfig: %w", err) + return nil, fmt.Errorf("unable to serialize ironcore cluster kubeconfig: %w", err) } restConfig, err := clientConfig.ClientConfig() if err != nil { - return nil, fmt.Errorf("unable to get onmetal cluster rest config: %w", err) + return nil, fmt.Errorf("unable to get ironcore cluster rest config: %w", err) } namespace, _, err := clientConfig.Namespace() if err != nil { - return nil, fmt.Errorf("failed to get namespace from onmetal kubeconfig: %w", err) + return nil, fmt.Errorf("failed to get namespace from ironcore kubeconfig: %w", err) } // TODO: empty or unset namespace will be defaulted to the 'default' namespace. We might want to handle this // as an error. if namespace == "" { - return nil, fmt.Errorf("got a empty namespace from onmetal kubeconfig") + return nil, fmt.Errorf("got a empty namespace from ironcore kubeconfig") } klog.V(2).Infof("Successfully read configuration for cloud provider: %s", ProviderName) diff --git a/pkg/cloudprovider/onmetal/config_test.go b/pkg/cloudprovider/ironcore/config_test.go similarity index 97% rename from pkg/cloudprovider/onmetal/config_test.go rename to pkg/cloudprovider/ironcore/config_test.go index 8abdb9d..8605ee0 100644 --- a/pkg/cloudprovider/onmetal/config_test.go +++ b/pkg/cloudprovider/ironcore/config_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "os" @@ -64,7 +64,7 @@ var _ = Describe("Config", func() { _ = kubeconfigFile.Close() }() Expect(os.WriteFile(kubeconfigFile.Name(), kubeconfigData, 0666)).To(Succeed()) - OnmetalKubeconfigPath = kubeconfigFile.Name() + IroncoreKubeconfigPath = kubeconfigFile.Name() config, err := LoadCloudProviderConfig(configReader) Expect(err).NotTo(HaveOccurred()) Expect(config.RestConfig).NotTo(BeNil()) @@ -112,7 +112,7 @@ var _ = Describe("Config", func() { _ = kubeconfigFile.Close() }() Expect(os.WriteFile(kubeconfigFile.Name(), kubeconfigData, 0666)).To(Succeed()) - OnmetalKubeconfigPath = kubeconfigFile.Name() + IroncoreKubeconfigPath = kubeconfigFile.Name() config, err := LoadCloudProviderConfig(configReader) Expect(err).NotTo(HaveOccurred()) Expect(config.RestConfig).NotTo(BeNil()) diff --git a/pkg/cloudprovider/onmetal/constants.go b/pkg/cloudprovider/ironcore/constants.go similarity index 92% rename from pkg/cloudprovider/onmetal/constants.go rename to pkg/cloudprovider/ironcore/constants.go index a77743a..a44cb06 100644 --- a/pkg/cloudprovider/onmetal/constants.go +++ b/pkg/cloudprovider/ironcore/constants.go @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore const ( // InternalLoadBalancerAnnotation is internal load balancer annotation of service - InternalLoadBalancerAnnotation = "service.beta.kubernetes.io/onmetal-load-balancer-internal" + InternalLoadBalancerAnnotation = "service.beta.kubernetes.io/ironcore-load-balancer-internal" // AnnotationKeyClusterName is the cluster name annotation key name AnnotationKeyClusterName = "cluster-name" // AnnotationKeyServiceName is the service name annotation key name diff --git a/pkg/cloudprovider/onmetal/instances_v2.go b/pkg/cloudprovider/ironcore/instances_v2.go similarity index 70% rename from pkg/cloudprovider/onmetal/instances_v2.go rename to pkg/cloudprovider/ironcore/instances_v2.go index 15a1adc..cdfc49e 100644 --- a/pkg/cloudprovider/onmetal/instances_v2.go +++ b/pkg/cloudprovider/ironcore/instances_v2.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "context" @@ -24,34 +24,34 @@ import ( "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" ) -type onmetalInstancesV2 struct { - targetClient client.Client - onmetalClient client.Client - onmetalNamespace string - clusterName string +type ironcoreInstancesV2 struct { + targetClient client.Client + ironcoreClient client.Client + ironcoreNamespace string + clusterName string } -func newOnmetalInstancesV2(targetClient client.Client, onmetalClient client.Client, namespace, clusterName string) cloudprovider.InstancesV2 { - return &onmetalInstancesV2{ - targetClient: targetClient, - onmetalClient: onmetalClient, - onmetalNamespace: namespace, - clusterName: clusterName, +func newIroncoreInstancesV2(targetClient client.Client, ironcoreClient client.Client, namespace, clusterName string) cloudprovider.InstancesV2 { + return &ironcoreInstancesV2{ + targetClient: targetClient, + ironcoreClient: ironcoreClient, + ironcoreNamespace: namespace, + clusterName: clusterName, } } -func (o *onmetalInstancesV2) InstanceExists(ctx context.Context, node *corev1.Node) (bool, error) { +func (o *ironcoreInstancesV2) InstanceExists(ctx context.Context, node *corev1.Node) (bool, error) { if node == nil { return false, nil } klog.V(4).InfoS("Checking if node exists", "Node", node.Name) machine := &computev1alpha1.Machine{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: node.Name}, machine); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: node.Name}, machine); err != nil { if apierrors.IsNotFound(err) { return false, cloudprovider.InstanceNotFound } @@ -62,14 +62,14 @@ func (o *onmetalInstancesV2) InstanceExists(ctx context.Context, node *corev1.No return true, nil } -func (o *onmetalInstancesV2) InstanceShutdown(ctx context.Context, node *corev1.Node) (bool, error) { +func (o *ironcoreInstancesV2) InstanceShutdown(ctx context.Context, node *corev1.Node) (bool, error) { if node == nil { return false, nil } klog.V(4).InfoS("Checking if instance is shut down", "Node", node.Name) machine := &computev1alpha1.Machine{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: node.Name}, machine); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: node.Name}, machine); err != nil { if apierrors.IsNotFound(err) { return false, cloudprovider.InstanceNotFound } @@ -81,12 +81,12 @@ func (o *onmetalInstancesV2) InstanceShutdown(ctx context.Context, node *corev1. return nodeShutDownStatus, nil } -func (o *onmetalInstancesV2) InstanceMetadata(ctx context.Context, node *corev1.Node) (*cloudprovider.InstanceMetadata, error) { +func (o *ironcoreInstancesV2) InstanceMetadata(ctx context.Context, node *corev1.Node) (*cloudprovider.InstanceMetadata, error) { if node == nil { return nil, nil } machine := &computev1alpha1.Machine{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: node.Name}, machine); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: node.Name}, machine); err != nil { if apierrors.IsNotFound(err) { return nil, cloudprovider.InstanceNotFound } @@ -100,14 +100,14 @@ func (o *onmetalInstancesV2) InstanceMetadata(ctx context.Context, node *corev1. } machine.Labels[LabelKeyClusterName] = o.clusterName klog.V(2).InfoS("Adding cluster name label to Machine object", "Machine", client.ObjectKeyFromObject(machine), "Node", node.Name) - if err := o.onmetalClient.Patch(ctx, machine, client.MergeFrom(machineBase)); err != nil { + if err := o.ironcoreClient.Patch(ctx, machine, client.MergeFrom(machineBase)); err != nil { return nil, fmt.Errorf("failed to patch Machine %s for Node %s: %w", client.ObjectKeyFromObject(machine), node.Name, err) } for _, networkInterface := range machine.Spec.NetworkInterfaces { nic := &networkingv1alpha1.NetworkInterface{} nicName := fmt.Sprintf("%s-%s", machine.Name, networkInterface.Name) - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: nicName}, nic); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: nicName}, nic); err != nil { return nil, fmt.Errorf("failed to get network interface %s for machine %s: %w", client.ObjectKeyFromObject(nic), machine.Name, err) } @@ -118,7 +118,7 @@ func (o *onmetalInstancesV2) InstanceMetadata(ctx context.Context, node *corev1. } nic.Labels[LabelKeyClusterName] = o.clusterName klog.V(2).InfoS("Adding cluster name label to NetworkInterface", "NetworkInterface", client.ObjectKeyFromObject(nic), "Node", node.Name, "Label", nic.Labels[LabelKeyClusterName]) - if err := o.onmetalClient.Patch(ctx, nic, client.MergeFrom(nicBase)); err != nil { + if err := o.ironcoreClient.Patch(ctx, nic, client.MergeFrom(nicBase)); err != nil { return nil, fmt.Errorf("failed to patch NetworkInterface %s for Node %s: %w", client.ObjectKeyFromObject(nic), node.Name, err) } } @@ -141,7 +141,7 @@ func (o *onmetalInstancesV2) InstanceMetadata(ctx context.Context, node *corev1. providerID := node.Spec.ProviderID if providerID == "" { - providerID = fmt.Sprintf("%s://%s/%s", ProviderName, o.onmetalNamespace, machine.Name) + providerID = fmt.Sprintf("%s://%s/%s", ProviderName, o.ironcoreNamespace, machine.Name) } zone := "" diff --git a/pkg/cloudprovider/onmetal/instances_v2_test.go b/pkg/cloudprovider/ironcore/instances_v2_test.go similarity index 96% rename from pkg/cloudprovider/onmetal/instances_v2_test.go rename to pkg/cloudprovider/ironcore/instances_v2_test.go index a9d4c3e..216fa19 100644 --- a/pkg/cloudprovider/onmetal/instances_v2_test.go +++ b/pkg/cloudprovider/ironcore/instances_v2_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "fmt" @@ -26,9 +26,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" ) var _ = Describe("InstancesV2", func() { diff --git a/pkg/cloudprovider/onmetal/load_balancer.go b/pkg/cloudprovider/ironcore/load_balancer.go similarity index 74% rename from pkg/cloudprovider/onmetal/load_balancer.go rename to pkg/cloudprovider/ironcore/load_balancer.go index 439555b..4c50bb3 100644 --- a/pkg/cloudprovider/onmetal/load_balancer.go +++ b/pkg/cloudprovider/ironcore/load_balancer.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "context" @@ -30,10 +30,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" ) const ( @@ -43,31 +43,31 @@ const ( ) var ( - loadBalancerFieldOwner = client.FieldOwner("cloud-provider.onmetal.de/loadbalancer") + loadBalancerFieldOwner = client.FieldOwner("cloud-provider.ironcore.dev/loadbalancer") ) -type onmetalLoadBalancer struct { - targetClient client.Client - onmetalClient client.Client - onmetalNamespace string - cloudConfig CloudConfig +type ironcoreLoadBalancer struct { + targetClient client.Client + ironcoreClient client.Client + ironcoreNamespace string + cloudConfig CloudConfig } -func newOnmetalLoadBalancer(targetClient client.Client, onmetalClient client.Client, namespace string, cloudConfig CloudConfig) cloudprovider.LoadBalancer { - return &onmetalLoadBalancer{ - targetClient: targetClient, - onmetalClient: onmetalClient, - onmetalNamespace: namespace, - cloudConfig: cloudConfig, +func newIroncoreLoadBalancer(targetClient client.Client, ironcoreClient client.Client, namespace string, cloudConfig CloudConfig) cloudprovider.LoadBalancer { + return &ironcoreLoadBalancer{ + targetClient: targetClient, + ironcoreClient: ironcoreClient, + ironcoreNamespace: namespace, + cloudConfig: cloudConfig, } } -func (o *onmetalLoadBalancer) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (status *v1.LoadBalancerStatus, exists bool, err error) { +func (o *ironcoreLoadBalancer) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (status *v1.LoadBalancerStatus, exists bool, err error) { klog.V(2).InfoS("GetLoadBalancer for Service", "Cluster", clusterName, "Service", client.ObjectKeyFromObject(service)) loadBalancer := &networkingv1alpha1.LoadBalancer{} loadBalancerName := o.GetLoadBalancerName(ctx, clusterName, service) - if err = o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: loadBalancerName}, loadBalancer); err != nil { + if err = o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: loadBalancerName}, loadBalancer); err != nil { return nil, false, fmt.Errorf("failed to get LoadBalancer %s for Service %s: %w", loadBalancerName, client.ObjectKeyFromObject(service), err) } @@ -79,12 +79,12 @@ func (o *onmetalLoadBalancer) GetLoadBalancer(ctx context.Context, clusterName s return status, true, nil } -func (o *onmetalLoadBalancer) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string { +func (o *ironcoreLoadBalancer) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string { cloudprovider.DefaultLoadBalancerName(service) return getLoadBalancerNameForService(clusterName, service) } -func (o *onmetalLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) { +func (o *ironcoreLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) { klog.V(2).InfoS("EnsureLoadBalancer for Service", "Cluster", clusterName, "Service", client.ObjectKeyFromObject(service)) // decide load balancer type based on service annotation for internal load balancer @@ -100,7 +100,7 @@ func (o *onmetalLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterNam // get existing load balancer type existingLoadBalancer := &networkingv1alpha1.LoadBalancer{} var existingLoadBalancerType networkingv1alpha1.LoadBalancerType - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: loadBalancerName}, existingLoadBalancer); err == nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: loadBalancerName}, existingLoadBalancer); err == nil { existingLoadBalancerType = existingLoadBalancer.Spec.Type if existingLoadBalancerType != desiredLoadBalancerType { if err = o.EnsureLoadBalancerDeleted(ctx, clusterName, service); err != nil { @@ -125,7 +125,7 @@ func (o *onmetalLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterNam }, ObjectMeta: metav1.ObjectMeta{ Name: loadBalancerName, - Namespace: o.onmetalNamespace, + Namespace: o.ironcoreNamespace, Annotations: map[string]string{ AnnotationKeyClusterName: clusterName, AnnotationKeyServiceName: service.Name, @@ -151,8 +151,8 @@ func (o *onmetalLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterNam loadBalancer.Spec.IPs = []networkingv1alpha1.IPSource{ { Ephemeral: &networkingv1alpha1.EphemeralPrefixSource{ - PrefixTemplate: &v1alpha1.PrefixTemplateSpec{ - Spec: v1alpha1.PrefixSpec{ + PrefixTemplate: &ipamv1alpha1.PrefixTemplateSpec{ + Spec: ipamv1alpha1.PrefixSpec{ // TODO: for now we only support IPv4 until Gardener has support for IPv6 based Shoots IPFamily: v1.IPv4Protocol, ParentRef: &v1.LocalObjectReference{ @@ -166,7 +166,7 @@ func (o *onmetalLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterNam } klog.V(2).InfoS("Applying LoadBalancer for Service", "LoadBalancer", client.ObjectKeyFromObject(loadBalancer), "Service", client.ObjectKeyFromObject(service)) - if err := o.onmetalClient.Patch(ctx, loadBalancer, client.Apply, loadBalancerFieldOwner, client.ForceOwnership); err != nil { + if err := o.ironcoreClient.Patch(ctx, loadBalancer, client.Apply, loadBalancerFieldOwner, client.ForceOwnership); err != nil { return nil, fmt.Errorf("failed to apply LoadBalancer %s for Service %s: %w", client.ObjectKeyFromObject(loadBalancer), client.ObjectKeyFromObject(service), err) } klog.V(2).InfoS("Applied LoadBalancer for Service", "LoadBalancer", client.ObjectKeyFromObject(loadBalancer), "Service", client.ObjectKeyFromObject(service)) @@ -177,7 +177,7 @@ func (o *onmetalLoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterNam } klog.V(2).InfoS("Applied LoadBalancerRouting for LoadBalancer", "LoadBalancer", client.ObjectKeyFromObject(loadBalancer)) - lbStatus, err := waitLoadBalancerActive(ctx, o.onmetalClient, existingLoadBalancerType, service, loadBalancer) + lbStatus, err := waitLoadBalancerActive(ctx, o.ironcoreClient, existingLoadBalancerType, service, loadBalancer) if err != nil { return nil, err } @@ -189,7 +189,7 @@ func getLoadBalancerNameForService(clusterName string, service *v1.Service) stri return fmt.Sprintf("%s-%s-%s", clusterName, service.Name, nameSuffix) } -func waitLoadBalancerActive(ctx context.Context, onmetalClient client.Client, existingLoadBalancerType networkingv1alpha1.LoadBalancerType, +func waitLoadBalancerActive(ctx context.Context, ironcoreClient client.Client, existingLoadBalancerType networkingv1alpha1.LoadBalancerType, service *v1.Service, loadBalancer *networkingv1alpha1.LoadBalancer) (v1.LoadBalancerStatus, error) { klog.V(2).InfoS("Waiting for LoadBalancer instance to become ready", "LoadBalancer", client.ObjectKeyFromObject(loadBalancer)) backoff := wait.Backoff{ @@ -200,7 +200,7 @@ func waitLoadBalancerActive(ctx context.Context, onmetalClient client.Client, ex loadBalancerStatus := v1.LoadBalancerStatus{} if err := wait.ExponentialBackoffWithContext(ctx, backoff, func(ctx context.Context) (bool, error) { - if err := onmetalClient.Get(ctx, client.ObjectKey{Namespace: loadBalancer.Namespace, Name: loadBalancer.Name}, loadBalancer); err != nil { + if err := ironcoreClient.Get(ctx, client.ObjectKey{Namespace: loadBalancer.Namespace, Name: loadBalancer.Name}, loadBalancer); err != nil { return false, err } if len(loadBalancer.Status.IPs) == 0 { @@ -224,15 +224,15 @@ func waitLoadBalancerActive(ctx context.Context, onmetalClient client.Client, ex return loadBalancerStatus, nil } -func (o *onmetalLoadBalancer) applyLoadBalancerRoutingForLoadBalancer(ctx context.Context, loadBalancer *networkingv1alpha1.LoadBalancer, nodes []*v1.Node) error { +func (o *ironcoreLoadBalancer) applyLoadBalancerRoutingForLoadBalancer(ctx context.Context, loadBalancer *networkingv1alpha1.LoadBalancer, nodes []*v1.Node) error { loadBalacerDestinations, err := o.getLoadBalancerDestinationsForNodes(ctx, nodes, loadBalancer.Spec.NetworkRef.Name) if err != nil { return fmt.Errorf("failed to get NetworkInterfaces for Nodes: %w", err) } network := &networkingv1alpha1.Network{} - networkKey := client.ObjectKey{Namespace: o.onmetalNamespace, Name: loadBalancer.Spec.NetworkRef.Name} - if err := o.onmetalClient.Get(ctx, networkKey, network); err != nil { + networkKey := client.ObjectKey{Namespace: o.ironcoreNamespace, Name: loadBalancer.Spec.NetworkRef.Name} + if err := o.ironcoreClient.Get(ctx, networkKey, network); err != nil { return fmt.Errorf("failed to get Network %s: %w", o.cloudConfig.NetworkName, err) } @@ -243,7 +243,7 @@ func (o *onmetalLoadBalancer) applyLoadBalancerRoutingForLoadBalancer(ctx contex }, ObjectMeta: metav1.ObjectMeta{ Name: loadBalancer.Name, - Namespace: o.onmetalNamespace, + Namespace: o.ironcoreNamespace, }, NetworkRef: commonv1alpha1.LocalUIDReference{ Name: network.Name, @@ -252,22 +252,22 @@ func (o *onmetalLoadBalancer) applyLoadBalancerRoutingForLoadBalancer(ctx contex Destinations: loadBalacerDestinations, } - if err := controllerutil.SetOwnerReference(loadBalancer, loadBalancerRouting, o.onmetalClient.Scheme()); err != nil { + if err := controllerutil.SetOwnerReference(loadBalancer, loadBalancerRouting, o.ironcoreClient.Scheme()); err != nil { return fmt.Errorf("failed to set owner reference for load balancer routing %s: %w", client.ObjectKeyFromObject(loadBalancerRouting), err) } - if err := o.onmetalClient.Patch(ctx, loadBalancerRouting, client.Apply, loadBalancerFieldOwner, client.ForceOwnership); err != nil { + if err := o.ironcoreClient.Patch(ctx, loadBalancerRouting, client.Apply, loadBalancerFieldOwner, client.ForceOwnership); err != nil { return fmt.Errorf("failed to apply LoadBalancerRouting %s for LoadBalancer %s: %w", client.ObjectKeyFromObject(loadBalancerRouting), client.ObjectKeyFromObject(loadBalancer), err) } return nil } -func (o *onmetalLoadBalancer) getLoadBalancerDestinationsForNodes(ctx context.Context, nodes []*v1.Node, networkName string) ([]networkingv1alpha1.LoadBalancerDestination, error) { +func (o *ironcoreLoadBalancer) getLoadBalancerDestinationsForNodes(ctx context.Context, nodes []*v1.Node, networkName string) ([]networkingv1alpha1.LoadBalancerDestination, error) { var loadbalancerDestinations []networkingv1alpha1.LoadBalancerDestination for _, node := range nodes { machineName := extractMachineNameFromProviderID(node.Spec.ProviderID) machine := &computev1alpha1.Machine{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: machineName}, machine); client.IgnoreNotFound(err) != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: machineName}, machine); client.IgnoreNotFound(err) != nil { return nil, fmt.Errorf("failed to get machine object for node %s: %w", node.Name, err) } @@ -279,7 +279,7 @@ func (o *onmetalLoadBalancer) getLoadBalancerDestinationsForNodes(ctx context.Co networkInterfaceName = machineNIC.NetworkInterfaceRef.Name } - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: networkInterfaceName}, networkInterface); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: networkInterfaceName}, networkInterface); err != nil { return nil, fmt.Errorf("failed to get network interface %s for machine %s: %w", client.ObjectKeyFromObject(networkInterface), client.ObjectKeyFromObject(machine), err) } @@ -312,7 +312,7 @@ func extractMachineNameFromProviderID(providerID string) string { return providerID[lastSlash+1:] } -func (o *onmetalLoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error { +func (o *ironcoreLoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error { klog.V(2).InfoS("Updating LoadBalancer for Service", "Service", client.ObjectKeyFromObject(service)) if len(nodes) == 0 { return fmt.Errorf("no Nodes available for LoadBalancer Service %s", client.ObjectKeyFromObject(service)) @@ -320,14 +320,14 @@ func (o *onmetalLoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterNam loadBalancerName := o.GetLoadBalancerName(ctx, clusterName, service) loadBalancer := &networkingv1alpha1.LoadBalancer{} - loadBalancerKey := client.ObjectKey{Namespace: o.onmetalNamespace, Name: loadBalancerName} - if err := o.onmetalClient.Get(ctx, loadBalancerKey, loadBalancer); err != nil { + loadBalancerKey := client.ObjectKey{Namespace: o.ironcoreNamespace, Name: loadBalancerName} + if err := o.ironcoreClient.Get(ctx, loadBalancerKey, loadBalancer); err != nil { return fmt.Errorf("failed to get LoadBalancer %s: %w", client.ObjectKeyFromObject(loadBalancer), err) } loadBalancerRouting := &networkingv1alpha1.LoadBalancerRouting{} - loadBalancerRoutingKey := client.ObjectKey{Namespace: o.onmetalNamespace, Name: loadBalancerName} - if err := o.onmetalClient.Get(ctx, loadBalancerRoutingKey, loadBalancerRouting); err != nil { + loadBalancerRoutingKey := client.ObjectKey{Namespace: o.ironcoreNamespace, Name: loadBalancerName} + if err := o.ironcoreClient.Get(ctx, loadBalancerRoutingKey, loadBalancerRouting); err != nil { return fmt.Errorf("failed to get LoadBalancerRouting %s for LoadBalancer %s: %w", client.ObjectKeyFromObject(loadBalancer), client.ObjectKeyFromObject(loadBalancerRouting), err) } @@ -339,7 +339,7 @@ func (o *onmetalLoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterNam loadBalancerRoutingBase := loadBalancerRouting.DeepCopy() loadBalancerRouting.Destinations = loadBalancerDestinations - if err := o.onmetalClient.Patch(ctx, loadBalancerRouting, client.MergeFrom(loadBalancerRoutingBase)); err != nil { + if err := o.ironcoreClient.Patch(ctx, loadBalancerRouting, client.MergeFrom(loadBalancerRoutingBase)); err != nil { return fmt.Errorf("failed to patch LoadBalancerRouting %s for LoadBalancer %s: %w", client.ObjectKeyFromObject(loadBalancerRouting), client.ObjectKeyFromObject(loadBalancer), err) } @@ -347,29 +347,29 @@ func (o *onmetalLoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterNam return nil } -func (o *onmetalLoadBalancer) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error { +func (o *ironcoreLoadBalancer) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error { loadBalancerName := o.GetLoadBalancerName(ctx, clusterName, service) loadBalancer := &networkingv1alpha1.LoadBalancer{ ObjectMeta: metav1.ObjectMeta{ - Namespace: o.onmetalNamespace, + Namespace: o.ironcoreNamespace, Name: loadBalancerName, }, } klog.V(2).InfoS("Deleting LoadBalancer", "LoadBalancer", client.ObjectKeyFromObject(loadBalancer)) - if err := o.onmetalClient.Delete(ctx, loadBalancer); err != nil { + if err := o.ironcoreClient.Delete(ctx, loadBalancer); err != nil { if apierrors.IsNotFound(err) { klog.V(2).InfoS("LoadBalancer is already gone", client.ObjectKeyFromObject(loadBalancer)) return nil } return fmt.Errorf("failed to delete loadbalancer %s: %w", client.ObjectKeyFromObject(loadBalancer), err) } - if err := waitForDeletingLoadBalancer(ctx, service, o.onmetalClient, loadBalancer); err != nil { + if err := waitForDeletingLoadBalancer(ctx, service, o.ironcoreClient, loadBalancer); err != nil { return err } return nil } -func waitForDeletingLoadBalancer(ctx context.Context, service *v1.Service, onmetalClient client.Client, loadBalancer *networkingv1alpha1.LoadBalancer) error { +func waitForDeletingLoadBalancer(ctx context.Context, service *v1.Service, ironcoreClient client.Client, loadBalancer *networkingv1alpha1.LoadBalancer) error { klog.V(2).InfoS("Waiting for LoadBalancer instance to be deleted", "LoadBalancer", client.ObjectKeyFromObject(loadBalancer)) backoff := wait.Backoff{ Duration: waitLoadbalancerInitDelay, @@ -378,7 +378,7 @@ func waitForDeletingLoadBalancer(ctx context.Context, service *v1.Service, onmet } if err := wait.ExponentialBackoffWithContext(ctx, backoff, func(ctx context.Context) (bool, error) { - if err := onmetalClient.Get(ctx, client.ObjectKey{Namespace: loadBalancer.Namespace, Name: loadBalancer.Name}, loadBalancer); !apierrors.IsNotFound(err) { + if err := ironcoreClient.Get(ctx, client.ObjectKey{Namespace: loadBalancer.Namespace, Name: loadBalancer.Name}, loadBalancer); !apierrors.IsNotFound(err) { return false, err } return true, nil diff --git a/pkg/cloudprovider/onmetal/load_balancer_test.go b/pkg/cloudprovider/ironcore/load_balancer_test.go similarity index 98% rename from pkg/cloudprovider/onmetal/load_balancer_test.go rename to pkg/cloudprovider/ironcore/load_balancer_test.go index 0bdb351..346a013 100644 --- a/pkg/cloudprovider/onmetal/load_balancer_test.go +++ b/pkg/cloudprovider/ironcore/load_balancer_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "fmt" @@ -25,9 +25,9 @@ import ( cloudprovider "k8s.io/cloud-provider" . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" ) var _ = Describe("LoadBalancer", func() { @@ -168,7 +168,7 @@ var _ = Describe("LoadBalancer", func() { } Eventually(Object(lbRouting)).Should(SatisfyAll( HaveField("ObjectMeta.OwnerReferences", ContainElement(metav1.OwnerReference{ - APIVersion: "networking.api.onmetal.de/v1alpha1", + APIVersion: "networking.ironcore.dev/v1alpha1", Kind: "LoadBalancer", Name: loadBalancer.Name, UID: loadBalancer.UID, @@ -338,7 +338,7 @@ var _ = Describe("LoadBalancer", func() { } Eventually(Object(lbRouting)).Should(SatisfyAll( HaveField("ObjectMeta.OwnerReferences", ContainElement(metav1.OwnerReference{ - APIVersion: "networking.api.onmetal.de/v1alpha1", + APIVersion: "networking.ironcore.dev/v1alpha1", Kind: "LoadBalancer", Name: loadBalancer.Name, UID: loadBalancer.UID, @@ -592,7 +592,7 @@ var _ = Describe("LoadBalancer", func() { } Eventually(Object(lbRouting)).Should(SatisfyAll( HaveField("ObjectMeta.OwnerReferences", ContainElement(metav1.OwnerReference{ - APIVersion: "networking.api.onmetal.de/v1alpha1", + APIVersion: "networking.ironcore.dev/v1alpha1", Kind: "LoadBalancer", Name: loadBalancer.Name, UID: loadBalancer.UID, diff --git a/pkg/cloudprovider/onmetal/routes.go b/pkg/cloudprovider/ironcore/routes.go similarity index 77% rename from pkg/cloudprovider/onmetal/routes.go rename to pkg/cloudprovider/ironcore/routes.go index 4c6dc7b..722db40 100644 --- a/pkg/cloudprovider/onmetal/routes.go +++ b/pkg/cloudprovider/ironcore/routes.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "context" @@ -25,32 +25,32 @@ import ( "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" ) -type onmetalRoutes struct { - targetClient client.Client - onmetalClient client.Client - onmetalNamespace string - cloudConfig CloudConfig +type ironcoreRoutes struct { + targetClient client.Client + ironcoreClient client.Client + ironcoreNamespace string + cloudConfig CloudConfig } -func newOnmetalRoutes(targetClient client.Client, onmetalClient client.Client, namespace string, cloudConfig CloudConfig) cloudprovider.Routes { - return &onmetalRoutes{ - targetClient: targetClient, - onmetalClient: onmetalClient, - onmetalNamespace: namespace, - cloudConfig: cloudConfig, +func newIroncoreRoutes(targetClient client.Client, ironcoreClient client.Client, namespace string, cloudConfig CloudConfig) cloudprovider.Routes { + return &ironcoreRoutes{ + targetClient: targetClient, + ironcoreClient: ironcoreClient, + ironcoreNamespace: namespace, + cloudConfig: cloudConfig, } } -func (o onmetalRoutes) ListRoutes(ctx context.Context, clusterName string) ([]*cloudprovider.Route, error) { +func (o ironcoreRoutes) ListRoutes(ctx context.Context, clusterName string) ([]*cloudprovider.Route, error) { klog.V(2).InfoS("List Routes", "Cluster", clusterName) networkInterfaces := &networkingv1alpha1.NetworkInterfaceList{} - if err := o.onmetalClient.List(ctx, networkInterfaces, client.InNamespace(o.onmetalNamespace), client.MatchingFields{ + if err := o.ironcoreClient.List(ctx, networkInterfaces, client.InNamespace(o.ironcoreNamespace), client.MatchingFields{ networkInterfaceSpecNetworkRefNameField: o.cloudConfig.NetworkName, }, client.MatchingLabels{ LabelKeyClusterName: clusterName, @@ -84,13 +84,13 @@ func (o onmetalRoutes) ListRoutes(ctx context.Context, clusterName string) ([]*c return routes, nil } -func (o onmetalRoutes) CreateRoute(ctx context.Context, clusterName string, nameHint string, route *cloudprovider.Route) error { +func (o ironcoreRoutes) CreateRoute(ctx context.Context, clusterName string, nameHint string, route *cloudprovider.Route) error { klog.V(2).InfoS("Creating Route", "Cluster", clusterName, "Route", route, "NameHint", nameHint) // get the machine object based on the node name nodeName := string(route.TargetNode) machine := &computev1alpha1.Machine{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: nodeName}, machine); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: nodeName}, machine); err != nil { if apierrors.IsNotFound(err) { return cloudprovider.InstanceNotFound } @@ -116,7 +116,7 @@ func (o onmetalRoutes) CreateRoute(ctx context.Context, clusterName string, name // get the network interface object networkInterfaceName := getNetworkInterfaceName(machine, networkInterface) nic := &networkingv1alpha1.NetworkInterface{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: networkInterfaceName}, nic); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: networkInterfaceName}, nic); err != nil { return err } @@ -139,7 +139,7 @@ func (o onmetalRoutes) CreateRoute(ctx context.Context, clusterName string, name nic.Spec.Prefixes = append(nic.Spec.Prefixes, prefixSource) klog.V(2).InfoS("Updating NetworkInterface by adding prefix", "NetworkInterface", client.ObjectKeyFromObject(nic), "Node", nodeName, "Prefix", route.DestinationCIDR) - if err := o.onmetalClient.Patch(ctx, nic, client.MergeFrom(nicBase)); err != nil { + if err := o.ironcoreClient.Patch(ctx, nic, client.MergeFrom(nicBase)); err != nil { return fmt.Errorf("failed to patch NetworkInterface %s for Node %s: %w", client.ObjectKeyFromObject(nic), nodeName, err) } } else { @@ -155,13 +155,13 @@ func (o onmetalRoutes) CreateRoute(ctx context.Context, clusterName string, name return nil } -func (o onmetalRoutes) DeleteRoute(ctx context.Context, clusterName string, route *cloudprovider.Route) error { +func (o ironcoreRoutes) DeleteRoute(ctx context.Context, clusterName string, route *cloudprovider.Route) error { klog.V(2).InfoS("Deleting Route", "Cluster", clusterName, "Route", route) // get the machine object based on the node name nodeName := string(route.TargetNode) machine := &computev1alpha1.Machine{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: nodeName}, machine); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: nodeName}, machine); err != nil { if apierrors.IsNotFound(err) { return cloudprovider.InstanceNotFound } @@ -187,7 +187,7 @@ func (o onmetalRoutes) DeleteRoute(ctx context.Context, clusterName string, rout // get the network interface object networkInterfaceName := getNetworkInterfaceName(machine, networkInterface) nic := &networkingv1alpha1.NetworkInterface{} - if err := o.onmetalClient.Get(ctx, client.ObjectKey{Namespace: o.onmetalNamespace, Name: networkInterfaceName}, nic); err != nil { + if err := o.ironcoreClient.Get(ctx, client.ObjectKey{Namespace: o.ironcoreNamespace, Name: networkInterfaceName}, nic); err != nil { return err } @@ -198,7 +198,7 @@ func (o onmetalRoutes) DeleteRoute(ctx context.Context, clusterName string, rout nic.Spec.Prefixes = append(nic.Spec.Prefixes[:i], nic.Spec.Prefixes[i+1:]...) klog.V(2).InfoS("Prefix found and removed", "Prefix", prefix.Prefix.String(), "Prefixes after", nic.Spec.Prefixes) - if err := o.onmetalClient.Patch(ctx, nic, client.MergeFrom(nicBase)); err != nil { + if err := o.ironcoreClient.Patch(ctx, nic, client.MergeFrom(nicBase)); err != nil { return fmt.Errorf("failed to patch NetworkInterface %s for Node %s: %w", client.ObjectKeyFromObject(nic), nodeName, err) } @@ -225,7 +225,7 @@ func getNetworkInterfaceName(machine *computev1alpha1.Machine, networkInterface return fmt.Sprintf("%s-%s", machine.Name, networkInterface.Name) } -func (o onmetalRoutes) getTargetNodeAddresses(ctx context.Context, nodeName string) ([]corev1.NodeAddress, error) { +func (o ironcoreRoutes) getTargetNodeAddresses(ctx context.Context, nodeName string) ([]corev1.NodeAddress, error) { node := &corev1.Node{} if err := o.targetClient.Get(ctx, client.ObjectKey{Name: nodeName}, node); err != nil { return nil, fmt.Errorf("failed to get node object %s: %w", nodeName, err) diff --git a/pkg/cloudprovider/onmetal/routes_test.go b/pkg/cloudprovider/ironcore/routes_test.go similarity index 98% rename from pkg/cloudprovider/onmetal/routes_test.go rename to pkg/cloudprovider/ironcore/routes_test.go index 85c2c71..4193469 100644 --- a/pkg/cloudprovider/onmetal/routes_test.go +++ b/pkg/cloudprovider/ironcore/routes_test.go @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "fmt" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/pkg/cloudprovider/onmetal/suite_test.go b/pkg/cloudprovider/ironcore/suite_test.go similarity index 87% rename from pkg/cloudprovider/onmetal/suite_test.go rename to pkg/cloudprovider/ironcore/suite_test.go index 3863235..d030577 100644 --- a/pkg/cloudprovider/onmetal/suite_test.go +++ b/pkg/cloudprovider/ironcore/suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package onmetal +package ironcore import ( "context" @@ -38,16 +38,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/yaml" - "github.com/onmetal/controller-utils/buildutils" - "github.com/onmetal/controller-utils/modutils" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" - computev1alpha1 "github.com/onmetal/onmetal-api/api/compute/v1alpha1" - corev1alpha1 "github.com/onmetal/onmetal-api/api/core/v1alpha1" - ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" - networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" - storagev1alpha1 "github.com/onmetal/onmetal-api/api/storage/v1alpha1" - envtestext "github.com/onmetal/onmetal-api/utils/envtest" - "github.com/onmetal/onmetal-api/utils/envtest/apiserver" + "github.com/ironcore-dev/controller-utils/buildutils" + "github.com/ironcore-dev/controller-utils/modutils" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + corev1alpha1 "github.com/ironcore-dev/ironcore/api/core/v1alpha1" + ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1" + networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" + storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1" + envtestext "github.com/ironcore-dev/ironcore/utils/envtest" + "github.com/ironcore-dev/ironcore/utils/envtest/apiserver" ) var ( @@ -84,7 +84,7 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{} testEnvExt = &envtestext.EnvironmentExtensions{ APIServiceDirectoryPaths: []string{ - modutils.Dir("github.com/onmetal/onmetal-api", "config", "apiserver", "apiservice", "bases"), + modutils.Dir("github.com/ironcore-dev/ironcore", "config", "apiserver", "apiservice", "bases"), }, ErrorIfAPIServicePathIsMissing: true, } @@ -107,7 +107,7 @@ var _ = BeforeSuite(func() { SetClient(k8sClient) apiSrv, err := apiserver.New(cfg, apiserver.Options{ - MainPath: "github.com/onmetal/onmetal-api/cmd/onmetal-apiserver", + MainPath: "github.com/ironcore-dev/ironcore/cmd/ironcore-apiserver", BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod}, ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()}, Host: testEnvExt.APIServiceInstallOptions.LocalServingHost, @@ -116,7 +116,7 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - By("starting the onmetal-api aggregated api server") + By("starting the ironcore aggregated server") Expect(apiSrv.Start()).To(Succeed()) DeferCleanup(apiSrv.Stop) @@ -197,11 +197,11 @@ func SetupTest() (*corev1.Namespace, *cloudprovider.Interface, *networkingv1alph }() Expect(os.WriteFile(kubeconfigFile.Name(), namespacedKubeconfigData, 0666)).To(Succeed()) - curr := OnmetalKubeconfigPath + curr := IroncoreKubeconfigPath defer func() { - OnmetalKubeconfigPath = curr + IroncoreKubeconfigPath = curr }() - OnmetalKubeconfigPath = kubeconfigFile.Name() + IroncoreKubeconfigPath = kubeconfigFile.Name() cloudConfigFile, err := os.CreateTemp(GinkgoT().TempDir(), "cloud.yaml") Expect(err).NotTo(HaveOccurred())