commit
f74768d009
46 changed files with 2227 additions and 0 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (c) 2019 RUG |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
# Webhosting Helm charts |
||||
|
||||
[](https://circleci.com/gh/kiwigrid/helm-charts) |
||||
|
||||
## Add repo |
||||
|
||||
```console |
||||
$ helm repo add webhosting https://registry.webhosting.rug.nl/webhosting/helm |
||||
``` |
||||
|
||||
## Support |
||||
|
||||
* Please don't write mails directly to the maintainers. |
||||
* Use the Gogs issue tracker instead. |
After Width: | Height: | Size: 3.7 KiB |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
name: mysql |
||||
version: 0.3.7 |
||||
appVersion: 5.7.14 |
||||
description: Fast, reliable, scalable, and easy to use open-source relational database |
||||
system. |
||||
keywords: |
||||
- mysql |
||||
- database |
||||
- sql |
||||
home: https://www.mysql.com/ |
||||
icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png |
||||
sources: |
||||
- https://github.com/kubernetes/charts |
||||
- https://github.com/docker-library/mysql |
||||
maintainers: |
||||
- name: Vic Iglesias |
||||
email: viglesias@google.com |
||||
engine: gotpl |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
## Prerequisites |
||||
|
||||
- Kubernetes 1.6+ with Beta APIs enabled |
||||
- PV provisioner support in the underlying infrastructure |
||||
|
||||
## Installing the Chart |
||||
|
||||
By default a random password will be generated for the root user. If you'd like to set your own password change the mysqlRootPassword |
||||
in the values.yaml. |
||||
|
||||
You can retrieve your root password by running the following command. Make sure to replace [YOUR_RELEASE_NAME]: |
||||
|
||||
printf $(printf '\%o' `kubectl get secret [YOUR_RELEASE_NAME]-mysql -o jsonpath="{.data.mysql-root-password[*]}"`) |
||||
|
||||
> **Tip**: List all releases using `helm list` |
||||
|
||||
## Configuration |
||||
|
||||
The following table lists the configurable parameters of the MySQL chart and their default values. |
||||
|
||||
| Parameter | Description | Default | |
||||
| ------------------------------------ | ----------------------------------------- | ---------------------------------------------------- | |
||||
| `imageTag` | `mysql` image tag. | Most recent release | |
||||
| `imagePullPolicy` | Image pull policy | `IfNotPresent` | |
||||
| `mysqlRootPassword` | Password for the `root` user. | `nil` | |
||||
| `mysqlUser` | Username of new user to create. | `nil` | |
||||
| `mysqlPassword` | Password for the new user. | `nil` | |
||||
| `mysqlDatabase` | Name for new database to create. | `nil` | |
||||
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 | |
||||
| `livenessProbe.periodSeconds` | How often to perform the probe | 10 | |
||||
| `livenessProbe.timeoutSeconds` | When the probe times out | 5 | |
||||
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 | |
||||
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 | |
||||
| `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | 5 | |
||||
| `readinessProbe.periodSeconds` | How often to perform the probe | 10 | |
||||
| `readinessProbe.timeoutSeconds` | When the probe times out | 1 | |
||||
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 | |
||||
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 | |
||||
| `persistence.enabled` | Create a volume to store data | true | |
||||
| `persistence.size` | Size of persistent volume claim | 8Gi RW | |
||||
| `nodeSelector` | Node labels for pod assignment | {} | |
||||
| `persistence.storageClass` | Type of persistent volume claim | nil (uses alpha storage class annotation) | |
||||
| `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce | |
||||
| `persistence.existingClaim` | Name of existing persistent volume | `nil` | |
||||
| `persistence.subPath` | Subdirectory of the volume to mount | `nil` | |
||||
| `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `100m` | |
||||
| `configurationFiles` | List of mysql configuration files | `nil` | |
||||
|
||||
Some of the parameters above map to the env variables defined in the [MySQL DockerHub image](https://hub.docker.com/_/mysql/). |
||||
|
||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, |
||||
|
||||
```bash |
||||
$ helm install --name my-release \ |
||||
--set mysqlRootPassword=secretpassword,mysqlUser=my-user,mysqlPassword=my-password,mysqlDatabase=my-database \ |
||||
stable/mysql |
||||
``` |
||||
|
||||
The above command sets the MySQL `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`. |
||||
|
||||
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, |
||||
|
||||
```bash |
||||
$ helm install --name my-release -f values.yaml stable/mysql |
||||
``` |
||||
|
||||
> **Tip**: You can use the default [values.yaml](values.yaml) |
||||
|
||||
## Persistence |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image stores the MySQL data and configurations at the `/var/lib/mysql` path of the container. |
||||
|
||||
By default a PersistentVolumeClaim is created and mounted into that directory. In order to disable this functionality |
||||
you can change the values.yaml to disable persistence and use an emptyDir instead. |
||||
|
||||
> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."* |
||||
|
||||
## Custom MySQL configuration files |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image accepts custom configuration files at the path `/etc/mysql/conf.d`. If you want to use a customized MySQL configuration, you can create your alternative configuration files by passing the file contents on the `configurationFiles` attribute. Note that according to the MySQL documentation only files ending with `.cnf` are loaded. |
||||
|
||||
```yaml |
||||
configurationFiles: |
||||
mysql.cnf: |- |
||||
[mysqld] |
||||
skip-host-cache |
||||
skip-name-resolve |
||||
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
||||
mysql_custom.cnf: |- |
||||
[mysqld] |
||||
``` |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
# MySQL |
||||
|
||||
[MySQL](https://MySQL.org) is one of the most popular database servers in the world. Notable users include Wikipedia, Facebook and Google. |
||||
|
||||
## Introduction |
||||
|
||||
This chart bootstraps a single node MySQL deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
rancher_max_version: 2.3.1 |
||||
categories: |
||||
- Database |
||||
- MySQL |
||||
questions: |
||||
- variable: defaultImage |
||||
default: "true" |
||||
description: "Use default Docker images" |
||||
label: Use Default Images |
||||
type: boolean |
||||
show_subquestion_if: false |
||||
group: "Container Images" |
||||
subquestions: |
||||
- variable: image |
||||
default: "mysql" |
||||
description: "Docker image name" |
||||
type: string |
||||
label: Image Name |
||||
- variable: imageTag |
||||
default: "5.7.14" |
||||
description: "Docker image tag" |
||||
type: string |
||||
label: Image Tag |
||||
- variable: mysqlDatabase |
||||
default: "admin" |
||||
description: "Name of database to create" |
||||
type: string |
||||
required: true |
||||
label: MySQL Database |
||||
group: "MySQL Settings" |
||||
- variable: mysqlUser |
||||
default: "admin" |
||||
description: "Username of user to create" |
||||
type: string |
||||
required: true |
||||
label: MySQL Username |
||||
group: "MySQL Settings" |
||||
- variable: mysqlPassword |
||||
default: "" |
||||
description: "MySQL Password for the new user, defaults to a random 10-character alphanumeric string if not set" |
||||
type: password |
||||
label: MySQL Password |
||||
group: "MySQL Settings" |
||||
- variable: persistence.enabled |
||||
default: "false" |
||||
description: "Enable persistence using PVC" |
||||
type: boolean |
||||
required: true |
||||
label: Persistent Volume Enabled |
||||
show_subquestion_if: true |
||||
group: "Persistent Volume" |
||||
subquestions: |
||||
- variable: persistence.size |
||||
default: "8Gi" |
||||
description: "Volume Size" |
||||
type: string |
||||
label: Volume Size |
||||
required: true |
||||
- variable: persistence.storageClass |
||||
default: "" |
||||
description: "If undefined or null, uses the default StorageClass. Defaults to null." |
||||
type: storageclass |
||||
label: Default storageClass |
||||
- variable: service.port |
||||
default: "3306" |
||||
description: "Service port for access to MySQL" |
||||
type: string |
||||
label: MySQL NodePort number |
||||
required: true |
||||
group: "MySQL Settings" |
||||
- variable: service.type |
||||
default: "ClusterIP" |
||||
description: "MySQL K8s Service type" |
||||
type: enum |
||||
group: "Services and Load Balancing" |
||||
options: |
||||
- "ClusterIP" |
||||
- "NodePort" |
||||
required: true |
||||
label: MySQL Service Type |
||||
show_subquestion_if: "NodePort" |
||||
subquestions: |
||||
- variable: service.nodePort |
||||
default: "" |
||||
description: "NodePort port number(to set explicitly, choose port between 30000-32767)" |
||||
type: int |
||||
min: 30000 |
||||
max: 32767 |
||||
label: Service NodePort number |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
MySQL can be accessed via port 3306 on the following DNS name from within your cluster: |
||||
{{ template "mysql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local |
||||
|
||||
To get your root password run: |
||||
|
||||
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo) |
||||
|
||||
To connect to your database: |
||||
|
||||
1. Run an Ubuntu pod that you can use as a client: |
||||
|
||||
kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il |
||||
|
||||
2. Install the mysql client: |
||||
|
||||
$ apt-get update && apt-get install mysql-client -y |
||||
|
||||
3. Connect using the mysql cli, then provide your password: |
||||
$ mysql -h {{ template "mysql.fullname" . }} -p |
||||
|
||||
To connect to your database directly from outside the K8s cluster: |
||||
{{- if contains "NodePort" .Values.service.type }} |
||||
MYSQL_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}') |
||||
MYSQL_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath='{.spec.ports[0].nodePort}') |
||||
|
||||
{{- else if contains "ClusterIP" .Values.service.type }} |
||||
MYSQL_HOST=127.0.0.1 |
||||
MYSQL_PORT={{ default "3306" .Values.service.port }} |
||||
|
||||
# Execute the following commands to route the connection: |
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "mysql.fullname" . }}" -o jsonpath="{.items[0].metadata.name}") |
||||
kubectl port-forward $POD_NAME {{ default "3306" .Values.service.port }}:{{ default "3306" .Values.service.port }} |
||||
|
||||
{{- end }} |
||||
|
||||
mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD} |
||||
|
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
{{/* vim: set filetype=mustache: */}} |
||||
{{/* |
||||
Expand the name of the chart. |
||||
*/}} |
||||
{{- define "mysql.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). |
||||
*/}} |
||||
{{- define "mysql.fullname" -}} |
||||
{{- $name := default .Chart.Name .Values.nameOverride -}} |
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
||||
{{- end -}} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
{{- if .Values.configurationFiles }} |
||||
apiVersion: v1 |
||||
kind: ConfigMap |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
data: |
||||
{{- range $key, $val := .Values.configurationFiles }} |
||||
{{ $key }}: |- |
||||
{{ $val | indent 4}} |
||||
{{- end }} |
||||
{{- end -}} |
@ -0,0 +1,114 @@
@@ -0,0 +1,114 @@
|
||||
apiVersion: apps/v1beta1 |
||||
kind: Deployment |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
spec: |
||||
template: |
||||
metadata: |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
spec: |
||||
initContainers: |
||||
- name: "remove-lost-found" |
||||
image: "busybox:1.25.0" |
||||
imagePullPolicy: {{ .Values.imagePullPolicy | quote }} |
||||
command: ["rm", "-fr", "/var/lib/mysql/lost+found"] |
||||
volumeMounts: |
||||
- name: data |
||||
mountPath: /var/lib/mysql |
||||
{{- if .Values.persistence.subPath }} |
||||
subPath: {{ .Values.persistence.subPath }} |
||||
{{- end }} |
||||
{{- if .Values.nodeSelector }} |
||||
nodeSelector: |
||||
{{ toYaml .Values.nodeSelector | indent 8 }} |
||||
{{- end }} |
||||
containers: |
||||
- name: {{ template "mysql.fullname" . }} |
||||
image: "{{ .Values.image }}:{{ .Values.imageTag }}" |
||||
imagePullPolicy: {{ .Values.imagePullPolicy | quote }} |
||||
resources: |
||||
{{ toYaml .Values.resources | indent 10 }} |
||||
env: |
||||
{{- if .Values.mysqlAllowEmptyPassword }} |
||||
- name: MYSQL_ALLOW_EMPTY_PASSWORD |
||||
value: "true" |
||||
{{- else }} |
||||
- name: MYSQL_ROOT_PASSWORD |
||||
valueFrom: |
||||
secretKeyRef: |
||||
name: {{ template "mysql.fullname" . }} |
||||
key: mysql-root-password |
||||
- name: MYSQL_PASSWORD |
||||
valueFrom: |
||||
secretKeyRef: |
||||
name: {{ template "mysql.fullname" . }} |
||||
key: mysql-password |
||||
{{- end }} |
||||
- name: MYSQL_USER |
||||
value: {{ default "" .Values.mysqlUser | quote }} |
||||
- name: MYSQL_DATABASE |
||||
value: {{ default "" .Values.mysqlDatabase | quote }} |
||||
ports: |
||||
- name: mysql |
||||
containerPort: 3306 |
||||
livenessProbe: |
||||
exec: |
||||
command: |
||||
{{- if .Values.mysqlAllowEmptyPassword }} |
||||
- mysqladmin |
||||
- ping |
||||
{{- else }} |
||||
- sh |
||||
- -c |
||||
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}" |
||||
{{- end }} |
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} |
||||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }} |
||||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} |
||||
successThreshold: {{ .Values.livenessProbe.successThreshold }} |
||||
failureThreshold: {{ .Values.livenessProbe.failureThreshold }} |
||||
readinessProbe: |
||||
exec: |
||||
command: |
||||
{{- if .Values.mysqlAllowEmptyPassword }} |
||||
- mysqladmin |
||||
- ping |
||||
{{- else }} |
||||
- sh |
||||
- -c |
||||
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}" |
||||
{{- end }} |
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} |
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }} |
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} |
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }} |
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }} |
||||
volumeMounts: |
||||
- name: data |
||||
mountPath: /var/lib/mysql |
||||
{{- if .Values.persistence.subPath }} |
||||
subPath: {{ .Values.persistence.subPath }} |
||||
{{- end }} |
||||
{{- if .Values.configurationFiles }} |
||||
- name: configurations |
||||
mountPath: /etc/mysql/conf.d |
||||
{{- end }} |
||||
volumes: |
||||
{{- if .Values.configurationFiles }} |
||||
- name: configurations |
||||
configMap: |
||||
name: {{ template "mysql.fullname" . }} |
||||
{{- end }} |
||||
- name: data |
||||
{{- if .Values.persistence.enabled }} |
||||
persistentVolumeClaim: |
||||
claimName: {{ .Values.persistence.existingClaim | default (include "mysql.fullname" .) }} |
||||
{{- else }} |
||||
emptyDir: {} |
||||
{{- end -}} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} |
||||
kind: PersistentVolumeClaim |
||||
apiVersion: v1 |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
spec: |
||||
accessModes: |
||||
- {{ .Values.persistence.accessMode | quote }} |
||||
resources: |
||||
requests: |
||||
storage: {{ .Values.persistence.size | quote }} |
||||
{{- if .Values.persistence.storageClass }} |
||||
{{- if (eq "-" .Values.persistence.storageClass) }} |
||||
storageClassName: "" |
||||
{{- else }} |
||||
storageClassName: "{{ .Values.persistence.storageClass }}" |
||||
{{- end }} |
||||
{{- end }} |
||||
{{- end }} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
apiVersion: v1 |
||||
kind: Secret |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
type: Opaque |
||||
data: |
||||
{{ if .Values.mysqlRootPassword }} |
||||
mysql-root-password: {{ .Values.mysqlRootPassword | b64enc | quote }} |
||||
{{ else }} |
||||
mysql-root-password: {{ randAlphaNum 10 | b64enc | quote }} |
||||
{{ end }} |
||||
{{ if .Values.mysqlPassword }} |
||||
mysql-password: {{ .Values.mysqlPassword | b64enc | quote }} |
||||
{{ else }} |
||||
mysql-password: {{ randAlphaNum 10 | b64enc | quote }} |
||||
{{ end }} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
apiVersion: v1 |
||||
kind: Service |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
spec: |
||||
type: {{ .Values.service.type }} |
||||
ports: |
||||
- name: mysql |
||||
port: {{ .Values.service.port }} |
||||
targetPort: mysql |
||||
{{- if .Values.service.nodePort }} |
||||
nodePort: {{ .Values.service.nodePort }} |
||||
{{- end }} |
||||
selector: |
||||
app: {{ template "mysql.fullname" . }} |
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
## mysql image version |
||||
## ref: https://hub.docker.com/r/library/mysql/tags/ |
||||
## |
||||
image: "mysql" |
||||
imageTag: "5.7.14" |
||||
|
||||
## Specify password for root user |
||||
## |
||||
## Default: random 10 character string |
||||
# mysqlRootPassword: testing |
||||
|
||||
## Create a database user |
||||
## |
||||
# mysqlUser: |
||||
# mysqlPassword: |
||||
|
||||
## Allow unauthenticated access, uncomment to enable |
||||
## |
||||
# mysqlAllowEmptyPassword: true |
||||
|
||||
## Create a database |
||||
## |
||||
# mysqlDatabase: |
||||
|
||||
## Specify an imagePullPolicy (Required) |
||||
## It's recommended to change this to 'Always' if the image tag is 'latest' |
||||
## ref: http://kubernetes.io/docs/user-guide/images/#updating-images |
||||
## |
||||
imagePullPolicy: IfNotPresent |
||||
|
||||
## Node selector |
||||
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector |
||||
nodeSelector: {} |
||||
|
||||
livenessProbe: |
||||
initialDelaySeconds: 30 |
||||
periodSeconds: 10 |
||||
timeoutSeconds: 5 |
||||
successThreshold: 1 |
||||
failureThreshold: 3 |
||||
|
||||
readinessProbe: |
||||
initialDelaySeconds: 5 |
||||
periodSeconds: 10 |
||||
timeoutSeconds: 1 |
||||
successThreshold: 1 |
||||
failureThreshold: 3 |
||||
|
||||
## Persist data to a persistent volume |
||||
persistence: |
||||
enabled: true |
||||
## database data Persistent Volume Storage Class |
||||
## If defined, storageClassName: <storageClass> |
||||
## If set to "-", storageClassName: "", which disables dynamic provisioning |
||||
## If undefined (the default) or set to null, no storageClassName spec is |
||||
## set, choosing the default provisioner. (gp2 on AWS, standard on |
||||
## GKE, AWS & OpenStack) |
||||
## |
||||
# storageClass: "-" |
||||
accessMode: ReadWriteOnce |
||||
size: 8Gi |
||||
|
||||
## Configure resource requests and limits |
||||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/ |
||||
## |
||||
resources: |
||||
requests: |
||||
memory: 256Mi |
||||
cpu: 100m |
||||
|
||||
# Custom mysql configuration files used to override default mysql settings |
||||
configurationFiles: |
||||
# mysql.cnf: |- |
||||
# [mysqld] |
||||
# skip-name-resolve |
||||
|
||||
|
||||
## Configure the service |
||||
## ref: http://kubernetes.io/docs/user-guide/services/ |
||||
service: |
||||
## Specify a service type |
||||
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types |
||||
type: ClusterIP |
||||
port: 3306 |
||||
# nodePort: 32000 |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
name: mysql |
||||
version: 0.3.8 |
||||
appVersion: 5.7.14 |
||||
description: Fast, reliable, scalable, and easy to use open-source relational database |
||||
system. |
||||
keywords: |
||||
- mysql |
||||
- database |
||||
- sql |
||||
home: https://www.mysql.com/ |
||||
icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png |
||||
sources: |
||||
- https://github.com/kubernetes/charts |
||||
- https://github.com/docker-library/mysql |
||||
maintainers: |
||||
- name: olemarkus |
||||
email: o.with@sportradar.com |
||||
- name: viglesiasce |
||||
email: viglesias@google.com |
||||
engine: gotpl |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
## Prerequisites |
||||
|
||||
- Kubernetes 1.6+ with Beta APIs enabled |
||||
- PV provisioner support in the underlying infrastructure |
||||
|
||||
## Installing the Chart |
||||
|
||||
By default a random password will be generated for the root user. If you'd like to set your own password change the mysqlRootPassword |
||||
in the values.yaml. |
||||
|
||||
You can retrieve your root password by running the following command. Make sure to replace [YOUR_RELEASE_NAME]: |
||||
|
||||
printf $(printf '\%o' `kubectl get secret [YOUR_RELEASE_NAME]-mysql -o jsonpath="{.data.mysql-root-password[*]}"`) |
||||
|
||||
> **Tip**: List all releases using `helm list` |
||||
|
||||
## Configuration |
||||
|
||||
The following table lists the configurable parameters of the MySQL chart and their default values. |
||||
|
||||
| Parameter | Description | Default | |
||||
| ------------------------------------ | ----------------------------------------- | ---------------------------------------------------- | |
||||
| `imageTag` | `mysql` image tag. | Most recent release | |
||||
| `imagePullPolicy` | Image pull policy | `IfNotPresent` | |
||||
| `mysqlRootPassword` | Password for the `root` user. | `nil` | |
||||
| `mysqlUser` | Username of new user to create. | `nil` | |
||||
| `mysqlPassword` | Password for the new user. | `nil` | |
||||
| `mysqlDatabase` | Name for new database to create. | `nil` | |
||||
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 | |
||||
| `livenessProbe.periodSeconds` | How often to perform the probe | 10 | |
||||
| `livenessProbe.timeoutSeconds` | When the probe times out | 5 | |
||||
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 | |
||||
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 | |
||||
| `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | 5 | |
||||
| `readinessProbe.periodSeconds` | How often to perform the probe | 10 | |
||||
| `readinessProbe.timeoutSeconds` | When the probe times out | 1 | |
||||
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 | |
||||
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 | |
||||
| `persistence.enabled` | Create a volume to store data | true | |
||||
| `persistence.size` | Size of persistent volume claim | 8Gi RW | |
||||
| `nodeSelector` | Node labels for pod assignment | {} | |
||||
| `persistence.storageClass` | Type of persistent volume claim | nil (uses alpha storage class annotation) | |
||||
| `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce | |
||||
| `persistence.existingClaim` | Name of existing persistent volume | `nil` | |
||||
| `persistence.subPath` | Subdirectory of the volume to mount | `nil` | |
||||
| `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `100m` | |
||||
| `configurationFiles` | List of mysql configuration files | `nil` | |
||||
|
||||
Some of the parameters above map to the env variables defined in the [MySQL DockerHub image](https://hub.docker.com/_/mysql/). |
||||
|
||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, |
||||
|
||||
```bash |
||||
$ helm install --name my-release \ |
||||
--set mysqlRootPassword=secretpassword,mysqlUser=my-user,mysqlPassword=my-password,mysqlDatabase=my-database \ |
||||
stable/mysql |
||||
``` |
||||
|
||||
The above command sets the MySQL `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`. |
||||
|
||||
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, |
||||
|
||||
```bash |
||||
$ helm install --name my-release -f values.yaml stable/mysql |
||||
``` |
||||
|
||||
> **Tip**: You can use the default [values.yaml](values.yaml) |
||||
|
||||
## Persistence |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image stores the MySQL data and configurations at the `/var/lib/mysql` path of the container. |
||||
|
||||
By default a PersistentVolumeClaim is created and mounted into that directory. In order to disable this functionality |
||||
you can change the values.yaml to disable persistence and use an emptyDir instead. |
||||
|
||||
> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."* |
||||
|
||||
## Custom MySQL configuration files |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image accepts custom configuration files at the path `/etc/mysql/conf.d`. If you want to use a customized MySQL configuration, you can create your alternative configuration files by passing the file contents on the `configurationFiles` attribute. Note that according to the MySQL documentation only files ending with `.cnf` are loaded. |
||||
|
||||
```yaml |
||||
configurationFiles: |
||||
mysql.cnf: |- |
||||
[mysqld] |
||||
skip-host-cache |
||||
skip-name-resolve |
||||
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
||||
mysql_custom.cnf: |- |
||||
[mysqld] |
||||
``` |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
# MySQL |
||||
|
||||
[MySQL](https://MySQL.org) is one of the most popular database servers in the world. Notable users include Wikipedia, Facebook and Google. |
||||
|
||||
## Introduction |
||||
|
||||
This chart bootstraps a single node MySQL deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
rancher_max_version: 2.3.1 |
||||
categories: |
||||
- Database |
||||
- MySQL |
||||
questions: |
||||
- variable: defaultImage |
||||
default: "true" |
||||
description: "Use default Docker images" |
||||
label: Use Default Images |
||||
type: boolean |
||||
show_subquestion_if: false |
||||
group: "Container Images" |
||||
subquestions: |
||||
- variable: image |
||||
default: "mysql" |
||||
description: "Docker image name" |
||||
type: string |
||||
label: Image Name |
||||
- variable: imageTag |
||||
default: "5.7.14" |
||||
description: "Docker image tag" |
||||
type: string |
||||
label: Image Tag |
||||
- variable: mysqlDatabase |
||||
default: "admin" |
||||
description: "Name of database to create" |
||||
type: string |
||||
required: true |
||||
label: MySQL Database |
||||
group: "MySQL Settings" |
||||
- variable: mysqlUser |
||||
default: "admin" |
||||
description: "Username of user to create" |
||||
type: string |
||||
required: true |
||||
label: MySQL Username |
||||
group: "MySQL Settings" |
||||
- variable: mysqlPassword |
||||
default: "" |
||||
description: "MySQL Password for the new user, defaults to a random 10-character alphanumeric string if not set" |
||||
type: password |
||||
label: MySQL Password |
||||
group: "MySQL Settings" |
||||
- variable: persistence.enabled |
||||
default: "false" |
||||
description: "Enable persistence using PVC" |
||||
type: boolean |
||||
required: true |
||||
label: Persistent Volume Enabled |
||||
show_subquestion_if: true |
||||
group: "Persistent Volume" |
||||
subquestions: |
||||
- variable: persistence.size |
||||
default: "8Gi" |
||||
description: "Volume Size" |
||||
type: string |
||||
label: Volume Size |
||||
required: true |
||||
- variable: persistence.storageClass |
||||
default: "" |
||||
description: "If undefined or null, uses the default StorageClass. Defaults to null." |
||||
type: storageclass |
||||
label: Default storageClass |
||||
- variable: service.port |
||||
default: "3306" |
||||
description: "Service port for access to MySQL" |
||||
type: string |
||||
label: MySQL NodePort number |
||||
required: true |
||||
group: "MySQL Settings" |
||||
- variable: service.type |
||||
default: "ClusterIP" |
||||
description: "MySQL K8s Service type" |
||||
type: enum |
||||
group: "Services and Load Balancing" |
||||
options: |
||||
- "ClusterIP" |
||||
- "NodePort" |
||||
required: true |
||||
label: MySQL Service Type |
||||
show_subquestion_if: "NodePort" |
||||
subquestions: |
||||
- variable: service.nodePort |
||||
default: "" |
||||
description: "NodePort port number(to set explicitly, choose port between 30000-32767)" |
||||
type: int |
||||
min: 30000 |
||||
max: 32767 |
||||
label: Service NodePort number |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
MySQL can be accessed via port 3306 on the following DNS name from within your cluster: |
||||
{{ template "mysql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local |
||||
|
||||
To get your root password run: |
||||
|
||||
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo) |
||||
|
||||
To connect to your database: |
||||
|
||||
1. Run an Ubuntu pod that you can use as a client: |
||||
|
||||
kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il |
||||
|
||||
2. Install the mysql client: |
||||
|
||||
$ apt-get update && apt-get install mysql-client -y |
||||
|
||||
3. Connect using the mysql cli, then provide your password: |
||||
$ mysql -h {{ template "mysql.fullname" . }} -p |
||||
|
||||
To connect to your database directly from outside the K8s cluster: |
||||
{{- if contains "NodePort" .Values.service.type }} |
||||
MYSQL_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}') |
||||
MYSQL_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath='{.spec.ports[0].nodePort}') |
||||
|
||||
{{- else if contains "ClusterIP" .Values.service.type }} |
||||
MYSQL_HOST=127.0.0.1 |
||||
MYSQL_PORT={{ default "3306" .Values.service.port }} |
||||
|
||||
# Execute the following commands to route the connection: |
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "mysql.fullname" . }}" -o jsonpath="{.items[0].metadata.name}") |
||||
kubectl port-forward $POD_NAME {{ default "3306" .Values.service.port }}:{{ default "3306" .Values.service.port }} |
||||
|
||||
{{- end }} |
||||
|
||||
mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD} |
||||
|
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
{{/* vim: set filetype=mustache: */}} |
||||
{{/* |
||||
Expand the name of the chart. |
||||
*/}} |
||||
{{- define "mysql.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). |
||||
*/}} |
||||
{{- define "mysql.fullname" -}} |
||||
{{- $name := default .Chart.Name .Values.nameOverride -}} |
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
||||
{{- end -}} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
{{- if .Values.configurationFiles }} |
||||
apiVersion: v1 |
||||
kind: ConfigMap |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
data: |
||||
{{- range $key, $val := .Values.configurationFiles }} |
||||
{{ $key }}: |- |
||||
{{ $val | indent 4}} |
||||
{{- end }} |
||||
{{- end -}} |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
apiVersion: apps/v1beta1 |
||||
kind: Deployment |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
spec: |
||||
template: |
||||
metadata: |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
spec: |
||||
initContainers: |
||||
- name: "remove-lost-found" |
||||
image: "busybox:1.25.0" |
||||
imagePullPolicy: {{ .Values.imagePullPolicy | quote }} |
||||
command: ["rm", "-fr", "/var/lib/mysql/lost+found"] |
||||
volumeMounts: |
||||
- name: data |
||||
mountPath: /var/lib/mysql |
||||
{{- if .Values.persistence.subPath }} |
||||
subPath: {{ .Values.persistence.subPath }} |
||||
{{- end }} |
||||
{{- if .Values.nodeSelector }} |
||||
nodeSelector: |
||||
{{ toYaml .Values.nodeSelector | indent 8 }} |
||||
{{- end }} |
||||
{{- with .Values.tolerations }} |
||||
tolerations: |
||||
{{ toYaml . | indent 8 }} |
||||
{{- end }} |
||||
containers: |
||||
- name: {{ template "mysql.fullname" . }} |
||||
image: "{{ .Values.image }}:{{ .Values.imageTag }}" |
||||
imagePullPolicy: {{ .Values.imagePullPolicy | quote }} |
||||
resources: |
||||
{{ toYaml .Values.resources | indent 10 }} |
||||
env: |
||||
{{- if .Values.mysqlAllowEmptyPassword }} |
||||
- name: MYSQL_ALLOW_EMPTY_PASSWORD |
||||
value: "true" |
||||
{{- else }} |
||||
- name: MYSQL_ROOT_PASSWORD |
||||
valueFrom: |
||||
secretKeyRef: |
||||
name: {{ template "mysql.fullname" . }} |
||||
key: mysql-root-password |
||||
- name: MYSQL_PASSWORD |
||||
valueFrom: |
||||
secretKeyRef: |
||||
name: {{ template "mysql.fullname" . }} |
||||
key: mysql-password |
||||
{{- end }} |
||||
- name: MYSQL_USER |
||||
value: {{ default "" .Values.mysqlUser | quote }} |
||||
- name: MYSQL_DATABASE |
||||
value: {{ default "" .Values.mysqlDatabase | quote }} |
||||
ports: |
||||
- name: mysql |
||||
containerPort: 3306 |
||||
livenessProbe: |
||||
exec: |
||||
command: |
||||
{{- if .Values.mysqlAllowEmptyPassword }} |
||||
- mysqladmin |
||||
- ping |
||||
{{- else }} |
||||
- sh |
||||
- -c |
||||
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}" |
||||
{{- end }} |
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} |
||||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }} |
||||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} |
||||
successThreshold: {{ .Values.livenessProbe.successThreshold }} |
||||
failureThreshold: {{ .Values.livenessProbe.failureThreshold }} |
||||
readinessProbe: |
||||
exec: |
||||
command: |
||||
{{- if .Values.mysqlAllowEmptyPassword }} |
||||
- mysqladmin |
||||
- ping |
||||
{{- else }} |
||||
- sh |
||||
- -c |
||||
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}" |
||||
{{- end }} |
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} |
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }} |
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} |
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }} |
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }} |
||||
volumeMounts: |
||||
- name: data |
||||
mountPath: /var/lib/mysql |
||||
{{- if .Values.persistence.subPath }} |
||||
subPath: {{ .Values.persistence.subPath }} |
||||
{{- end }} |
||||
{{- if .Values.configurationFiles }} |
||||
- name: configurations |
||||
mountPath: /etc/mysql/conf.d |
||||
{{- end }} |
||||
volumes: |
||||
{{- if .Values.configurationFiles }} |
||||
- name: configurations |
||||
configMap: |
||||
name: {{ template "mysql.fullname" . }} |
||||
{{- end }} |
||||
- name: data |
||||
{{- if .Values.persistence.enabled }} |
||||
persistentVolumeClaim: |
||||
claimName: {{ .Values.persistence.existingClaim | default (include "mysql.fullname" .) }} |
||||
{{- else }} |
||||
emptyDir: {} |
||||
{{- end -}} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} |
||||
kind: PersistentVolumeClaim |
||||
apiVersion: v1 |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
spec: |
||||
accessModes: |
||||
- {{ .Values.persistence.accessMode | quote }} |
||||
resources: |
||||
requests: |
||||
storage: {{ .Values.persistence.size | quote }} |
||||
{{- if .Values.persistence.storageClass }} |
||||
{{- if (eq "-" .Values.persistence.storageClass) }} |
||||
storageClassName: "" |
||||
{{- else }} |
||||
storageClassName: "{{ .Values.persistence.storageClass }}" |
||||
{{- end }} |
||||
{{- end }} |
||||
{{- end }} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
apiVersion: v1 |
||||
kind: Secret |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
type: Opaque |
||||
data: |
||||
{{ if .Values.mysqlRootPassword }} |
||||
mysql-root-password: {{ .Values.mysqlRootPassword | b64enc | quote }} |
||||
{{ else }} |
||||
mysql-root-password: {{ randAlphaNum 10 | b64enc | quote }} |
||||
{{ end }} |
||||
{{ if .Values.mysqlPassword }} |
||||
mysql-password: {{ .Values.mysqlPassword | b64enc | quote }} |
||||
{{ else }} |
||||
mysql-password: {{ randAlphaNum 10 | b64enc | quote }} |
||||
{{ end }} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
apiVersion: v1 |
||||
kind: Service |
||||
metadata: |
||||
name: {{ template "mysql.fullname" . }} |
||||
labels: |
||||
app: {{ template "mysql.fullname" . }} |
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
||||
release: "{{ .Release.Name }}" |
||||
heritage: "{{ .Release.Service }}" |
||||
spec: |
||||
type: {{ .Values.service.type }} |
||||
ports: |
||||
- name: mysql |
||||
port: {{ .Values.service.port }} |
||||
targetPort: mysql |
||||
{{- if .Values.service.nodePort }} |
||||
nodePort: {{ .Values.service.nodePort }} |
||||
{{- end }} |
||||
selector: |
||||
app: {{ template "mysql.fullname" . }} |
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
## mysql image version |
||||
## ref: https://hub.docker.com/r/library/mysql/tags/ |
||||
## |
||||
image: "mysql" |
||||
imageTag: "5.7.14" |
||||
|
||||
## Specify password for root user |
||||
## |
||||
## Default: random 10 character string |
||||
# mysqlRootPassword: testing |
||||
|
||||
## Create a database user |
||||
## |
||||
# mysqlUser: |
||||
# mysqlPassword: |
||||
|
||||
## Allow unauthenticated access, uncomment to enable |
||||
## |
||||
# mysqlAllowEmptyPassword: true |
||||
|
||||
## Create a database |
||||
## |
||||
# mysqlDatabase: |
||||
|
||||
## Specify an imagePullPolicy (Required) |
||||
## It's recommended to change this to 'Always' if the image tag is 'latest' |
||||
## ref: http://kubernetes.io/docs/user-guide/images/#updating-images |
||||
## |
||||
imagePullPolicy: IfNotPresent |
||||
|
||||
## Node selector |
||||
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector |
||||
nodeSelector: {} |
||||
tolerations: [] |
||||
|
||||
livenessProbe: |
||||
initialDelaySeconds: 30 |
||||
periodSeconds: 10 |
||||
timeoutSeconds: 5 |
||||
successThreshold: 1 |
||||
failureThreshold: 3 |
||||
|
||||
readinessProbe: |
||||
initialDelaySeconds: 5 |
||||
periodSeconds: 10 |
||||
timeoutSeconds: 1 |
||||
successThreshold: 1 |
||||
failureThreshold: 3 |
||||
|
||||
## Persist data to a persistent volume |
||||
persistence: |
||||
enabled: true |
||||
## database data Persistent Volume Storage Class |
||||
## If defined, storageClassName: <storageClass> |
||||
## If set to "-", storageClassName: "", which disables dynamic provisioning |
||||
## If undefined (the default) or set to null, no storageClassName spec is |
||||
## set, choosing the default provisioner. (gp2 on AWS, standard on |
||||
## GKE, AWS & OpenStack) |
||||
## |
||||
# storageClass: "-" |
||||
accessMode: ReadWriteOnce |
||||
size: 8Gi |
||||
|
||||
## Configure resource requests and limits |
||||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/ |
||||
## |
||||
resources: |
||||
requests: |
||||
memory: 256Mi |
||||
cpu: 100m |
||||
|
||||
# Custom mysql configuration files used to override default mysql settings |
||||
configurationFiles: |
||||
# mysql.cnf: |- |
||||
# [mysqld] |
||||
# skip-name-resolve |
||||
|
||||
|
||||
## Configure the service |
||||
## ref: http://kubernetes.io/docs/user-guide/services/ |
||||
service: |
||||
## Specify a service type |
||||
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types |
||||
type: ClusterIP |
||||
port: 3306 |
||||
# nodePort: 32000 |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
.git |
||||
OWNERS |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
apiVersion: v1 |
||||
name: webhosting |
||||
version: 1.3.1 |
||||
appVersion: 5.7.14 |
||||
description: Fast, reliable, scalable, and easy to use |
||||
system. |
||||
keywords: |
||||
- mysql |
||||
- database |
||||
- web |
||||
home: https://doc.web.rug.nl |
||||
icon: file://../logo-mysql.png |
||||
sources: |
||||
- https://registry.webhosting.rug.nl/webhosting/ |
||||
maintainers: |
||||
- name: Harm |
||||
email: p.h.vos@rug.nl |
||||
engine: gotpl |
@ -0,0 +1,211 @@
@@ -0,0 +1,211 @@
|
||||
## Prerequisites |
||||
|
||||
- Kubernetes 1.6+ with Beta APIs enabled |
||||
- PV provisioner support in the underlying infrastructure |
||||
|
||||
## Installing the Chart |
||||
|
||||
By default a random password will be generated for the root user. If you'd like to set your own password change the mysqlRootPassword |
||||
in the values.yaml. |
||||
|
||||
You can retrieve your root password by running the following command. Make sure to replace [YOUR_RELEASE_NAME]: |
||||
|
||||
printf $(printf '\%o' `kubectl get secret [YOUR_RELEASE_NAME]-mysql -o jsonpath="{.data.mysql-root-password[*]}"`) |
||||
|
||||
> **Tip**: List all releases using `helm list` |
||||
|
||||
## Configuration |
||||
|
||||
The following table lists the configurable parameters of the MySQL chart and their default values. |
||||
|
||||
| Parameter | Description | Default | |
||||
| -------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------- | |
||||
| `args` | Additional arguments to pass to the MySQL container. | `[]` | |
||||
| `initContainer.resources` | initContainer resource requests/limits | Memory: `10Mi`, CPU: `10m` | |
||||
| `image` | `mysql` image repository. | `mysql` | |
||||
| `imageTag` | `mysql` image tag. | `5.7.14` | |
||||
| `busybox.image` | `busybox` image repository. | `busybox` | |
||||
| `busybox.tag` | `busybox` image tag. | `1.29.3` | |
||||
| `testFramework.image` | `test-framework` image repository. | `dduportal/bats` | |
||||
| `testFramework.tag` | `test-framework` image tag. | `0.4.0` | |
||||
| `imagePullPolicy` | Image pull policy | `IfNotPresent` | |
||||
| `existingSecret` | Use Existing secret for Password details | `nil` | |
||||
| `extraVolumes` | Additional volumes as a string to be passed to the `tpl` function | | |
||||
| `extraVolumeMounts` | Additional volumeMounts as a string to be passed to the `tpl` function | | |
||||
| `extraInitContainers` | Additional init containers as a string to be passed to the `tpl` function | | |
||||
| `mysqlRootPassword` | Password for the `root` user. Ignored if existing secret is provided | Random 10 characters | |
||||
| `mysqlUser` | Username of new user to create. | `nil` | |
||||
| `mysqlPassword` | Password for the new user. Ignored if existing secret is provided | Random 10 characters | |
||||
| `mysqlDatabase` | Name for new database to create. | `nil` | |
||||
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 | |
||||
| `livenessProbe.periodSeconds` | How often to perform the probe | 10 | |
||||
| `livenessProbe.timeoutSeconds` | When the probe times out | 5 | |
||||
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 | |
||||
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 | |
||||
| `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | 5 | |
||||
| `readinessProbe.periodSeconds` | How often to perform the probe | 10 | |
||||
| `readinessProbe.timeoutSeconds` | When the probe times out | 1 | |
||||
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 | |
||||
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 | |
||||
| `schedulerName` | Name of the k8s scheduler (other than default) | `nil` | |
||||
| `persistence.enabled` | Create a volume to store data | true | |
||||
| `persistence.size` | Size of persistent volume claim | 8Gi RW | |
||||
| `persistence.storageClass` | Type of persistent volume claim | nil | |
||||
| `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce | |
||||
| `persistence.existingClaim` | Name of existing persistent volume | `nil` | |
||||
| `persistence.subPath` | Subdirectory of the volume to mount | `nil` | |
||||
| `persistence.annotations` | Persistent Volume annotations | {} | |
||||
| `nodeSelector` | Node labels for pod assignment | {} | |
||||
| `tolerations` | Pod taint tolerations for deployment | {} | |
||||
| `metrics.enabled` | Start a side-car prometheus exporter | `false` | |
||||
| `metrics.image` | Exporter image | `prom/mysqld-exporter` | |
||||
| `metrics.imageTag` | Exporter image | `v0.10.0` | |
||||
| `metrics.imagePullPolicy` | Exporter image pull policy | `IfNotPresent` | |
||||
| `metrics.resources` | Exporter resource requests/limit | `nil` | |
||||
| `metrics.livenessProbe.initialDelaySeconds` | Delay before metrics liveness probe is initiated | 15 | |
||||
| `metrics.livenessProbe.timeoutSeconds` | When the probe times out | 5 | |
||||
| `metrics.readinessProbe.initialDelaySeconds` | Delay before metrics readiness probe is initiated | 5 | |
||||
| `metrics.readinessProbe.timeoutSeconds` | When the probe times out | 1 | |
||||
| `metrics.flags` | Additional flags for the mysql exporter to use | `[]` | |
||||
| `metrics.serviceMonitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` | |
||||
| `metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}` | |
||||
| `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `100m` | |
||||
| `configurationFiles` | List of mysql configuration files | `nil` | |
||||
| `configurationFilesPath` | Path of mysql configuration files | `/etc/mysql/conf.d/` | |
||||
| `securityContext.enabled` | Enable security context (mysql pod) | `false` | |
||||
| `securityContext.fsGroup` | Group ID for the container (mysql pod) | 999 | |
||||
| `securityContext.runAsUser` | User ID for the container (mysql pod) | 999 | |
||||
| `service.annotations` | Kubernetes annotations for mysql | {} | |
||||
| `service.type` | Kubernetes service type | ClusterIP | |
||||
| `service.loadBalancerIP` | LoadBalancer service IP | `""` | |
||||
| `ssl.enabled` | Setup and use SSL for MySQL connections | `false` | |
||||
| `ssl.secret` | Name of the secret containing the SSL certificates | mysql-ssl-certs | |
||||
| `ssl.certificates[0].name` | Name of the secret containing the SSL certificates | `nil` | |
||||
| `ssl.certificates[0].ca` | CA certificate | `nil` | |
||||
| `ssl.certificates[0].cert` | Server certificate (public key) | `nil` | |
||||
| `ssl.certificates[0].key` | Server key (private key) | `nil` | |
||||
| `imagePullSecrets` | Name of Secret resource containing private registry credentials | `nil` | |
||||
| `initializationFiles` | List of SQL files which are run after the container started | `nil` | |
||||
| `timezone` | Container and mysqld timezone (TZ env) | `nil` (UTC depending on image) | |
||||
| `podAnnotations` | Map of annotations to add to the pods | `{}` | |
||||
| `podLabels` | Map of labels to add to the pods | `{}` | |
||||
| `priorityClassName` | Set pod priorityClassName | `{}` | |
||||
| `deploymentAnnotations` | Map of annotations for deployment | `{}` | |
||||
|
||||
Some of the parameters above map to the env variables defined in the [MySQL DockerHub image](https://hub.docker.com/_/mysql/). |
||||
|
||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, |
||||
|
||||
```bash |
||||
$ helm install --name my-release \ |
||||
--set mysqlRootPassword=secretpassword,mysqlUser=my-user,mysqlPassword=my-password,mysqlDatabase=my-database \ |
||||
stable/mysql |
||||
``` |
||||
|
||||
The above command sets the MySQL `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`. |
||||
|
||||
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, |
||||
|
||||
```bash |
||||
$ helm install --name my-release -f values.yaml stable/mysql |
||||
``` |
||||
|
||||
> **Tip**: You can use the default [values.yaml](values.yaml) |
||||
|
||||
## Persistence |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image stores the MySQL data and configurations at the `/var/lib/mysql` path of the container. |
||||
|
||||
By default a PersistentVolumeClaim is created and mounted into that directory. In order to disable this functionality |
||||
you can change the values.yaml to disable persistence and use an emptyDir instead. |
||||
|
||||
> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."* |
||||
|
||||
**Notice**: You may need to increase the value of `livenessProbe.initialDelaySeconds` when enabling persistence by using PersistentVolumeClaim from PersistentVolume with varying properties. Since its IO performance has impact on the database initialization performance. The default limit for database initialization is `60` seconds (`livenessProbe.initialDelaySeconds` + `livenessProbe.periodSeconds` * `livenessProbe.failureThreshold`). Once such initialization process takes more time than this limit, kubelet will restart the database container, which will interrupt database initialization then causing persisent data in an unusable state. |
||||
|
||||
## Custom MySQL configuration files |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image accepts custom configuration files at the path `/etc/mysql/conf.d`. If you want to use a customized MySQL configuration, you can create your alternative configuration files by passing the file contents on the `configurationFiles` attribute. Note that according to the MySQL documentation only files ending with `.cnf` are loaded. |
||||
|
||||
```yaml |
||||
configurationFiles: |
||||
mysql.cnf: |- |
||||
[mysqld] |
||||
skip-host-cache |
||||
skip-name-resolve |
||||
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
||||
mysql_custom.cnf: |- |
||||
[mysqld] |
||||
``` |
||||
|
||||
## MySQL initialization files |
||||
|
||||
The [MySQL](https://hub.docker.com/_/mysql/) image accepts *.sh, *.sql and *.sql.gz files at the path `/docker-entrypoint-initdb.d`. |
||||
These files are being run exactly once for container initialization and ignored on following container restarts. |
||||
If you want to use initialization scripts, you can create initialization files by passing the file contents on the `initializationFiles` attribute. |
||||
|
||||
|
||||
```yaml |
||||
initializationFiles: |
||||
first-db.sql: |- |
||||
CREATE DATABASE IF NOT EXISTS first DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; |
||||
second-db.sql: |- |
||||
CREATE DATABASE IF NOT EXISTS second DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; |
||||
``` |
||||
|
||||
## SSL |
||||
|
||||
This chart supports configuring MySQL to use [encrypted connections](https://dev.mysql.com/doc/refman/5.7/en/encrypted-connections.html) with TLS/SSL certificates provided by the user. This is accomplished by storing the required Certificate Authority file, the server public key certificate, and the server private key as a Kubernetes secret. The SSL options for this chart support the following use cases: |
||||
|
||||
* Manage certificate secrets with helm |
||||
* Manage certificate secrets outside of helm |
||||
|
||||
## Manage certificate secrets with helm |
||||
|
||||
Include your certificate data in the `ssl.certificates` section. For example: |
||||
|
||||
``` |
||||
ssl: |
||||
enabled: false |
||||
secret: mysql-ssl-certs |
||||
certificates: |
||||
- name: mysql-ssl-certs |
||||
ca: |- |
||||
-----BEGIN CERTIFICATE----- |
||||
... |
||||
-----END CERTIFICATE----- |
||||
cert: |- |
||||
-----BEGIN CERTIFICATE----- |
||||
... |
||||
-----END CERTIFICATE----- |
||||
key: |- |
||||
-----BEGIN RSA PRIVATE KEY----- |
||||
... |
||||
-----END RSA PRIVATE KEY----- |
||||
``` |
||||
|
||||
> **Note**: Make sure your certificate data has the correct formatting in the values file. |
||||
|
||||
## Manage certificate secrets outside of helm |
||||
|
||||
1. Ensure the certificate secret exist before installation of this chart. |
||||
2. Set the name of the certificate secret in `ssl.secret`. |
||||
3. Make sure there are no entries underneath `ssl.certificates`. |
||||
|
||||
To manually create the certificate secret from local files you can execute: |
||||
``` |
||||
kubectl create secret generic mysql-ssl-certs \ |
||||
--from-file=ca.pem=./ssl/certificate-authority.pem \ |
||||
--from-file=server-cert.pem=./ssl/server-public-key.pem \ |
||||
--from-file=server-key.pem=./ssl/server-private-key.pem |
||||
``` |
||||
> **Note**: `ca.pem`, `server-cert.pem`, and `server-key.pem` **must** be used as the key names in this generic secret. |
||||
|
||||
If you are using a certificate your configurationFiles must include the three ssl lines under [mysqld] |
||||
|
||||
``` |
||||
[mysqld] |
||||
ssl-ca=/ssl/ca.pem |
||||
ssl-cert=/ssl/server-cert.pem |
||||
ssl-key=/ssl/server-key.pem |
||||
``` |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
# Webhosting |
||||
|
||||
[Webhosting](https://MySQL.org) is one of the most popular database servers in the world. Notable users include Wikipedia, Facebook and Google. |
||||
|
||||
## Introduction |
||||
|
||||
This chart bootstraps a single node MySQL deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
labels: |
||||
io.cattle.role: project # options are cluster/project |
||||
categories: |
||||
- Database |
||||
- MySQL |
||||
questions: |
||||
- variable: defaultImage |
||||
default: true |
||||
description: "Use default Docker images" |
||||
label: Use Default Images |
||||
type: boolean |
||||
show_subquestion_if: false |
||||
group: "Container Images" |
||||
subquestions: |
||||
- variable: image |
||||
default: "ranchercharts/mysql" |
||||
description: "MySQL image name" |
||||
type: string |
||||
label: Image Name |
||||
- variable: imageTag |
||||
default: "5.7.14" |
||||
description: "MySQL image tag" |
||||
type: string |
||||
label: Image Tag |
||||
- variable: busybox.image |
||||
default: "ranchercharts/busybox" |
||||
description: "Busybox image name" |
||||
type: string |
||||
label: Image Image Name |
||||
- variable: busybox.tag |
||||
default: "1.29.3" |
||||
description: "Busybox image tag" |
||||
type: string |
||||
label: Busybox Image Tag |
||||
- variable: mysqlDatabase |
||||
default: "admin" |
||||
description: "Name of database to create" |
||||
type: string |
||||
required: true |
||||
label: MySQL Database |
||||
group: "MySQL Settings" |
||||
- variable: mysqlUser |
||||
default: "admin" |
||||
description: "Username of user to create" |
||||
type: string |
||||
required: true |