Skip to content

Commit

Permalink
charts/mysql-operator: add mysql-operator helm files
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyass committed Jun 30, 2021
1 parent 8f0a8e3 commit 4c7a87f
Show file tree
Hide file tree
Showing 11 changed files with 1,607 additions and 0 deletions.
24 changes: 24 additions & 0 deletions charts/mysql-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: mysql-operator
description: A Helm chart for Kubernetes

# 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.1.0

# 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.16.0"
1,131 changes: 1,131 additions & 0 deletions charts/mysql-operator/crds/mysql.radondb.com_clusters.yaml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions charts/mysql-operator/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
You can create a new cluster by issuing:

cat <<EOF | kubectl apply -f-
apiVersion: mysql.radondb.com/v1alpha1
kind: Cluster
metadata:
name: sample
spec:
replicas: 3
EOF
42 changes: 42 additions & 0 deletions charts/mysql-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mysql-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "mysql-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

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

{{/*
Create the name of the service account to use
*/}}
{{- define "serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "mysql-operator.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
79 changes: 79 additions & 0 deletions charts/mysql-operator/templates/auth_proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{- if .Values.rbacProxy.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "mysql-operator.name" . }}-metrics-reader
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
rules:
- nonResourceURLs:
- "/metrics"
verbs:
- get

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "mysql-operator.name" . }}-proxy
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "mysql-operator.name" . }}-proxy
subjects:
- kind: ServiceAccount
name: {{ template "serviceAccountName" . }}
namespace: {{ .Release.Namespace }}

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "mysql-operator.name" . }}-proxy
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create

---
apiVersion: v1
kind: Service
metadata:
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
name: {{ template "mysql-operator.name" . }}-metrics
namespace: {{ .Release.Namespace }}
spec:
ports:
- name: https
port: 8443
targetPort: https
selector:
app: {{ template "mysql-operator.name" . }}
release: {{ .Release.Name | quote }}
{{- end }}
131 changes: 131 additions & 0 deletions charts/mysql-operator/templates/cluster_rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{{- if and .Values.serviceAccount.create .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "mysql-operator.fullname" . }}
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
rules:
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
- persistentvolumeclaims
- pods
- secrets
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- get
- patch
- apiGroups:
- ""
resources:
- pods/exec
verbs:
- create
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- mysql.radondb.com
resources:
- clusters
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mysql.radondb.com
resources:
- clusters/finalizers
verbs:
- update
- apiGroups:
- mysql.radondb.com
resources:
- clusters/status
verbs:
- get
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
- roles
verbs:
- create
- get
- list
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "mysql-operator.fullname" . }}
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "mysql-operator.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/mysql-operator/templates/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if (and .Values.installCRDs (not (.Capabilities.APIVersions.Has "mysql.radondb.com/v1alpha1"))) }}
{{- if and .Values.installCRDs -}}
{{- range $path, $bytes := .Files.Glob "crds/*.yaml" }}
---
{{ $.Files.Get $path }}
{{- end }}
{{- end }}
{{- end }}
63 changes: 63 additions & 0 deletions charts/mysql-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "mysql-operator.fullname" . }}
labels:
app: {{ template "mysql-operator.name" . }}
chart: {{ template "mysql-operator.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
spec:
selector:
matchLabels:
app: {{ template "mysql-operator.name" . }}
release: {{ .Release.Name | quote }}
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "mysql-operator.name" . }}
release: {{ .Release.Name | quote }}
spec:
securityContext:
runAsNonRoot: true
containers:
{{- if .Values.rbacProxy.create }}
- name: kube-rbac-proxy
image: gcr.azk8s.cn/kubebuilder/kube-rbac-proxy:v0.8.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=10"
ports:
- containerPort: 8443
name: https
{{- end }}
- name: manager
command:
- /manager
args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
image: "{{ .Values.manager.image }}:{{ .Values.manager.tag }}"
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{ toYaml .Values.manager.resources | indent 10 }}
serviceAccountName: {{ template "serviceAccountName" . }}
terminationGracePeriodSeconds: 10
Loading

0 comments on commit 4c7a87f

Please sign in to comment.