Skip to content

Commit

Permalink
update unit test and docs
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Tiptur <[email protected]>
  • Loading branch information
Sachin Tiptur committed Dec 13, 2022
1 parent 6b4e8db commit d066d36
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ package-hosted directory like this:

```bash
cd cloud-controller-manager/cmd/digitalocean-cloud-controller-manager
REGION=fra1 DO_ACCESS_TOKEN=your_access_token go run main.go \
REGION=fra1 DO_ACCESS_TOKEN=your_access_token DO_IP_ADDR_FAMILIES=ipv4 go run main.go \
--kubeconfig <path to your kubeconfig file> \
--leader-elect=false --v=5 --cloud-provider=digitalocean
```
Expand All @@ -79,6 +79,11 @@ You might also need to provide your DigitalOcean access token in
the cloud controller to start, but in that case, you will not be able to
validate integration with DigitalOcean API.

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.

Please note that if you use a Kubernetes cluster created on DigitalOcean, there
will be a cloud controller manager running in the cluster already, so your local
one will compete for API access with it.
Expand Down
20 changes: 20 additions & 0 deletions cloud-controller-manager/do/droplets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ func newFakeDroplet() *godo.Droplet {
Type: "public",
},
},
V6: []godo.NetworkV6{
{
IPAddress: "2a01::10",
Type: "public",
},
},
},
Region: &godo.Region{
Name: "test-region",
Expand All @@ -143,6 +149,12 @@ func newFakeShutdownDroplet() *godo.Droplet {
Type: "public",
},
},
V6: []godo.NetworkV6{
{
IPAddress: "2a01::10",
Type: "public",
},
},
},
Region: &godo.Region{
Name: "test-region",
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion docs/controllers/node/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions docs/example-manifests/cloud-controller-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ spec:
secretKeyRef:
name: digitalocean
key: access-token
- name: DO_IP_ADDR_FAMILIES
value: ipv4,ipv6

---
apiVersion: v1
Expand Down

0 comments on commit d066d36

Please sign in to comment.