Skip to content

Commit

Permalink
use v1beta1 CRD for capo resources (#446)
Browse files Browse the repository at this point in the history
* use v1beta1 CRD for capo resources

* set placeholders for required fields

---------

Co-authored-by: okozachenko1203 <[email protected]>
  • Loading branch information
okozachenko1203 and okozachenko1203 authored Oct 30, 2024
1 parent bdd8e30 commit 8e375c4
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 42 deletions.
2 changes: 1 addition & 1 deletion magnum_cluster_api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def update_nodegroups_status(
}
image_id_match = all(
[
machine.obj["spec"]["imageUUID"] == md_variables["imageUUID"]
machine.obj["spec"]["image"]["id"] == md_variables["imageUUID"]
for machine in machines
]
)
Expand Down
8 changes: 4 additions & 4 deletions magnum_cluster_api/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ClusterResourceSet(NamespacedAPIObject):


class OpenStackMachineTemplate(NamespacedAPIObject):
version = "infrastructure.cluster.x-k8s.io/v1alpha7"
version = "infrastructure.cluster.x-k8s.io/v1beta1"
endpoint = "openstackmachinetemplates"
kind = "OpenStackMachineTemplate"

Expand Down Expand Up @@ -157,13 +157,13 @@ class Machine(NamespacedAPIObject):


class OpenStackClusterTemplate(NamespacedAPIObject):
version = "infrastructure.cluster.x-k8s.io/v1alpha7"
version = "infrastructure.cluster.x-k8s.io/v1beta1"
endpoint = "openstackclustertemplates"
kind = "OpenStackClusterTemplate"


class OpenStackCluster(NamespacedAPIObject):
version = "infrastructure.cluster.x-k8s.io/v1alpha7"
version = "infrastructure.cluster.x-k8s.io/v1beta1"
endpoint = "openstackclusters"
kind = "OpenStackCluster"

Expand Down Expand Up @@ -295,7 +295,7 @@ def openstack_cluster(self):


class OpenStackMachine(NamespacedAPIObject):
version = "infrastructure.cluster.x-k8s.io/v1alpha7"
version = "infrastructure.cluster.x-k8s.io/v1beta1"
endpoint = "openstackmachines"
kind = "OpenStackMachine"

Expand Down
90 changes: 53 additions & 37 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
CLUSTER_CLASS_NODE_VOLUME_DETACH_TIMEOUT = "300s" # seconds

PLACEHOLDER = "PLACEHOLDER"
PLACEHOLDER_UUID = "00000000-0000-0000-0000-000000000000"

AUTOSCALE_ANNOTATION_MIN = "cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size"
AUTOSCALE_ANNOTATION_MAX = "cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size"
Expand Down Expand Up @@ -803,7 +804,13 @@ def get_object(self) -> objects.OpenStackMachineTemplate:
"spec": {
"template": {
"spec": {
"cloudName": "default",
"image": {
"id": PLACEHOLDER_UUID,
},
"identityRef": {
"name": PLACEHOLDER,
"cloudName": "default",
},
"flavor": PLACEHOLDER,
}
}
Expand All @@ -826,9 +833,13 @@ def get_object(self) -> objects.OpenStackClusterTemplate:
"spec": {
"template": {
"spec": {
"cloudName": "default",
"managedSecurityGroups": True,
"allowAllInClusterTraffic": True,
"identityRef": {
"name": PLACEHOLDER,
"cloudName": "default",
},
"managedSecurityGroups": {
"allowAllInClusterTraffic": True,
},
},
},
},
Expand Down Expand Up @@ -1037,19 +1048,11 @@ def get_object(self) -> objects.ClusterClass:
},
},
{
"name": "clusterIdentityRef",
"name": "clusterIdentityRefName",
"required": True,
"schema": {
"openAPIV3Schema": {
"type": "object",
"required": ["kind", "name"],
"properties": {
"kind": {
"type": "string",
"enum": [pykube.Secret.kind],
},
"name": {"type": "string"},
},
"type": "string",
},
},
},
Expand Down Expand Up @@ -1470,8 +1473,8 @@ def get_object(self) -> objects.ClusterClass:
"valueFrom": {
"template": textwrap.dedent(
"""\
diskSize: {{ .bootVolume.size }}
volumeType: {{ .bootVolume.type }}
sizeGiB: {{ .bootVolume.size }}
type: {{ .bootVolume.type }}
"""
),
},
Expand Down Expand Up @@ -1736,10 +1739,10 @@ def get_object(self) -> objects.ClusterClass:
},
"jsonPatches": [
{
"op": "add",
"path": "/spec/template/spec/identityRef",
"op": "replace",
"path": "/spec/template/spec/identityRef/name",
"valueFrom": {
"variable": "clusterIdentityRef"
"variable": "clusterIdentityRefName"
},
},
{
Expand All @@ -1748,8 +1751,8 @@ def get_object(self) -> objects.ClusterClass:
"valueFrom": {"variable": "sshKeyName"},
},
{
"op": "add",
"path": "/spec/template/spec/imageUUID",
"op": "replace",
"path": "/spec/template/spec/image/id",
"valueFrom": {"variable": "imageUUID"},
},
],
Expand All @@ -1772,9 +1775,9 @@ def get_object(self) -> objects.ClusterClass:
},
{
"op": "add",
"path": "/spec/template/spec/identityRef",
"path": "/spec/template/spec/identityRef/name",
"valueFrom": {
"variable": "clusterIdentityRef"
"variable": "clusterIdentityRefName"
},
},
{
Expand All @@ -1786,14 +1789,24 @@ def get_object(self) -> objects.ClusterClass:
},
{
"op": "add",
"path": "/spec/template/spec/dnsNameservers",
"valueFrom": {"variable": "dnsNameservers"},
"path": "/spec/template/spec/managedSubnets",
"valueFrom": {
"template": textwrap.dedent(
"""\
- dnsNameservers: {{ .dnsNameservers }}
"""
),
},
},
{
"op": "add",
"path": "/spec/template/spec/externalNetworkId",
"path": "/spec/template/spec/externalNetwork",
"valueFrom": {
"variable": "externalNetworkId"
"template": textwrap.dedent(
"""\
id: {{ .externalNetworkId }}
"""
),
},
},
],
Expand Down Expand Up @@ -1839,7 +1852,7 @@ def get_object(self) -> objects.ClusterClass:
"jsonPatches": [
{
"op": "add",
"path": "/spec/template/spec/nodeCidr",
"path": "/spec/template/spec/managedSubnets/0/cidr",
"valueFrom": {"variable": "nodeCidr"},
},
],
Expand Down Expand Up @@ -1885,8 +1898,14 @@ def get_object(self) -> objects.ClusterClass:
"jsonPatches": [
{
"op": "add",
"path": "/spec/template/spec/subnet/id",
"valueFrom": {"variable": "fixedSubnetId"},
"path": "/spec/template/spec/subnets",
"valueFrom": {
"template": textwrap.dedent(
"""\
- id: {{ .fixedSubnetId }}
"""
),
},
},
],
},
Expand Down Expand Up @@ -2572,13 +2591,10 @@ def get_object(self) -> objects.Cluster:
},
},
{
"name": "clusterIdentityRef",
"value": {
"kind": pykube.Secret.kind,
"name": utils.get_cluster_api_cloud_config_secret_name(
self.cluster
),
},
"name": "clusterIdentityRefName",
"value": utils.get_cluster_api_cloud_config_secret_name(
self.cluster
),
},
{
"name": "cloudCaCert",
Expand Down

0 comments on commit 8e375c4

Please sign in to comment.