From c847e0000530856299dfa0355c1e9d6d046b4f37 Mon Sep 17 00:00:00 2001 From: Bharath Nallapeta Date: Thu, 28 Nov 2024 13:10:39 +0530 Subject: [PATCH] Add OpenStack provider support with configuration and templates Signed-off-by: Bharath Nallapeta --- api/v1alpha1/common.go | 5 ++- api/v1alpha1/management_types.go | 1 + .../.helmignore | 23 +++++++++++ .../cluster-api-provider-openstack/Chart.yaml | 24 ++++++++++++ .../templates/provider.yaml | 11 ++++++ .../templates/secret.yaml | 9 +++++ .../values.schema.json | 38 +++++++++++++++++++ .../values.yaml | 6 +++ .../provider/hmc-templates/files/release.yaml | 2 + .../cluster-api-provider-openstack.yaml | 10 +++++ 10 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 templates/provider/cluster-api-provider-openstack/.helmignore create mode 100644 templates/provider/cluster-api-provider-openstack/Chart.yaml create mode 100644 templates/provider/cluster-api-provider-openstack/templates/provider.yaml create mode 100644 templates/provider/cluster-api-provider-openstack/templates/secret.yaml create mode 100644 templates/provider/cluster-api-provider-openstack/values.schema.json create mode 100644 templates/provider/cluster-api-provider-openstack/values.yaml create mode 100644 templates/provider/hmc-templates/files/templates/cluster-api-provider-openstack.yaml diff --git a/api/v1alpha1/common.go b/api/v1alpha1/common.go index 16f3ef3e4..867be8be1 100644 --- a/api/v1alpha1/common.go +++ b/api/v1alpha1/common.go @@ -45,8 +45,11 @@ const ( // Provider CAPA ProviderCAPAName = "cluster-api-provider-aws" // Provider Azure - ProviderAzureName = "cluster-api-provider-azure" + ProviderAzureName = "cluster-api-provider-azure" + // Provider vSphere ProviderVSphereName = "cluster-api-provider-vsphere" + // Provider OpenStack + ProviderOpenStackName = "cluster-api-provider-openstack" // Provider K0smotron ProviderK0smotronName = "k0smotron" // Provider Sveltos diff --git a/api/v1alpha1/management_types.go b/api/v1alpha1/management_types.go index 40844a3ed..7934a9e81 100644 --- a/api/v1alpha1/management_types.go +++ b/api/v1alpha1/management_types.go @@ -81,6 +81,7 @@ func GetDefaultProviders() []Provider { {Name: ProviderCAPAName}, {Name: ProviderAzureName}, {Name: ProviderVSphereName}, + {Name: ProviderOpenStackName}, {Name: ProviderSveltosName}, } } diff --git a/templates/provider/cluster-api-provider-openstack/.helmignore b/templates/provider/cluster-api-provider-openstack/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/templates/provider/cluster-api-provider-openstack/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/templates/provider/cluster-api-provider-openstack/Chart.yaml b/templates/provider/cluster-api-provider-openstack/Chart.yaml new file mode 100644 index 000000000..b3d55a7b1 --- /dev/null +++ b/templates/provider/cluster-api-provider-openstack/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: cluster-api-provider-openstack +description: A Helm chart for Cluster API provider OpenStack +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.1 +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "v0.11.3" +annotations: + cluster.x-k8s.io/provider: infrastructure-openstack + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/templates/provider/cluster-api-provider-openstack/templates/provider.yaml b/templates/provider/cluster-api-provider-openstack/templates/provider.yaml new file mode 100644 index 000000000..26bc3d296 --- /dev/null +++ b/templates/provider/cluster-api-provider-openstack/templates/provider.yaml @@ -0,0 +1,11 @@ +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: InfrastructureProvider +metadata: + name: openstack +spec: + version: v0.11.3 + {{- if .Values.configSecret.name }} + configSecret: + name: {{ .Values.configSecret.name }} + namespace: {{ .Values.configSecret.namespace | default .Release.Namespace | trunc 63 }} + {{- end }} diff --git a/templates/provider/cluster-api-provider-openstack/templates/secret.yaml b/templates/provider/cluster-api-provider-openstack/templates/secret.yaml new file mode 100644 index 000000000..f5780d57b --- /dev/null +++ b/templates/provider/cluster-api-provider-openstack/templates/secret.yaml @@ -0,0 +1,9 @@ +{{- if and .Values.configSecret.create .Values.configSecret.name }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.configSecret.name }} + namespace: {{ .Values.configSecret.namespace | default .Release.Namespace | trunc 63 }} +stringData: +{{ toYaml .Values.config | indent 2 }} +{{- end }} diff --git a/templates/provider/cluster-api-provider-openstack/values.schema.json b/templates/provider/cluster-api-provider-openstack/values.schema.json new file mode 100644 index 000000000..2c1df9f1a --- /dev/null +++ b/templates/provider/cluster-api-provider-openstack/values.schema.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "Schema for configuration secret settings used in the OpenStack deployment.", + "type": "object", + "required": [ + "configSecret" + ], + "properties": { + "configSecret": { + "type": "object", + "description": "Settings for the OpenStack configuration secret.", + "required": [ + "create", + "name" + ], + "properties": { + "create": { + "type": "boolean", + "description": "Indicates whether a new secret should be created." + }, + "name": { + "type": "string", + "description": "The name of the OpenStack configuration secret." + }, + "namespace": { + "type": "string", + "description": "The namespace where the OpenStack configuration secret will be created or referenced." + } + } + }, + "config": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } +} diff --git a/templates/provider/cluster-api-provider-openstack/values.yaml b/templates/provider/cluster-api-provider-openstack/values.yaml new file mode 100644 index 000000000..dac04d5b0 --- /dev/null +++ b/templates/provider/cluster-api-provider-openstack/values.yaml @@ -0,0 +1,6 @@ +configSecret: + create: false + name: "" + namespace: "" + +config: {} diff --git a/templates/provider/hmc-templates/files/release.yaml b/templates/provider/hmc-templates/files/release.yaml index 8ee758875..66be6d2e6 100644 --- a/templates/provider/hmc-templates/files/release.yaml +++ b/templates/provider/hmc-templates/files/release.yaml @@ -19,5 +19,7 @@ spec: template: cluster-api-provider-vsphere-0-0-3 - name: cluster-api-provider-aws template: cluster-api-provider-aws-0-0-3 + - name: cluster-api-provider-openstack + template: cluster-api-provider-openstack-0-0-1 - name: projectsveltos template: projectsveltos-0-42-0 diff --git a/templates/provider/hmc-templates/files/templates/cluster-api-provider-openstack.yaml b/templates/provider/hmc-templates/files/templates/cluster-api-provider-openstack.yaml new file mode 100644 index 000000000..d9f07ab91 --- /dev/null +++ b/templates/provider/hmc-templates/files/templates/cluster-api-provider-openstack.yaml @@ -0,0 +1,10 @@ +apiVersion: hmc.mirantis.com/v1alpha1 +kind: ProviderTemplate +metadata: + name: cluster-api-provider-openstack-0-0-1 + annotations: + helm.sh/resource-policy: keep +spec: + helm: + chartName: cluster-api-provider-openstack + chartVersion: 0.0.1