Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions charts/openstack-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/}}
Expand Down
35 changes: 19 additions & 16 deletions charts/openstack-cluster/templates/cluster-openstack.yaml
Original file line number Diff line number Diff line change
@@ -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" . }}
Expand All @@ -11,49 +11,52 @@ 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 }}
{{- with .Values.apiServer }}
{{- 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: {{ . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/openstack-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,71 @@
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: {{ . }}
{{- end }}
{{- 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 := . }}
- name: {{ $name }}
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 }}

Expand All @@ -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" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,71 @@
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: {{ . }}
{{- end }}
{{- 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 := . }}
- name: {{ $name }}
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 }}

Expand All @@ -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) }}
Expand Down