Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rabbitmq-standalone chart #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions .github/workflows/install-rabbitmq-standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Install rabbitmq-standalone chart

on:
pull_request:
paths:
- 'charts/rabbitmq-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: fightdou/[email protected]

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

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

- name: Install rabbitmq-standalone chart
run: |
ct install --namespace test-rabbitmq --target-branch main --charts charts/rabbitmq-standalone --debug --helm-extra-args "--timeout 300s"

- 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
7 changes: 7 additions & 0 deletions charts/rabbitmq-standalone/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
description: Deploy standalone rabbitmq
home: https://github.com/kungze/rabbitmq-standalone
maintainers:
- name: Kungze
name: rabbitmq-standalone
version: 1.0.0
49 changes: 49 additions & 0 deletions charts/rabbitmq-standalone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# rabbitmq-standalone

在 K8s 环境中部署 [rabbitmq-standalone](https://github.com/kungze/rabbitmq-standalone)

该组件提供一种不依赖于 pvc 的单节点部署方式

## 快速部署

```
helm repo add kungze https://kungze.github.io/cinder-metal-csi
helm install rabbitmq-standalone kungze rabbitmq-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` |


### rabbitmq Config parameters

| Name | Form title | Description | Value |
| ---------------- | ----------------- | ---------------------- | ---------------------- |
| `rabbitmq.username` | RabbitMQ username | RabbitMQ username | `openstack` |
| `rabbitmq.password` | RabbitMQ password | RabbitMQ password | `TXO9pjYDoX` |
40 changes: 40 additions & 0 deletions charts/rabbitmq-standalone/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "rabbitmq.names.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

{{/*
Kubernetes standard labels
*/}}
{{- define "rabbitmq.labels.standard" -}}
app.kubernetes.io/name: {{ include "rabbitmq.names.name" . }}
helm.sh/chart: {{ include "rabbitmq.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 "rabbitmq.labels.matchLabels" -}}
app.kubernetes.io/name: {{ include "rabbitmq.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{- define "rabbitmq.utils.template" -}}
{{- $name := index . 0 -}}
{{- $context := index . 1 -}}
{{- $last := base $context.Template.Name }}
{{- $wtf := $context.Template.Name | replace $last $name -}}
{{ include $wtf $context }}
{{- end -}}
10 changes: 10 additions & 0 deletions charts/rabbitmq-standalone/templates/conf/_definitions.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"vhosts": [
{"name": "/"} ],
"users": [
{"name": "{{ .Values.rabbitmq.username }}", "password": "{{ .Values.rabbitmq.password }}", "tags": "administrator"} ],
"permissions": [
{"user": "{{ .Values.rabbitmq.username }}", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*"} ],
"policies":[
{"vhost": "/", "name": "ha-all", "pattern": ".*", "apply-to": "all", "definition": {"ha-mode":"all"}, "priority":0} ]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
RABBITMQ_LOG_BASE=/var/log/kolla/rabbitmq
RABBITMQ_DIST_PORT=25672
RABBITMQ_PID_FILE=/var/lib/rabbitmq/mnesia/rabbitmq.pid
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-kernel inetrc '/etc/rabbitmq/erl_inetrc' "
RABBITMQ_CTL_ERL_ARGS=""

export ERL_EPMD_PORT=4369
export ERL_INETRC=/etc/rabbitmq/erl_inetrc
6 changes: 6 additions & 0 deletions charts/rabbitmq-standalone/templates/conf/_rabbitmq.conf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
listeners.tcp.1 = 0.0.0.0:5672
cluster_partition_handling = pause_minority

management.listener.ip = 0.0.0.0
management.listener.port = 15672
management.load_definitions = /etc/rabbitmq/definitions.json
41 changes: 41 additions & 0 deletions charts/rabbitmq-standalone/templates/conf/_rabbitmq.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"command": "/usr/sbin/rabbitmq-server",
"config_files": [
{
"source": "/var/lib/kolla/config_files/rabbitmq-env.conf",
"dest": "/etc/rabbitmq/rabbitmq-env.conf",
"owner": "rabbitmq",
"perm": "0600"
},
{
"source": "/var/lib/kolla/config_files/rabbitmq.conf",
"dest": "/etc/rabbitmq/rabbitmq.conf",
"owner": "rabbitmq",
"perm": "0600"
},
{
"source": "/var/lib/kolla/config_files/erl_inetrc",
"dest": "/etc/rabbitmq/erl_inetrc",
"owner": "rabbitmq",
"perm": "0600"
},
{
"source": "/var/lib/kolla/config_files/definitions.json",
"dest": "/etc/rabbitmq/definitions.json",
"owner": "rabbitmq",
"perm": "0600"
}
],
"permissions": [
{
"path": "/var/lib/rabbitmq",
"owner": "rabbitmq:rabbitmq",
"recurse": true
},
{
"path": "/var/log/kolla/rabbitmq",
"owner": "rabbitmq:rabbitmq",
"recurse": true
}
]
}
16 changes: 16 additions & 0 deletions charts/rabbitmq-standalone/templates/configmap-etc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: rabbitmq-etc
namespace: {{ .Release.Namespace | quote }}
data:
rabbitmq.conf: |
{{ tuple "conf/_rabbitmq.conf.tpl" . | include "rabbitmq.utils.template" | indent 4 }}
definitions.json: |
{{ tuple "conf/_definitions.json.tpl" . | include "rabbitmq.utils.template" | indent 4 }}
rabbitmq-env.conf: |
{{ tuple "conf/_rabbitmq-env.conf.tpl" . | include "rabbitmq.utils.template" | indent 4 }}
erl_inetrc: |
{{ tuple "conf/_erl_inetrc.tpl" . | include "rabbitmq.utils.template" | indent 4 }}
rabbitmq.json: |
{{ tuple "conf/_rabbitmq.json.tpl" . | include "rabbitmq.utils.template" | indent 4 }}
102 changes: 102 additions & 0 deletions charts/rabbitmq-standalone/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "rabbitmq.labels.standard" . | nindent 4 }}
spec:
selector:
matchLabels: {{- include "rabbitmq.labels.matchLabels" . | nindent 6 }}
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels: {{- include "rabbitmq.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: rabbitmq
spec:
containers:
- name: rabbitmq
image: "{{ .Values.imageRegistry }}/{{ .Values.imageNamespace }}/ubuntu-source-rabbitmq:{{ .Values.openstackTag }}"
imagePullPolicy: {{ .Values.pullPolicy }}
{{- if .Values.enableLivenessProbe }}
livenessProbe:
failureThreshold: 3
tcpSocket:
port: 5672
initialDelaySeconds: 50
periodSeconds: 60
successThreshold: 1
timeoutSeconds: 15
{{- end }}
{{- if .Values.enableReadinessProbe }}
readinessProbe:
failureThreshold: 3
tcpSocket:
port: 5672
initialDelaySeconds: 50
periodSeconds: 60
successThreshold: 1
timeoutSeconds: 15
{{- end }}
env:
- name: KOLLA_CONFIG_STRATEGY
value: "COPY_ALWAYS"
- name: KOLLA_SERVICE_NAME
value: "rabbitmq"
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
ports:
- name: amqp
containerPort: 5672
protocol: TCP
- name: dist
containerPort: 25672
protocol: TCP
- name: stats
containerPort: 15672
protocol: TCP
- name: epmd
containerPort: 4369
protocol: TCP
volumeMounts:
- mountPath: /var/log/kolla/rabbitmq
name: rabbitmqlog
- mountPath: /var/lib/kolla/config_files/rabbitmq.conf
name: rabbitmq-etc
subPath: rabbitmq.conf
- mountPath: /var/lib/kolla/config_files/config.json
name: rabbitmq-etc
subPath: rabbitmq.json
- mountPath: /var/lib/kolla/config_files/definitions.json
name: rabbitmq-etc
subPath: definitions.json
- mountPath: /var/lib/kolla/config_files/rabbitmq-env.conf
name: rabbitmq-etc
subPath: rabbitmq-env.conf
- mountPath: /var/lib/kolla/config_files/erl_inetrc
name: rabbitmq-etc
subPath: erl_inetrc
- mountPath: /var/lib/rabbitmq/
name: rabbitmqdata
securityContext:
runAsUser: 0
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
serviceAccount: {{ .Values.serviceAccountName}}
serviceAccountName: {{ .Values.serviceAccountName}}
volumes:
- hostPath:
path: /var/log/kolla/rabbitmq
type: DirectoryOrCreate
name: rabbitmqlog
- configMap:
defaultMode: 365
name: rabbitmq-etc
name: rabbitmq-etc
- hostPath:
path: /var/lib/rabbitmq
type: DirectoryOrCreate
name: rabbitmqdata
28 changes: 28 additions & 0 deletions charts/rabbitmq-standalone/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: rabbitmq
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "rabbitmq.labels.standard" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- name: amqp
port: 5672
protocol: TCP
targetPort: amqp
- name: epmd
port: 4369
protocol: TCP
targetPort: epmd
- name: dist
port: 25672
protocol: TCP
targetPort: dist
- name: http-stats
port: 15672
protocol: TCP
targetPort: stats
selector: {{- include "rabbitmq.labels.matchLabels" . | nindent 4 }}
app.kubernetes.io/component: "rabbitmq"

46 changes: 46 additions & 0 deletions charts/rabbitmq-standalone/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccountName}}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "rabbitmq.labels.standard" . | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Values.serviceAccountName}}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "rabbitmq.labels.standard" . | nindent 4 }}
rules:
- apiGroups:
- ""
- extensions
- batch
- apps
resources:
- services
- endpoints
- secrets
- configmaps
- jobs
- pods
verbs:
- get
- list
- create
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Values.serviceAccountName}}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "rabbitmq.labels.standard" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ .Values.serviceAccountName}}
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccountName}}
namespace: {{ .Release.Namespace | quote }}
Loading