diff --git a/charts/openstack-cluster/templates/_helpers.tpl b/charts/openstack-cluster/templates/_helpers.tpl index f370a3c0a..b8903a7f6 100644 --- a/charts/openstack-cluster/templates/_helpers.tpl +++ b/charts/openstack-cluster/templates/_helpers.tpl @@ -134,6 +134,43 @@ nodeRegistration: node-labels: "{{ range $i, $k := (keys . | sortAlpha) }}{{ if ne $i 0 }},{{ end }}{{ $k }}={{ index $ $k }}{{ end }}" {{- end }} +{{/* +Converts the tags in a Neutron filter when required. +*/}} +{{- define "openstack-cluster.convert.tags" -}} +{{- if kindIs "string" . -}} +{{- splitList "," . | toYaml }} +{{- else -}} +{{- toYaml . }} +{{- end }} +{{- end }} + +{{/* +Converts a v1alpha7 Neutron filter to a v1beta1 filter. +*/}} +{{- define "openstack-cluster.convert.neutronFilter" -}} +{{- if hasKey . "id" -}} +id: {{ .id }} +{{- else -}} +filter: + {{- with omit . "tags" "tagsAny" "notTags" "notTagsAny" }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .tags }} + tags: {{ include "openstack-cluster.convert.tags" . | nindent 4 }} + {{- end }} + {{- with .tagsAny }} + tagsAny: {{ include "openstack-cluster.convert.tags" . | nindent 4 }} + {{- end }} + {{- with .notTags }} + notTags: {{ include "openstack-cluster.convert.tags" . | nindent 4 }} + {{- end }} + {{- with .notTagsAny }} + notTagsAny: {{ include "openstack-cluster.convert.tags" . | nindent 4 }} + {{- end }} +{{- end }} +{{- end }} + {{/* Outputs the content for a containerd registry file containing mirror configuration. */}} diff --git a/charts/openstack-cluster/templates/cluster-openstack.yaml b/charts/openstack-cluster/templates/cluster-openstack.yaml index 71153dc68..3de1e2f7a 100644 --- a/charts/openstack-cluster/templates/cluster-openstack.yaml +++ b/charts/openstack-cluster/templates/cluster-openstack.yaml @@ -1,5 +1,5 @@ --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OpenStackCluster metadata: name: {{ include "openstack-cluster.clusterName" . }} @@ -11,31 +11,35 @@ metadata: # NOTE: Argo won't delete this object itself as it has an owner reference to the cluster spec: identityRef: - kind: Secret name: {{ include "openstack-cluster.cloudCredentialsSecretName" . }} - cloudName: openstack + cloudName: openstack {{- with .Values.controlPlaneEndpoint }} controlPlaneEndpoint: {{ toYaml . | nindent 4 }} {{- end }} {{- with .Values.clusterNetworking }} - {{- with .dnsNameservers }} - dnsNameservers: {{ toYaml . | nindent 4 }} + {{- if .manageSecurityGroups }} + managedSecurityGroups: + allowAllInClusterTraffic: {{ .allowAllInClusterTraffic }} {{- end }} - managedSecurityGroups: {{ .manageSecurityGroups }} - allowAllInClusterTraffic: {{ .allowAllInClusterTraffic }} {{- with .externalNetworkId }} - externalNetworkId: {{ . }} + externalNetwork: + id: {{ . }} {{- end }} {{- with .internalNetwork }} {{- if or .networkFilter .subnetFilter }} {{- with .networkFilter }} - network: {{ . | toYaml | nindent 4 }} + network: {{ include "openstack-cluster.convert.neutronFilter" . | nindent 4 }} {{- end }} {{- with .subnetFilter }} - subnet: {{ . | toYaml | nindent 4 }} + subnets: + - {{ include "openstack-cluster.convert.neutronFilter" . | nindent 6 }} {{- end }} {{- else }} - nodeCidr: {{ .nodeCidr }} + managedSubnets: + - cidr: {{ .nodeCidr }} + {{- with .dnsNameservers }} + dnsNameservers: {{ toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- end }} {{- end }} @@ -43,17 +47,16 @@ spec: {{- if .enableLoadBalancer }} apiServerLoadBalancer: enabled: true - {{- if .loadBalancerProvider }} + {{- if .loadBalancerProvider }} provider: {{ .loadBalancerProvider }} - {{- end }} - {{- if .allowedCidrs }} + {{- end }} + {{- if .allowedCidrs }} allowedCidrs: {{- range .allowedCidrs }} - {{ . }} {{- end}} + {{- end }} {{- end }} - {{- end }} - disableAPIServerFloatingIP: {{ not .associateFloatingIP }} {{- with .floatingIP }} apiServerFloatingIP: {{ . }} diff --git a/charts/openstack-cluster/templates/cluster.yaml b/charts/openstack-cluster/templates/cluster.yaml index 049a4aa8c..4272b9555 100644 --- a/charts/openstack-cluster/templates/cluster.yaml +++ b/charts/openstack-cluster/templates/cluster.yaml @@ -13,7 +13,7 @@ spec: name: {{ include "openstack-cluster.componentName" (list . "control-plane") }} namespace: {{ .Release.Namespace }} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OpenStackCluster name: {{ include "openstack-cluster.clusterName" . }} namespace: {{ .Release.Namespace }} diff --git a/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml b/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml index 5f3cfa5c8..7c3236c07 100644 --- a/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml +++ b/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml @@ -134,7 +134,7 @@ spec: labels: {{ include "openstack-cluster.componentSelectorLabels" (list . "control-plane") | nindent 8 }} infrastructureRef: kind: OpenStackMachineTemplate - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 name: {{ include "openstack-cluster.controlplane.mt.name" . }} namespace: {{ .Release.Namespace }} nodeDrainTimeout: {{ .Values.controlPlane.nodeDrainTimeout }} diff --git a/charts/openstack-cluster/templates/control-plane/openstack-machine-template.yaml b/charts/openstack-cluster/templates/control-plane/openstack-machine-template.yaml index e44372c3b..13cdf59a2 100644 --- a/charts/openstack-cluster/templates/control-plane/openstack-machine-template.yaml +++ b/charts/openstack-cluster/templates/control-plane/openstack-machine-template.yaml @@ -12,9 +12,8 @@ template: spec: identityRef: - kind: Secret name: {{ include "openstack-cluster.cloudCredentialsSecretName" . }} - cloudName: openstack + cloudName: openstack flavor: {{ .Values.controlPlane.machineFlavor | required ".Values.controlPlane.machineFlavor is required" }} {{- with .Values.machineSSHKeyName }} sshKeyName: {{ . }} @@ -22,20 +21,36 @@ template: {{- if or .Values.controlPlane.machineConfigDrive $blockDevices }} configDrive: true {{- end }} - {{- if .Values.controlPlane.machineRootVolume.diskSize }} - rootVolume: {{ toYaml .Values.controlPlane.machineRootVolume | nindent 6 }} + {{- with .Values.controlPlane.machineRootVolume }} + {{- if .diskSize }} + rootVolume: + sizeGiB: {{ .diskSize }} + {{- with .volumeType }} + type: {{ . }} + {{- end }} + availabilityZone: + {{- if .availabilityZone }} + from: Name + name: {{ .availabilityZone }} + {{- else }} + from: Machine + {{- end }} {{- end }} - {{- if .Values.controlPlane.machineImageId }} - imageUUID: {{ .Values.controlPlane.machineImageId }} - {{- else if .Values.controlPlane.machineImage }} - image: {{ tpl .Values.controlPlane.machineImage . }} - {{- else if .Values.machineImageId }} - imageUUID: {{ .Values.machineImageId }} - {{- else if .Values.machineImage }} - image: {{ tpl .Values.machineImage . }} - {{- else }} - {{- fail "Either controlPlane.machineImageId, controlPlane.machineImage, machineImage or machineImageId is required" }} {{- end }} + image: + {{- if .Values.controlPlane.machineImageId }} + id: {{ .Values.controlPlane.machineImageId }} + {{- else if .Values.controlPlane.machineImage }} + filter: + name: {{ tpl .Values.controlPlane.machineImage . }} + {{- else if .Values.machineImageId }} + id: {{ .Values.machineImageId }} + {{- else if .Values.machineImage }} + filter: + name: {{ tpl .Values.machineImage . }} + {{- else }} + {{- fail "One of controlPlane.machineImageId, controlPlane.machineImage, machineImageId or machineImage is required" }} + {{- end }} {{- with $blockDevices }} additionalBlockDevices: {{- range $name, $blockDevice := . }} @@ -43,22 +58,25 @@ template: sizeGiB: {{ required "size is required for a block device" $blockDevice.size }} storage: type: {{ default "Volume" $blockDevice.type }} - {{- if or $blockDevice.volumeType $blockDevice.availabilityZone }} volume: {{- with $blockDevice.volumeType }} type: {{ . }} {{- end }} - {{- with $blockDevice.availabilityZone }} - availabilityZone: {{ . }} - {{- end }} - {{- end }} + availabilityZone: + {{- if $blockDevice.availabilityZone }} + from: Name + name: {{ $blockDevice.availabilityZone }} + {{- else }} + from: Machine + {{- end }} {{- end }} {{- end }} {{- with .Values.controlPlane.machineNetworking.ports }} ports: {{ toYaml . | nindent 6 }} {{- end }} {{- with .Values.controlPlane.serverGroupId }} - serverGroupID: {{ . }} + serverGroup: + id: {{ . }} {{- end }} {{- end }} @@ -71,7 +89,7 @@ template: {{- include "openstack-cluster.componentName" (list . "control-plane") }}-{{ trunc 8 $checksum }} {{- end }} -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OpenStackMachineTemplate metadata: name: {{ include "openstack-cluster.controlplane.mt.name" . }} diff --git a/charts/openstack-cluster/templates/node-group/machine-deployment.yaml b/charts/openstack-cluster/templates/node-group/machine-deployment.yaml index bfa2c62d2..e4cecff6c 100644 --- a/charts/openstack-cluster/templates/node-group/machine-deployment.yaml +++ b/charts/openstack-cluster/templates/node-group/machine-deployment.yaml @@ -62,7 +62,7 @@ spec: kind: KubeadmConfigTemplate name: {{ include "openstack-cluster.nodegroup.kct.name" (list $ $nodeGroup) }} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OpenStackMachineTemplate name: {{ include "openstack-cluster.nodegroup.mt.name" (list $ $nodeGroup) }} nodeDrainTimeout: {{ $nodeGroup.nodeDrainTimeout }} diff --git a/charts/openstack-cluster/templates/node-group/openstack-machine-template.yaml b/charts/openstack-cluster/templates/node-group/openstack-machine-template.yaml index ae191bb8f..f505d8fec 100644 --- a/charts/openstack-cluster/templates/node-group/openstack-machine-template.yaml +++ b/charts/openstack-cluster/templates/node-group/openstack-machine-template.yaml @@ -8,9 +8,8 @@ template: spec: identityRef: - kind: Secret name: {{ include "openstack-cluster.cloudCredentialsSecretName" $ctx }} - cloudName: openstack + cloudName: openstack flavor: {{ $nodeGroup.machineFlavor | required (printf "no flavor specified for node group '%s'" $nodeGroup.name) }} {{- with $ctx.Values.machineSSHKeyName }} sshKeyName: {{ . }} @@ -18,20 +17,36 @@ template: {{- if or $nodeGroup.machineConfigDrive $nodeGroup.additionalBlockDevices }} configDrive: true {{- end }} - {{- if $nodeGroup.machineRootVolume.diskSize }} - rootVolume: {{ toYaml $nodeGroup.machineRootVolume | nindent 6 }} + {{- with $nodeGroup.machineRootVolume }} + {{- if .diskSize }} + rootVolume: + sizeGiB: {{ .diskSize }} + {{- with .volumeType }} + type: {{ . }} + {{- end }} + availabilityZone: + {{- if .availabilityZone }} + from: Name + name: {{ .availabilityZone }} + {{- else }} + from: Machine + {{- end }} {{- end }} - {{- if $nodeGroup.machineImageId }} - imageUUID: {{ $nodeGroup.machineImageId }} - {{- else if $nodeGroup.machineImage }} - image: {{ tpl $nodeGroup.machineImage $ctx }} - {{- else if $ctx.Values.machineImageId }} - imageUUID: {{ $ctx.Values.machineImageId }} - {{- else if $ctx.Values.machineImage }} - image: {{ tpl $ctx.Values.machineImage $ctx }} - {{- else }} - {{- fail "Either nodeGroupDefaults.machineImageId, nodeGroupDefaults.machineImage, machineImageId or machineImage is required" }} {{- end }} + image: + {{- if $nodeGroup.machineImageId }} + id: {{ $nodeGroup.machineImageId }} + {{- else if $nodeGroup.machineImage }} + filter: + name: {{ tpl $nodeGroup.machineImage $ctx }} + {{- else if $ctx.Values.machineImageId }} + id: {{ $ctx.Values.machineImageId }} + {{- else if $ctx.Values.machineImage }} + filter: + name: {{ tpl $ctx.Values.machineImage $ctx }} + {{- else }} + {{- fail "One of nodeGroupDefaults.machineImageId, nodeGroupDefaults.machineImage, machineImageId or machineImage is required" }} + {{- end }} {{- with $nodeGroup.additionalBlockDevices }} additionalBlockDevices: {{- range $name, $blockDevice := . }} @@ -39,22 +54,25 @@ template: sizeGiB: {{ required "size is required for a block device" $blockDevice.size }} storage: type: {{ default "Volume" $blockDevice.type }} - {{- if or $blockDevice.volumeType $blockDevice.availabilityZone }} volume: {{- with $blockDevice.volumeType }} type: {{ . }} {{- end }} - {{- with $blockDevice.availabilityZone }} - availabilityZone: {{ . }} - {{- end }} - {{- end }} + availabilityZone: + {{- if $blockDevice.availabilityZone }} + from: Name + name: {{ $blockDevice.availabilityZone }} + {{- else }} + from: Machine + {{- end }} {{- end }} {{- end }} {{- with $nodeGroup.machineNetworking.ports }} ports: {{ toYaml . | nindent 6 }} {{- end }} {{- with $nodeGroup.serverGroupId }} - serverGroupID: {{ . }} + serverGroup: + id: {{ . }} {{- end }} {{- end }} @@ -72,7 +90,7 @@ template: {{- range $nodeGroupOverrides := .Values.nodeGroups }} {{- $nodeGroup := deepCopy $.Values.nodeGroupDefaults | mustMerge $nodeGroupOverrides }} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OpenStackMachineTemplate metadata: name: {{ include "openstack-cluster.nodegroup.mt.name" (list $ $nodeGroup) }}