Skip to content

Commit

Permalink
Add OpenStack standalone control plane Helm chart and templates
Browse files Browse the repository at this point in the history
Signed-off-by: Bharath Nallapeta <[email protected]>
  • Loading branch information
bnallapeta committed Dec 9, 2024
1 parent 5ddea6f commit 625ae95
Show file tree
Hide file tree
Showing 14 changed files with 782 additions and 0 deletions.
22 changes: 22 additions & 0 deletions config/dev/openstack-managedcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
name: openstack-dev
namespace: ${NAMESPACE}
spec:
template: openstack-standalone-cp-0-0-1
credential: openstack-cluster-identity-cred
config:
controlPlaneNumber: ${CONTROL_PLANE_MACHINE_COUNT}
workersNumber: ${WORKER_MACHINE_COUNT}
controlPlane:
flavor: ${OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR}
image:
filter:
name: ${OPENSTACK_IMAGE_NAME}
worker:
flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR}
image:
filter:
name: ${OPENSTACK_IMAGE_NAME}
authURL: ${OS_AUTH_URL}
23 changes: 23 additions & 0 deletions templates/cluster/openstack-standalone-cp/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
19 changes: 19 additions & 0 deletions templates/cluster/openstack-standalone-cp/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: openstack-standalone-cp
description: |
An HMC template to deploy a k0s cluster on OpenStack with bootstrapped control plane nodes.
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: "1.31.1+k0s.1"
annotations:
cluster.x-k8s.io/provider: infrastructure-openstack, control-plane-k0smotron, bootstrap-k0smotron
cluster.x-k8s.io/bootstrap-k0smotron: v1beta1
cluster.x-k8s.io/control-plane-k0smotron: v1beta1
cluster.x-k8s.io/infrastructure-openstack: v1beta1
23 changes: 23 additions & 0 deletions templates/cluster/openstack-standalone-cp/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- define "cluster.name" -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "openstackmachinetemplate.controlplane.name" -}}
{{- include "cluster.name" . }}-cp-mt
{{- end }}

{{- define "openstackmachinetemplate.worker.name" -}}
{{- include "cluster.name" . }}-worker-mt
{{- end }}

{{- define "k0scontrolplane.name" -}}
{{- include "cluster.name" . }}-cp
{{- end }}

{{- define "k0sworkerconfigtemplate.name" -}}
{{- include "cluster.name" . }}-machine-config
{{- end }}

{{- define "machinedeployment.name" -}}
{{- include "cluster.name" . }}-md
{{- end }}
17 changes: 17 additions & 0 deletions templates/cluster/openstack-standalone-cp/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: {{ include "cluster.name" . }}
spec:
{{- with .Values.clusterNetwork }}
clusterNetwork:
{{- toYaml . | nindent 4 }}
{{- end }}
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: K0sControlPlane
name: {{ include "k0scontrolplane.name" . }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackCluster
name: {{ include "cluster.name" . }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: K0sControlPlane
metadata:
name: {{ include "k0scontrolplane.name" . }}
spec:
k0sConfigSpec:
args:
- --enable-worker
- --enable-cloud-provider
- --kubelet-extra-args="--cloud-provider=external"
- --disable-components=konnectivity-server
k0s:
apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
name: k0s
spec:
api:
extraArgs:
anonymous-auth: "true"
extensions:
helm:
repositories:
- name: openstack
url: https://kubernetes.github.io/cloud-provider-openstack/
charts:
- name: openstack-ccm
chartname: openstack/openstack-cloud-controller-manager
version: 2.31.1
order: 1
namespace: kube-system
values: |
secret:
enabled: true
name: openstack-cloud-config
create: false
- name: openstack-csi
chartname: openstack/openstack-cinder-csi
version: 2.31.3
order: 2
namespace: kube-system
values: |
storageClass:
enabled: true
delete:
isDefault: false
allowVolumeExpansion: true
retain:
isDefault: false
allowVolumeExpansion: false
secret:
enabled: true
name: openstack-cloud-config
create: false
network:
provider: calico
calico:
mode: vxlan
machineTemplate:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackMachineTemplate
name: {{ include "openstackmachinetemplate.controlplane.name" . }}
namespace: {{ .Release.Namespace }}
replicas: {{ .Values.controlPlaneNumber }}
version: {{ .Values.k0s.version }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: K0sWorkerConfigTemplate
metadata:
name: {{ include "k0sworkerconfigtemplate.name" . }}
spec:
template:
spec:
args:
- --enable-cloud-provider
- --kubelet-extra-args="--cloud-provider=external"
version: {{ .Values.k0s.version }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ include "machinedeployment.name" . }}
spec:
clusterName: {{ include "cluster.name" . }}
replicas: {{ .Values.workersNumber }}
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }}
template:
metadata:
labels:
cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }}
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: K0sWorkerConfigTemplate
name: {{ include "k0sworkerconfigtemplate.name" . }}
clusterName: {{ include "cluster.name" . }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackMachineTemplate
name: {{ include "openstackmachinetemplate.worker.name" . }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackCluster
metadata:
name: {{ include "cluster.name" . }}
spec:
{{- if .Values.apiServerLoadBalancer }}
apiServerLoadBalancer:
{{- toYaml .Values.apiServerLoadBalancer | nindent 4 }}
{{- end }}
{{- if .Values.bastion.enabled }}
bastion:
{{- with .Values.bastion.spec }}
spec:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.externalNetwork }}
externalNetwork:
{{- toYaml .Values.externalNetwork | nindent 4 }}
{{- end }}
{{- if .Values.clusterIdentity }}
identityRef:
name: {{ .Values.clusterIdentity.name }}
cloudName: {{ .Values.clusterIdentity.cloudName | default "openstack" }}
region: {{ .Values.clusterIdentity.region | default "RegionOne" }}
{{- end }}
managedSecurityGroups:
{{- toYaml .Values.managedSecurityGroups | nindent 4 }}
{{- if .Values.managedSubnets }}
managedSubnets:
{{- toYaml .Values.managedSubnets | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackMachineTemplate
metadata:
name: {{ include "openstackmachinetemplate.controlplane.name" . }}
spec:
template:
spec:
flavor: {{ .Values.controlplane.flavor }}
cloudName: {{ .Values.clusterIdentity.cloudName}}
image:
filter:
name: {{ .Values.controlplane.image.filter.name }}
{{- if .Values.controlplane.image.filter.tags }}
tags:
{{- range $tag := .Values.controlplane.image.filter.tags }}
- {{ $tag }}
{{- end }}
{{- end }}
{{- if gt (len .Values.controlplane.portOpts) 0 }}
portOpts:
{{ .Values.controlplane.portOpts | toYaml | nindent 8 }}
{{- end }}
{{- if gt (len .Values.controlplane.securityGroups) 0 }}
securityGroups:
{{ .Values.controlplane.securityGroups | toYaml | nindent 8 }}
{{- end }}
{{- if not ( .Values.controlplane.sshPublicKey | empty) }}
sshPublicKey: {{ .Values.controlplane.sshPublicKey }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackMachineTemplate
metadata:
name: {{ include "openstackmachinetemplate.worker.name" . }}
spec:
template:
spec:
flavor: {{ .Values.worker.flavor }}
cloudName: {{ .Values.clusterIdentity.cloudName }}
image:
filter:
name: {{ .Values.worker.image.filter.name }}
{{- if .Values.worker.image.filter.tags }}
tags:
{{- range $tag := .Values.worker.image.filter.tags }}
- {{ $tag }}
{{- end }}
{{- end }}
{{- if gt (len .Values.worker.portOpts) 0 }}
portOpts:
{{ .Values.worker.portOpts | toYaml | nindent 8 }}
{{- end }}
{{- if gt (len .Values.worker.securityGroups) 0 }}
securityGroups:
{{ .Values.worker.securityGroups | toYaml | nindent 8 }}
{{- end }}
{{- if not ( .Values.worker.sshPublicKey | empty) }}
sshPublicKey: {{ .Values.worker.sshPublicKey }}
{{- end }}
Loading

0 comments on commit 625ae95

Please sign in to comment.