From 14215b884b93435763b25f8b6da07954bd8c3b71 Mon Sep 17 00:00:00 2001 From: Sachin Tiptur Date: Tue, 13 Dec 2022 11:45:50 +0100 Subject: [PATCH] update unit test and docs Signed-off-by: Sachin Tiptur --- README.md | 6 ++++++ cloud-controller-manager/do/droplets_test.go | 20 +++++++++++++++++++ docs/controllers/node/examples/README.md | 4 +++- .../cloud-controller-manager.yml | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 86471c96b..905bdbc55 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ endpoint that will expose them. The command will look similar to this: cd cloud-controller-manager/cmd/digitalocean-cloud-controller-manager DO_ACCESS_TOKEN=your_access_token \ METRICS_ADDR=: \ +DO_IP_ADDR_FAMILIES=ipv4 \ digitalocean-cloud-controller-manager \ --kubeconfig \ --leader-elect=false --v=5 --cloud-provider=digitalocean @@ -145,6 +146,11 @@ The `METRICS_ADDR` environment variable takes a valid endpoint that you'd like to use to serve your Prometheus metrics. To be valid it should be in the form `:`. +The `DO_IP_ADDR_FAMILIES` is used to configure the required IP familes and the +order in which address should be populated in nodes status. The accepted values +are one of the `{"", "ipv4", "ipv6", "ipv4,ipv6", "ipv6,ipv4"}`.IPv4 is the +default, if not set or empty. + After you have started up `digitalocean-cloud-controller-manager`, run the following curl command to view the Prometheus metrics output: diff --git a/cloud-controller-manager/do/droplets_test.go b/cloud-controller-manager/do/droplets_test.go index d73a9b4da..d8862c584 100644 --- a/cloud-controller-manager/do/droplets_test.go +++ b/cloud-controller-manager/do/droplets_test.go @@ -118,6 +118,12 @@ func newFakeDroplet() *godo.Droplet { Type: "public", }, }, + V6: []godo.NetworkV6{ + { + IPAddress: "2a01::10", + Type: "public", + }, + }, }, Region: &godo.Region{ Name: "test-region", @@ -143,6 +149,12 @@ func newFakeShutdownDroplet() *godo.Droplet { Type: "public", }, }, + V6: []godo.NetworkV6{ + { + IPAddress: "2a01::10", + Type: "public", + }, + }, }, Region: &godo.Region{ Name: "test-region", @@ -186,6 +198,10 @@ func TestNodeAddresses(t *testing.T) { Type: v1.NodeExternalIP, Address: "99.99.99.99", }, + { + Type: "public", + Address: "2a01::10", + }, } addresses, err := instances.NodeAddresses(context.TODO(), "test-droplet") @@ -222,6 +238,10 @@ func TestNodeAddressesByProviderID(t *testing.T) { Type: v1.NodeExternalIP, Address: "99.99.99.99", }, + { + Type: "public", + Address: "2a01::10", + }, } addresses, err := instances.NodeAddressesByProviderID(context.TODO(), "digitalocean://123") diff --git a/docs/controllers/node/examples/README.md b/docs/controllers/node/examples/README.md index aaf5cc30f..c1034389b 100644 --- a/docs/controllers/node/examples/README.md +++ b/docs/controllers/node/examples/README.md @@ -68,6 +68,8 @@ status: type: InternalIP - address: 138.197.174.81 type: ExternalIP + - address: 2a03:b0c0:3:d0::e68:a001 + type: ExternalIP allocatable: cpu: "4" memory: 6012700Ki @@ -80,7 +82,7 @@ status: DigitalOcean cloud controller manager has made the cluster aware of the size of the node, in this case c-4 (4 core high CPU droplet). It has also assigned the node a failure domain which the scheduler can use for region failovers. Note also that the correct addresses were assigned to the node. The `InternalIP` now represents -the private IP of the droplet, and the `ExternalIP` is it's public IP. +the private IP of the droplet, and the `ExternalIP` is it's public IP. The order and IP families depends on the env variable `DO_IP_ADDR_FAMILIES`. ## Node clean up diff --git a/docs/example-manifests/cloud-controller-manager.yml b/docs/example-manifests/cloud-controller-manager.yml index cb82c126e..d76b456de 100644 --- a/docs/example-manifests/cloud-controller-manager.yml +++ b/docs/example-manifests/cloud-controller-manager.yml @@ -66,6 +66,8 @@ spec: secretKeyRef: name: digitalocean key: access-token + - name: DO_IP_ADDR_FAMILIES + value: ipv4,ipv6 --- apiVersion: v1