This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a chart for Percona Server (#860)
- Loading branch information
Showing
10 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: percona | ||
version: 0.1.0 | ||
description: free, fully compatible, enhanced, open source drop-in replacement for MySQL | ||
keywords: | ||
- mysql | ||
- percona | ||
- database | ||
- sql | ||
home: https://www.percona.com/ | ||
icon: https://www.percona.com/sites/all/themes/percona2015/logo.png | ||
sources: | ||
- https://github.com/kubernetes/charts | ||
- https://github.com/docker-library/percona | ||
maintainers: | ||
- name: Patrick Galbraith | ||
email: [email protected] | ||
engine: gotpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Percona | ||
|
||
[Percona Server](https://MySQL.org) for MySQL® is a free, fully compatible, enhanced, open source drop-in replacement for MySQL that provides superior performance, scalability and instrumentation. With over 3,000,000 downloads, Percona Server for MySQL's self-tuning algorithms and support for extremely high-performance hardware delivers excellent performance and reliability. | ||
|
||
Notable users include Netflix, Amazon Web Services, Alcatel-Lucent, and Smug Mug. | ||
|
||
## Introduction | ||
|
||
This chart, based off of the MySQL chart, bootstraps a single node Percona Server deployment on a [Kubernetes](http:https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. | ||
|
||
## Prerequisites | ||
|
||
- Kubernetes 1.4+ with Beta APIs enabled | ||
- PV provisioner support in the underlying infrastructure | ||
|
||
## Installing the Chart | ||
|
||
To install the chart with the release name `my-release`: | ||
|
||
```bash | ||
$ helm install --name my-release stable/percona | ||
``` | ||
|
||
The command deploys Percona Server on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. | ||
|
||
By default a random password will be generated for the root user. If you'd like to set your own password change the perconaRootPassword | ||
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]-percona -o jsonpath="{.data.mysql-root-password[*]}"`) | ||
|
||
> **Tip**: List all releases using `helm list` | ||
## Uninstalling the Chart | ||
|
||
To uninstall/delete the `my-release` deployment: | ||
|
||
```bash | ||
$ helm delete my-release | ||
``` | ||
|
||
The command removes all the Kubernetes components associated with the chart and deletes the release. | ||
|
||
## Configuration | ||
|
||
The following tables lists the configurable parameters of the Percona chart and their default values. | ||
|
||
| Parameter | Description | Default | | ||
| ----------------------- | ---------------------------------- | ---------------------------------------------------------- | | ||
| `imageTag` | `percona` image tag. | Most recent release | | ||
| `imagePullPolicy` | Image pull policy | `IfNotPresent` | | ||
| `perconaRootPassword` | Password for the `root` user. | `nil` | | ||
| `perconaUser` | Username of new user to create. | `nil` | | ||
| `perconaPassword` | Password for the new user. | `nil` | | ||
| `perconaDatabase` | Name for new database to create. | `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 (uses alpha storage class annotation) | | ||
| `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce | | ||
| `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `100m` | | ||
|
||
Some of the parameters above map to the env variables defined in the [Percona Server DockerHub image](https://hub.docker.com/_/percona/). | ||
|
||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, | ||
|
||
```bash | ||
$ helm install --name my-release \ | ||
--set mysqlLRootPassword=secretpassword,mysqlUser=my-user,mysqlPassword=my-password,mysqlDatabase=my-database \ | ||
stable/percona | ||
``` | ||
|
||
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/percona | ||
``` | ||
|
||
> **Tip**: You can use the default [values.yaml](values.yaml) | ||
## Persistence | ||
|
||
The [Percona Server](https://hub.docker.com/_/percona/) 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."* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Percona can be accessed via port 3306 on the following DNS name from within your cluster: | ||
{{ template "fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local | ||
|
||
To get your root password run: | ||
|
||
kubectl get secret --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo | ||
|
||
To connect to your database: | ||
|
||
1. Run a percona pod that you can use as a client: | ||
|
||
kubectl run -i --tty percona-client --image=percona:5.7 --restart=Never -- bash -il | ||
|
||
2. Connect using the mysql cli, then provide your password: | ||
$ mysql -h {{ template "fullname" . }} -p | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
*/}} | ||
{{- define "fullname" -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
app: {{ template "fullname" . }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ template "fullname" . }} | ||
annotations: | ||
pod.beta.kubernetes.io/init-containers: '[ | ||
{ | ||
"name": "remove-lost-found", | ||
"image": "busybox:1.25.0", | ||
"command": ["rm", "-fr", "/var/lib/mysql/lost+found"], | ||
"volumeMounts": [ | ||
{ | ||
"name": "data", | ||
"mountPath": "/var/lib/mysql" | ||
} | ||
], | ||
"imagePullPolicy": {{ .Values.imagePullPolicy | quote }} | ||
} | ||
]' | ||
spec: | ||
containers: | ||
- name: {{ template "fullname" . }} | ||
image: "mysql:{{ .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 "fullname" . }} | ||
key: mysql-root-password | ||
- name: MYSQL_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ template "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: | ||
- mysqladmin | ||
- ping | ||
initialDelaySeconds: 30 | ||
timeoutSeconds: 5 | ||
readinessProbe: | ||
exec: | ||
command: | ||
- mysqladmin | ||
- ping | ||
initialDelaySeconds: 5 | ||
timeoutSeconds: 1 | ||
volumeMounts: | ||
- name: data | ||
mountPath: /var/lib/mysql | ||
volumes: | ||
- name: data | ||
{{- if .Values.persistence.enabled }} | ||
persistentVolumeClaim: | ||
claimName: {{ template "fullname" . }} | ||
{{- else }} | ||
emptyDir: {} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if .Values.persistence.enabled }} | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
app: {{ template "fullname" . }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
annotations: | ||
{{- if .Values.persistence.storageClass }} | ||
volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }} | ||
{{- else }} | ||
volume.alpha.kubernetes.io/storage-class: default | ||
{{- end }} | ||
spec: | ||
accessModes: | ||
- {{ .Values.persistence.accessMode | quote }} | ||
resources: | ||
requests: | ||
storage: {{ .Values.persistence.size | quote }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
app: {{ template "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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
app: {{ template "fullname" . }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
spec: | ||
ports: | ||
- name: mysql | ||
port: 3306 | ||
targetPort: mysql | ||
selector: | ||
app: {{ template "fullname" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## percona image version | ||
## ref: https://hub.docker.com/r/library/percona/tags/ | ||
## | ||
imageTag: "5.7.17" | ||
|
||
## 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:https://kubernetes.io/docs/user-guide/images/#updating-images | ||
## | ||
imagePullPolicy: IfNotPresent | ||
|
||
## Persist data to a persitent volume | ||
persistence: | ||
enabled: false | ||
## If defined, volume.beta.kubernetes.io/storage-class: <storageClass> | ||
## Default: volume.alpha.kubernetes.io/storage-class: default | ||
## | ||
# storageClass: | ||
accessMode: ReadWriteOnce | ||
size: 8Gi | ||
|
||
## Configure resource requests and limits | ||
## ref: http:https://kubernetes.io/docs/user-guide/compute-resources/ | ||
## | ||
resources: | ||
requests: | ||
memory: 256Mi | ||
cpu: 100m |