Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ionos-cloud/cluster-api-provider-io…
Browse files Browse the repository at this point in the history
…noscloud into CAPI-101/document_ccm_installation
  • Loading branch information
schegi committed May 2, 2024
2 parents 11e924f + dd3f67e commit 3181522
Show file tree
Hide file tree
Showing 22 changed files with 264 additions and 134 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha1/ionoscloudcluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ var _ = Describe("IonosCloudCluster", func() {
It("should allow creating valid clusters", func() {
Expect(k8sClient.Create(context.Background(), defaultCluster())).To(Succeed())
})
It("should work with a FQDN controlplane endpoint", func() {
cluster := defaultCluster()
cluster.Spec.ControlPlaneEndpoint.Host = "example.org"
Expect(k8sClient.Create(context.Background(), cluster)).To(Succeed())
})
It("should not allow creating clusters with empty credential secret", func() {
cluster := defaultCluster()
cluster.Spec.CredentialsRef.Name = ""
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/ionoscloudmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ type IonosCloudMachineSpec struct {
//
// If the machine is a control plane machine, this field will not be taken into account.
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="failoverIP is immutable"
//+kubebuilder:validation:XValidation:rule=`self == "" || self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")`,message="failoverIP must be either 'AUTO' or a valid IPv4 address"
//+kubebuilder:validation:XValidation:rule=`self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")`,message="failoverIP must be either 'AUTO' or a valid IPv4 address"
//+optional
FailoverIP string `json:"failoverIP"`
FailoverIP *string `json:"failoverIP,omitempty"`
}

// Networks contains a list of additional LAN IDs
Expand Down
24 changes: 12 additions & 12 deletions api/v1alpha1/ionoscloudmachine_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,24 +342,24 @@ var _ = Describe("IonosCloudMachine Tests", func() {
Context("FailoverIP", func() {
It("should allow setting AUTO as the value", func() {
m := defaultMachine()
m.Spec.FailoverIP = CloudResourceConfigAuto
m.Spec.FailoverIP = ptr.To(CloudResourceConfigAuto)
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal(CloudResourceConfigAuto))
Expect(m.Spec.FailoverIP).To(Equal(ptr.To(CloudResourceConfigAuto)))
})
It("should allow setting a valid IPv4 address", func() {
m := defaultMachine()
m.Spec.FailoverIP = "203.0.113.1"
m.Spec.FailoverIP = ptr.To("203.0.113.1")
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal("203.0.113.1"))
Expect(m.Spec.FailoverIP).To(Equal(ptr.To("203.0.113.1")))
})
It("should allow setting empty string", func() {
It("should allow setting null", func() {
m := defaultMachine()
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal(""))
Expect(m.Spec.FailoverIP).To(BeNil())
})
DescribeTable("should not allow setting invalid IPv4 addresses", func(ip string) {
m := defaultMachine()
m.Spec.FailoverIP = ip
m.Spec.FailoverIP = &ip
Expect(k8sClient.Create(context.Background(), m)).ToNot(Succeed())
},
Entry("IPv4 out of range", "203.0.113.256"),
Expand All @@ -370,17 +370,17 @@ var _ = Describe("IonosCloudMachine Tests", func() {
)
It("should require AUTO to be in capital letters", func() {
m := defaultMachine()
m.Spec.FailoverIP = "Auto"
m.Spec.FailoverIP = ptr.To("Auto")
Expect(k8sClient.Create(context.Background(), m)).ToNot(Succeed())
})
It("should be immutable", func() {
m := defaultMachine()
m.Spec.FailoverIP = "AUTO"
m.Spec.FailoverIP = ptr.To(CloudResourceConfigAuto)
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal("AUTO"))
m.Spec.FailoverIP = "127.0.0.1"
Expect(m.Spec.FailoverIP).To(Equal(ptr.To(CloudResourceConfigAuto)))
m.Spec.FailoverIP = ptr.To("127.0.0.1")
Expect(k8sClient.Update(context.Background(), m)).ToNot(Succeed())
m.Spec.FailoverIP = ""
m.Spec.FailoverIP = ptr.To("")
Expect(k8sClient.Update(context.Background(), m)).ToNot(Succeed())
})
})
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ spec:
- message: failoverIP is immutable
rule: self == oldSelf
- message: failoverIP must be either 'AUTO' or a valid IPv4 address
rule: self == "" || self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
rule: self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
memoryMB:
default: 3072
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ spec:
rule: self == oldSelf
- message: failoverIP must be either 'AUTO' or a valid IPv4
address
rule: self == "" || self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
rule: self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
memoryMB:
default: 3072
description: |-
Expand Down
20 changes: 12 additions & 8 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@ clusterctl init --infrastructure=ionoscloud
CAPIC requires several environment variables to be set in order to create a Kubernetes cluster on IONOS Cloud.

```env
## -- Cloud specific environment variables -- ##
## -- Cloud-specific environment variables -- ##
IONOS_TOKEN # The token of the IONOS Cloud account.
IONOS_API_URL # The API URL of the IONOS Cloud account.
# Defaults to https://api.ionos.com/cloudapi/v6
## -- Cluster API related environment variables -- ##
CONTROL_PLANE_ENDPOINT_IP # The IP address of the control plane endpoint.
CONTROL_PLANE_ENDPOINT_PORT # The port of the control plane endpoint.
IONOS_API_URL # The API URL of the IONOS Cloud account (optional).
# Defaults to https://api.ionos.com/cloudapi/v6.
## -- Cluster API-related environment variables -- ##
CONTROL_PLANE_ENDPOINT_HOST # The control plane endpoint host (optional).
# If it's not an IP but an FQDN, the provider must be able to resolve it
# to the value for CONTROL_PLANE_ENDPOINT_IP.
CONTROL_PLANE_ENDPOINT_IP # The IPv4 address of the control plane endpoint.
CONTROL_PLANE_ENDPOINT_PORT # The port of the control plane endpoint (optional).
# Defaults to 6443.
CONTROL_PLANE_ENDPOINT_LOCATION # The location of the control plane endpoint.
CLUSTER_NAME # The name of the cluster.
KUBERNETES_VERSION # The version of Kubernetes to be installed (can also be set via clusterctl).
## -- Kubernetes Cluster related environment variables -- ##
## -- Kubernetes Cluster-related environment variables -- ##
IONOSCLOUD_CONTRACT_NUMBER # The contract number of the IONOS Cloud contract.
IONOSCLOUD_DATACENTER_ID # The datacenter ID where the cluster should be created.
IONOSCLOUD_MACHINE_NUM_CORES # The number of cores.
Expand Down
1 change: 1 addition & 0 deletions envfile.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export IONOS_API_URL="https://api.ionos.com/cloudapi/v6"


# Cluster API related environment variables
export CONTROL_PLANE_ENDPOINT_HOST="example.org"
export CONTROL_PLANE_ENDPOINT_IP="192.168.0.1"
export CONTROL_PLANE_ENDPOINT_PORT=6443
export CONTROL_PLANE_ENDPOINT_LOCATION="de/txl"
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ require (
github.com/ionos-cloud/sdk-go/v6 v6.1.11
github.com/jarcoal/httpmock v1.3.1
github.com/onsi/ginkgo/v2 v2.17.2
github.com/onsi/gomega v1.33.0
github.com/onsi/gomega v1.33.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
k8s.io/api v0.29.4
k8s.io/apimachinery v0.29.4
k8s.io/client-go v0.29.4
k8s.io/klog/v2 v2.110.1
sigs.k8s.io/cluster-api v1.6.3
k8s.io/klog/v2 v2.120.1
sigs.k8s.io/cluster-api v1.7.1
sigs.k8s.io/controller-runtime v0.17.3
)

Expand All @@ -29,8 +29,8 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down Expand Up @@ -78,25 +78,25 @@ require (
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/apiserver v0.29.2 // indirect
k8s.io/component-base v0.29.2 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/apiserver v0.29.3 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect
Expand Down
Loading

0 comments on commit 3181522

Please sign in to comment.