Skip to content

Commit 3763817

Browse files
authored
Feat/k8s node group anti-affinity (#206)
1 parent 98ac549 commit 3763817

15 files changed

Lines changed: 444 additions & 694 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
55

66
## [Unreleased]
77

8+
### Added
9+
- kubernetes: experimental support for anti-affinity node groups
10+
811
## [5.3.1]
912

1013
### Deprecated

upcloud/kubernetes.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ type KubernetesCluster struct {
3030
}
3131

3232
type KubernetesNodeGroup struct {
33-
Count int `json:"count,omitempty"`
34-
Labels []Label `json:"labels,omitempty"`
35-
Name string `json:"name,omitempty"`
36-
Plan string `json:"plan,omitempty"`
37-
SSHKeys []string `json:"ssh_keys,omitempty"`
38-
Storage string `json:"storage,omitempty"`
39-
KubeletArgs []KubernetesKubeletArg `json:"kubelet_args,omitempty"`
40-
Taints []KubernetesTaint `json:"taints,omitempty"`
33+
Count int `json:"count,omitempty"`
34+
Labels []Label `json:"labels,omitempty"`
35+
Name string `json:"name,omitempty"`
36+
Plan string `json:"plan,omitempty"`
37+
SSHKeys []string `json:"ssh_keys,omitempty"`
38+
Storage string `json:"storage,omitempty"`
39+
KubeletArgs []KubernetesKubeletArg `json:"kubelet_args,omitempty"`
40+
Taints []KubernetesTaint `json:"taints,omitempty"`
41+
AntiAffinity bool `json:"anti_affinity,omitempty"`
4142
}
4243

4344
type KubernetesKubeletArg struct {

upcloud/kubernetes_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const exampleKubernetesClusterJSON string = `{
1919
"name": "upcloud-go-sdk-unit-test",
2020
"plan": "K8S-2xCPU-4GB",
2121
"count": 1,
22+
"anti_affinity": true,
2223
"labels": [
2324
{
2425
"key": "managedBy",
@@ -44,6 +45,7 @@ const exampleKubernetesClusterJSON string = `{
4445
"name": "upcloud-go-sdk-unit-test",
4546
"plan": "K8S-2xCPU-4GB",
4647
"count": 1,
48+
"anti_affinity": false,
4749
"labels": [
4850
{
4951
"key": "managedBy",
@@ -95,16 +97,16 @@ func exampleKubernetesCluster() KubernetesCluster {
9597
Network: "03a98be3-7daa-443f-bb25-4bc6854b396c",
9698
NetworkCIDR: "172.16.0.0/24",
9799
NodeGroups: []KubernetesNodeGroup{
98-
exampleKubernetesNodeGroup(),
99-
exampleKubernetesNodeGroup(),
100+
exampleKubernetesNodeGroup(true),
101+
exampleKubernetesNodeGroup(false),
100102
},
101103
State: KubernetesClusterStateRunning,
102104
UUID: "0ddab8f4-97c0-4222-91ba-85a4fff7499b",
103105
Zone: "de-fra1",
104106
}
105107
}
106108

107-
func exampleKubernetesNodeGroup() KubernetesNodeGroup {
109+
func exampleKubernetesNodeGroup(antiAffinity bool) KubernetesNodeGroup {
108110
return KubernetesNodeGroup{
109111
Count: 1,
110112
Labels: []Label{
@@ -113,8 +115,9 @@ func exampleKubernetesNodeGroup() KubernetesNodeGroup {
113115
Value: "upcloud-go-sdk-unit-test",
114116
},
115117
},
116-
Name: "upcloud-go-sdk-unit-test",
117-
Plan: "K8S-2xCPU-4GB",
118+
Name: "upcloud-go-sdk-unit-test",
119+
AntiAffinity: antiAffinity,
120+
Plan: "K8S-2xCPU-4GB",
118121
KubeletArgs: []KubernetesKubeletArg{
119122
{
120123
Key: "somekubeletkey",

upcloud/request/kubernetes.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ func (r *GetKubernetesNodeGroupRequest) RequestURL() string {
114114
}
115115

116116
type KubernetesNodeGroup struct {
117-
Count int `json:"count,omitempty"`
118-
Labels []upcloud.Label `json:"labels,omitempty"`
119-
Name string `json:"name,omitempty"`
120-
Plan string `json:"plan,omitempty"`
121-
SSHKeys []string `json:"ssh_keys,omitempty"`
122-
Storage string `json:"storage,omitempty"`
123-
KubeletArgs []upcloud.KubernetesKubeletArg `json:"kubelet_args,omitempty"`
124-
Taints []upcloud.KubernetesTaint `json:"taints,omitempty"`
117+
Count int `json:"count,omitempty"`
118+
Labels []upcloud.Label `json:"labels,omitempty"`
119+
Name string `json:"name,omitempty"`
120+
Plan string `json:"plan,omitempty"`
121+
SSHKeys []string `json:"ssh_keys,omitempty"`
122+
Storage string `json:"storage,omitempty"`
123+
KubeletArgs []upcloud.KubernetesKubeletArg `json:"kubelet_args,omitempty"`
124+
Taints []upcloud.KubernetesTaint `json:"taints,omitempty"`
125+
AntiAffinity bool `json:"anti_affinity,omitempty"`
125126
}
126127

127128
type CreateKubernetesNodeGroupRequest struct {

upcloud/request/kubernetes_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func TestCreateKubernetesNodeGroupRequest(t *testing.T) {
240240
const expectedJSON string = `
241241
{
242242
"count": 4,
243+
"anti_affinity": true,
243244
"kubelet_args": [
244245
{
245246
"key": "log-flush-frequency",
@@ -270,7 +271,8 @@ func TestCreateKubernetesNodeGroupRequest(t *testing.T) {
270271
r := CreateKubernetesNodeGroupRequest{
271272
ClusterUUID: "id",
272273
NodeGroup: KubernetesNodeGroup{
273-
Count: 4,
274+
Count: 4,
275+
AntiAffinity: true,
274276
Labels: []upcloud.Label{
275277
{
276278
Key: "environment",

upcloud/service/fixtures/create_kubernetes_cluster.yaml

Lines changed: 0 additions & 107 deletions
This file was deleted.

upcloud/service/fixtures/create_kubernetes_private_network.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.

upcloud/service/fixtures/delete_kubernetes_cluster.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

upcloud/service/fixtures/delete_kubernetes_private_network.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

upcloud/service/fixtures/get_kubernetes_cluster.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)