Skip to content

Commit

Permalink
Add AvailabilityZones field (#92)
Browse files Browse the repository at this point in the history
* Add AvailabilityZones field

* Update db test

* Update swagger

---------

Co-authored-by: aalexand <[email protected]>
  • Loading branch information
aalexandru and aalexand authored Dec 5, 2023
1 parent 69aa011 commit a0832c4
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 2 deletions.
12 changes: 12 additions & 0 deletions config/crd/bases/registry.ethos.adobe.com_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ spec:
- certificateAuthorityData
- endpoint
type: object
availabilityZones:
description: AvailabilityZones cluster availability zones
items:
properties:
id:
type: string
name:
type: string
required:
- name
type: object
type: array
businessUnit:
description: The BU that owns the cluster
type: string
Expand Down
7 changes: 7 additions & 0 deletions local/client/dummy-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ spec:
taints:
- workload=memory-optimized:NoSchedule
accountId: "11111-2222-3333-4444-555555555"
availabilityZones:
- name: us-east-1a
id: use1-az1
- name: us-east-1b
id: use1-az2
- name: us-east-1c
id: use1-az3
virtualNetworks:
- id: "/subscriptions/11111-2222-3333-4444-555555555/resourceGroups/cluster01_local_network/providers/Microsoft.Network/virtualNetworks/cluster01_local_useast1-vnet/subnets/cluster01_local_useast1_master_network_10_0_0_0_24"
cidrs:
Expand Down
7 changes: 7 additions & 0 deletions local/database/dummy-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@
clusterCapacity: 30
clusterProvisioning: 30
lastUpdated: "2023-03-22T11:55:41Z"
availabilityZones:
- name: us-east-1a
id: use1-az1
- name: us-east-1b
id: use1-az2
- name: us-east-1c
id: use1-az3
status: Active
phase: Running
tags:
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/registry/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ type ClusterSpec struct {

// ServiceMetadata service specific metadata
ServiceMetadata ServiceMetadata `json:"services,omitempty"`

// AvailabilityZones cluster availability zones
AvailabilityZones []AvailabilityZone `json:"availabilityZones,omitempty"`
}

// Offering the cluster is meant for
Expand Down Expand Up @@ -255,6 +258,11 @@ type ServiceMetadataItem map[string]ServiceMetadataMap

type ServiceMetadataMap map[string]string

type AvailabilityZone struct {
Name string `json:"name"`
ID string `json:"id,omitempty"`
}

// ClusterStatus defines the observed state of Cluster
type ClusterStatus struct {
// Send/Receive Errors
Expand Down
20 changes: 20 additions & 0 deletions pkg/api/registry/v1/zz_generated.deepcopy.go

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

18 changes: 18 additions & 0 deletions pkg/apiserver/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,17 @@ const docTemplate = `{
}
}
},
"github_com_adobe_cluster-registry_pkg_api_registry_v1.AvailabilityZone": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"github_com_adobe_cluster-registry_pkg_api_registry_v1.Capacity": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -504,6 +515,13 @@ const docTemplate = `{
}
]
},
"availabilityZones": {
"description": "AvailabilityZones cluster availability zones",
"type": "array",
"items": {
"$ref": "#/definitions/github_com_adobe_cluster-registry_pkg_api_registry_v1.AvailabilityZone"
}
},
"businessUnit": {
"description": "The BU that owns the cluster\n+kubebuilder:validation:Required",
"type": "string"
Expand Down
18 changes: 18 additions & 0 deletions pkg/apiserver/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,17 @@
}
}
},
"github_com_adobe_cluster-registry_pkg_api_registry_v1.AvailabilityZone": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"github_com_adobe_cluster-registry_pkg_api_registry_v1.Capacity": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -502,6 +513,13 @@
}
]
},
"availabilityZones": {
"description": "AvailabilityZones cluster availability zones",
"type": "array",
"items": {
"$ref": "#/definitions/github_com_adobe_cluster-registry_pkg_api_registry_v1.AvailabilityZone"
}
},
"businessUnit": {
"description": "The BU that owns the cluster\n+kubebuilder:validation:Required",
"type": "string"
Expand Down
12 changes: 12 additions & 0 deletions pkg/apiserver/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ definitions:
+kubebuilder:validation:Required
type: string
type: object
github_com_adobe_cluster-registry_pkg_api_registry_v1.AvailabilityZone:
properties:
id:
type: string
name:
type: string
type: object
github_com_adobe_cluster-registry_pkg_api_registry_v1.Capacity:
properties:
clusterCapacity:
Expand Down Expand Up @@ -57,6 +64,11 @@ definitions:
description: |-
Information about K8s API endpoint and CA cert
+kubebuilder:validation:Required
availabilityZones:
description: AvailabilityZones cluster availability zones
items:
$ref: '#/definitions/github_com_adobe_cluster-registry_pkg_api_registry_v1.AvailabilityZone'
type: array
businessUnit:
description: |-
The BU that owns the cluster
Expand Down
46 changes: 44 additions & 2 deletions pkg/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,22 @@ var _ = Describe("Database Suite", func() {
Phase: "Running",
Type: "Dedicated",
Capabilities: []string{"gpu-compute"},
LastUpdated: "2020-03-20T07:55:46.132Z",
Tags: map[string]string{"onboarding": "on", "scaling": "on"},
AvailabilityZones: []registryv1.AvailabilityZone{
{
Name: "us-east-1a",
ID: "use1-az1",
},
{
Name: "us-east-1b",
ID: "use1-az2",
},
{
Name: "us-east-1c",
ID: "use1-az3",
},
},
LastUpdated: "2020-03-20T07:55:46.132Z",
Tags: map[string]string{"onboarding": "on", "scaling": "on"},
},
},
},
Expand Down Expand Up @@ -1106,6 +1120,20 @@ var _ = Describe("Database Suite", func() {
Capabilities: []string{"gpu-compute"},
LastUpdated: "2020-03-20T07:55:46.132Z",
Tags: map[string]string{"onboarding": "on", "scaling": "on"},
AvailabilityZones: []registryv1.AvailabilityZone{
{
Name: "us-east-1a",
ID: "use1-az1",
},
{
Name: "us-east-1b",
ID: "use1-az2",
},
{
Name: "us-east-1c",
ID: "use1-az3",
},
},
},
},
},
Expand Down Expand Up @@ -1427,6 +1455,20 @@ var _ = Describe("Database Suite", func() {
Capabilities: []string{"gpu-compute"},
LastUpdated: "2020-03-20T07:55:46.132Z",
Tags: map[string]string{"onboarding": "on", "scaling": "on"},
AvailabilityZones: []registryv1.AvailabilityZone{
{
Name: "us-east-1a",
ID: "use1-az1",
},
{
Name: "us-east-1b",
ID: "use1-az2",
},
{
Name: "us-east-1c",
ID: "use1-az3",
},
},
},
},
},
Expand Down
7 changes: 7 additions & 0 deletions pkg/database/testdata/clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,10 @@
tags:
onboarding: "on"
scaling: "on"
availabilityZones:
- name: us-east-1a
id: use1-az1
- name: us-east-1b
id: use1-az2
- name: us-east-1c
id: use1-az3

0 comments on commit a0832c4

Please sign in to comment.