Skip to content

Commit

Permalink
Add cinder-standalone chart
Browse files Browse the repository at this point in the history
  • Loading branch information
caotingv committed Aug 26, 2022
1 parent bc51bda commit b04d8ba
Show file tree
Hide file tree
Showing 29 changed files with 1,416 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/install-cinder-standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Install cinder chart

on:
pull_request:
paths:
- 'charts/cinder-standalone/**'

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch history
run: git fetch --prune --unshallow

- name: Set up chart-testing
uses: helm/[email protected]

- name: Create kind cluster
uses: helm/[email protected]

- name: use local disk
run: tests/scripts/github-action-helper.sh use_local_disk_for_integration_test

- name: Create k8s namespace
run:
kubectl create namespace test-cinder

- name: Run chart-testing (install)
run: ct install --namespace test-cinder --target-branch main --charts charts/cinder-standalone --debug --helm-extra-args "--timeout 600s"

- name: setup tmate session for debugging when event is PR
if: failure() && github.event_name == 'pull_request'
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60
12 changes: 12 additions & 0 deletions charts/cinder-standalone/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
description: Deploy noauth and Cinder for SQLite
home: https://github.com/kungze/cinder-metal-csi
maintainers:
- name: Kungze
name: cinder-standalone
version: 1.0.0
dependencies:
- name: rabbitmq-standalone
condition: rabbitmq.enabled
version: "1.0.0"
repository: "https://github.com/kungze/cinder-metal-csi"
71 changes: 71 additions & 0 deletions charts/cinder-standalone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

# cinder

The chart used to deploy cinder project.

## TL;DR

```shell
helm repo add kungze https://kungze.github.io/cinder-standalone
helm install cinder-standalone kungze cinder-standalone
```


## Parameters

### Cluster Paramters

| Name | Form title | Description | Value |
| ----------------------- | --------------------- | -------------------------------------------- | --------------- |
| `cluster_domain_suffix` | Cluster Domain Suffix | The doamin suffix of the current k8s cluster | `cluster.local` |


### Image Parameters

| Name | Form title | Description | Value |
| ---------------- | ----------------- | ----------------------------------------------- | ----------------------- |
| `imageRegistry` | Image Registry | The registry address of openstack kolla image | `registry.aliyuncs.com` |
| `imageNamespace` | Image Namespace | The registry namespace of openstack kolla image | `kolla-helm` |
| `openstackTag` | Openstack version | The openstack version | `yoga` |
| `pullPolicy` | Pull Policy | The image pull policy | `IfNotPresent` |


### Deployment Parameters

| Name | Form title | Description | Value |
| ---------------------- | ----------------------- | ------------------------------------------------------------------------ | -------- |
| `replicaCount` | | Number of cinder replicas to deploy (requires ReadWriteMany PVC support) | `1` |
| `serviceAccountName` | | ServiceAccount name | `cinder` |
| `enableLivenessProbe` | Enable Liveness Probe | Whether or not enable liveness probe | `true` |
| `enableReadinessProbe` | Enable Readliness Probe | Whether or not enable readiness probe | `true` |


### Cinder Config parameters

| Name | Form title | Description | Value |
| ---------------------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| `enabled_notification` | Enable Notification | Whether or not enable notification | `false` |
| `lvm.enabled` | Enable Lvm | Whether or not enable lvm backend | `true` |
| `lvm.vg_name` | Volume group Name | The volume group name used to as the cinder lvm driver's backend | `cinder-volumes` |
| `lvm.create_loop_device` | Create Loop Device | Whether or not create a loop device for lvm backend. If this set as false, the lvm volume group must be prepared in advance. | `true` |
| `lvm.loop_device_name` | Loop Device Name | The loop device's name | `/dev/loop0` |
| `lvm.loop_device_size` | Loop Device Size | The loop device's size, unit Mb | `2048` |
| `lvm.volume_type` | Cinder Volume Type | The cinder volume type name corresponding with lvm backend | `lvm` |
| `lvm.lvm_target_helper` | Cinder Lvm Target Helper | Target user-land tool to use | `tgtadm` |
| `ceph.enabled` | Enable Ceph | Whether or not enable ceph backend | `true` |
| `ceph.volume_type` | Cinder Volume Type | The cinder volume type name corresponding with ceph backend | `rbd` |
| `ceph.poolName` | Pool Name | The ceph pool name which used to store the cinder volumes | `volumes` |
| `ceph.replicatedSize` | Pool Replicated Size | For a pool based on raw copies, specify the number of copies. A size of 1 indicates no redundancy. | `1` |
| `ceph.cephClientName` | Rook Ceph Client Name | The name of rook ceph cephclient | `cinder` |
| `ceph.backup.enabled` | Enable Cinder Backup | Whether or not enable cinder backup feature | `false` |
| `ceph.backup.poolName` | Backup Pool Name | The name of ceph pool used to store cinder volume backups | `backups` |
| `ceph.backup.replicatedSize` | Pool Replicated Size | For a pool based on raw copies, specify the number of copies. A size of 1 indicates no redundancy. | `1` |


### rabbitmq Config parameters

| Name | Form title | Description | Value |
| ---------------- | ----------------- | ----------------------------------------------- | ----------------------- |
| `rabbitmq.enable` | Enable rabbitmq | Whether or not enable rabbitmq | `true` |
| `rabbitmq.username` | RabbitMQ username | Required for the Cinder connection username | `openstack` |
| `rabbitmq.password` | RabbitMQ password | Required for the Cinder connection password | `TXO9pjYDoX` |
11 changes: 11 additions & 0 deletions charts/cinder-standalone/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}

1. Set the necessary environment variables:
export OS_AUTH_TYPE=noauth
export OS_PROJECT_ID=admin
export OS_VOLUME_API_VERSION=3.10
export CINDER_ENDPOINT=http://cinder-api.{{ .Release.Namespace }}.svc.{{ .Values.cluster_domain_suffix }}:8776/v3

2. Run the following command to check the service status
$ cinder service-list
125 changes: 125 additions & 0 deletions charts/cinder-standalone/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Return the proper image name
{{ include "cinder.images.image" ( dict "registry" .Values.registry "namespace" .Values.namespace "repository" "kolla-toolbox" "tag" .Values.openstackTag) }}
*/}}
{{- define "cinder.images.image" -}}
{{- $registry := index . "registry" -}}
{{- $namespace := index . "namespace" -}}
{{- $repository := index . "repository" -}}
{{- $tag := index . "tag" -}}
{{ printf "%s/%s/%s:%s" $registry $namespace $repository $tag }}
{{- end -}}

{{/*
Return entrypoint image name
*/}}
{{- define "rabbitmq.image" -}}
{{ $repository := "ubuntu-source-rabbitmq" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }}
{{- end -}}

{{/*
Return entrypoint image name
*/}}
{{- define "kubernetes.entrypoint.image" -}}
{{ $repository := "kubernetes-entrypoint" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" "v1.0.0") }}
{{- end -}}

{{/*
Return the proper cinder api image name
*/}}
{{- define "cinder.api.image" -}}
{{ $repository := "ubuntu-source-cinder-api" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }}
{{- end -}}

{{/*
Return the proper cinder volume image name
*/}}
{{- define "cinder.volume.image" -}}
{{ $repository := "ubuntu-source-cinder-volume" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }}
{{- end -}}

{{/*
Return the proper cinder backup image name
*/}}
{{- define "cinder.backup.image" -}}
{{ $repository := "ubuntu-source-cinder-backup" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }}
{{- end -}}

{{/*
Return the proper cinder scheduler image name
*/}}
{{- define "cinder.scheduler.image" -}}
{{ $repository := "ubuntu-source-cinder-scheduler" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }}
{{- end -}}


{{/*
Return the proper tgtd image name
*/}}
{{- define "kolla.tgtd.image" -}}
{{ $repository := "ubuntu-source-tgtd" }}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }}
{{- end -}}

{{/*
Return the proper cinder loop image name
*/}}
{{- define "cinder.loop.image" -}}
{{- include "cinder.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" "loop" "tag" "latest") }}
{{- end -}}

{{/*
Return the sync endpoint image name
*/}}
{{- define "cinder.kolla-toolbox.image" -}}
{{- $repository := "ubuntu-source-kolla-toolbox" -}}
{{- printf "%s/%s/%s:%s" .Values.imageRegistry .Values.imageNamespace $repository .Values.openstackTag }}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
{{- define "cinder.names.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cinder.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Kubernetes standard labels
*/}}
{{- define "cinder.labels.standard" -}}
app.kubernetes.io/name: {{ include "cinder.names.name" . }}
helm.sh/chart: {{ include "cinder.names.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "cinder.labels.matchLabels" -}}
app.kubernetes.io/name: {{ include "cinder.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{- define "cinder.utils.template" -}}
{{- $name := index . 0 -}}
{{- $context := index . 1 -}}
{{- $last := base $context.Template.Name }}
{{- $wtf := $context.Template.Name | replace $last $name -}}
{{ include $wtf $context }}
{{- end -}}
4 changes: 4 additions & 0 deletions charts/cinder-standalone/templates/bin/_db_sync.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -ex
touch /var/lib/cinder/cinder.sqlite
kolla_start
35 changes: 35 additions & 0 deletions charts/cinder-standalone/templates/bin/_gen_ceph_conf.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash -e

CEPH_CONFIG="/etc/ceph/ceph.conf"
MON_CONFIG="/etc/rook/mon-endpoints"
KEYRING_FILE="/etc/ceph/ceph.client.cinder.keyring"

# create a ceph config file in its default location so ceph/rados tools can be used
# without specifying any arguments
write_endpoints() {
endpoints=$(cat ${MON_CONFIG})

# filter out the mon names
# external cluster can have numbers or hyphens in mon names, handling them in regex
# shellcheck disable=SC2001
mon_endpoints=$(echo "${endpoints}"| sed 's/[a-z0-9_-]\+=//g')

DATE=$(date)
echo "$DATE writing mon endpoints to ${CEPH_CONFIG}: ${endpoints}"
cat <<EOF > ${CEPH_CONFIG}
[global]
mon_host = ${mon_endpoints}
[client.cinder]
keyring = ${KEYRING_FILE}
EOF
}

# create the keyring file
cat <<EOF > ${KEYRING_FILE}
[client.${CEPH_USERNAME}]
key = ${CEPH_SECRET}
EOF

# write the initial config file
write_endpoints
7 changes: 7 additions & 0 deletions charts/cinder-standalone/templates/bin/_lvm_clean.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -ex
vgremove -y {{ .Values.lvm.vg_name }}
pvremove {{ .Values.lvm.loop_device_name }}
{{- if .Values.lvm.create_loop_device }}
losetup -d {{ .Values.lvm.loop_device_name }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/cinder-standalone/templates/bin/_lvm_create.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -ex
pvcreate {{ .Values.lvm.loop_device_name }}
vgcreate {{ .Values.lvm.vg_name }} {{ .Values.lvm.loop_device_name }}
15 changes: 15 additions & 0 deletions charts/cinder-standalone/templates/bin/_volume_type_create.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -ex

export OS_AUTH_TYPE=noauth
export OS_PROJECT_ID=admin
export OS_VOLUME_API_VERSION=3.10
export CINDER_ENDPOINT=http://cinder-api.{{ .Release.Namespace }}.svc.{{ .Values.cluster_domain_suffix }}:8776/v3

{{- if .Values.ceph.enabled }}
cinder type-create {{ .Values.ceph.volume_type }}
{{- end }}

{{- if .Values.lvm.enabled }}
cinder type-create {{ .Values.lvm.volume_type }}
{{- end }}
Loading

0 comments on commit b04d8ba

Please sign in to comment.