mirror of
https://github.com/clearlinux/dockerfiles.git
synced 2026-11-20 12:59:15 +00:00
Add "Mariadb Deploy with Helm"
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# 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
|
||||
.vscode/
|
||||
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
appVersion: "1.0"
|
||||
description: A Helm chart for Kubernetes
|
||||
name: mariadb
|
||||
version: 0.1.0
|
||||
@@ -0,0 +1,101 @@
|
||||
# Clear Linux* OS `mariadb` Helm Charts
|
||||
|
||||
<!-- Required -->
|
||||
## What is this image?
|
||||
|
||||
`clearlinux/mariadb` is a Docker image with `mariadb` running on top of the
|
||||
[official clearlinux base image](https://hub.docker.com/_/clearlinux).
|
||||
|
||||
<!-- application introduction -->
|
||||
|
||||
> [Mariadb](https://mariadb.com/) is a community-developed, commercially supported
|
||||
> fork of the MySQL relational database management system (RDBMS), intended to remain
|
||||
> free and open-source software under the GNU General Public License. Development is led
|
||||
> by some of the original developers of MySQL, who forked it due to concerns over its
|
||||
> acquisition by Oracle Corporation
|
||||
|
||||
For other Clear Linux* OS
|
||||
based container images, see: https://hub.docker.com/u/clearlinux
|
||||
|
||||
## Why use a clearlinux based image?
|
||||
|
||||
<!-- CL introduction -->
|
||||
|
||||
> [Clear Linux* OS](https://clearlinux.org/) is an open source, rolling release
|
||||
> Linux distribution optimized for performance and security, from the Cloud to
|
||||
> the Edge, designed for customization, and manageability.
|
||||
|
||||
Clear Linux* OS based container images use:
|
||||
|
||||
- Optimized libraries that are compiled with latest compiler versions and
|
||||
flags.
|
||||
- Software packages that follow upstream source closely and update frequently.
|
||||
- An aggressive security model and best practices for CVE patching.
|
||||
- A multi-staged build approach to keep a reduced container image size.
|
||||
- The same container syntax as the official images to make getting started
|
||||
easy.
|
||||
|
||||
To learn more about Clear Linux* OS, visit: https://clearlinux.org.
|
||||
|
||||
<!-- Required -->
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- PV provisioner support in the underlying infrastructure
|
||||
|
||||
## Installing the Mariadb Chart
|
||||
|
||||
Download the mariadb chart and install the chart with the release name ` my-release`
|
||||
|
||||
```
|
||||
$ helm install --name my-release mariadb
|
||||
```
|
||||
|
||||
## Uninstalling the Chart
|
||||
|
||||
To uninstall/delete the `my-release` deployment:
|
||||
|
||||
```
|
||||
$ helm delete my-release
|
||||
```
|
||||
|
||||
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
||||
|
||||
## Parameters
|
||||
|
||||
The following table lists the configurable parameters of the MariaDB chart and their default values.
|
||||
|
||||
| Parameter | Description | Default |
|
||||
| ------------------------ | ---------------------------------------------- | ------------------------------ |
|
||||
| `image.replicaCount` | Mariadb pod count | `2` |
|
||||
| `image.repository` | MariaDB image repository | `docker.io/clearlinux/mariadb` |
|
||||
| `image.imagepullPolicy` | MariaDB image pull policy | `IfNotPresent` |
|
||||
| `service.type` | MariaDB service type | `NodePort` |
|
||||
| `service.port` | MariaDB service port | `3306` |
|
||||
| `service.targetPort` | MariaDB service targetPort | `3306` |
|
||||
| `service.nodePort` | MariaDB service nodePort | `30001` |
|
||||
| `config.enabled` | If apply custom config file to Mariadb service | `True` |
|
||||
| `config.content` | custom file content | `your own custom conf` |
|
||||
| `config.name` | config volume name | `config-volume` |
|
||||
| `mariadbRootPassword` | Mariadb Root Password | `nil` |
|
||||
| `mariadbUser` | Mariadb User Name | `nil` |
|
||||
| `mariadbPassword` | Mariadb User Password | `nil` |
|
||||
| `persistence.enabled` | if pv is enabled to Mariadb service | `True` |
|
||||
| `persistence.accessMode` | pv accessMode for Mariadb service | `ReadWriteMany` |
|
||||
| `persistence.size` | pv size for Mariadb service | `1Gi` |
|
||||
|
||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
||||
|
||||
```
|
||||
$ helm install --name my-release \
|
||||
--set mariadbRootPassword=<your-root-password>,mariadbUser=<your-user-name>,mariadbPassword=<your-user-password> mariadb
|
||||
```
|
||||
|
||||
The above command sets MariaDB `root` account password to `<your-root-password>`, MariaDB `user` account password to `<your-user-password>` and MariaDB `user` account name to `<your-user-name>`.
|
||||
|
||||
<!-- Required -->
|
||||
|
||||
## Licenses
|
||||
|
||||
All licenses for the Clear Linux* Project and distributed software can be found
|
||||
at https://clearlinux.org/terms-and-policies
|
||||
@@ -0,0 +1,21 @@
|
||||
1. Get the application URL by running these commands:
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
{{- range .paths }}
|
||||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mariadb.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mariadb.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mariadb.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mariadb.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl port-forward $POD_NAME 8080:80
|
||||
{{- end }}
|
||||
@@ -0,0 +1,56 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "mariadb.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 "mariadb.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 "mariadb.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "mariadb.labels" -}}
|
||||
app.kubernetes.io/name: {{ include "mariadb.name" . }}
|
||||
helm.sh/chart: {{ include "mariadb.chart" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "mariadb.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{ default (include "mariadb.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,11 @@
|
||||
{{- if .Values.config.enabled }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
labels:
|
||||
{{ include "mariadb.labels" . | indent 4 }}
|
||||
data:
|
||||
my.cnf: |-
|
||||
{{ .Values.config.content | indent 4 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,58 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
labels:
|
||||
{{ include "mariadb.labels" . | indent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.image.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ include "mariadb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ include "mariadb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
spec:
|
||||
volumes:
|
||||
{{- if .Values.config.enabled }}
|
||||
- name: {{ .Values.config.name }}
|
||||
configMap:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.enabled }}
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "mariadb.fullname" . }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: mariadb
|
||||
image: {{ .Values.image.repository }}
|
||||
ports:
|
||||
- containerPort: 3306
|
||||
name: db-port
|
||||
imagePullPolicy: {{ .Values.image.imagePullPolicy }}
|
||||
volumeMounts:
|
||||
{{- if .Values.config.enabled }}
|
||||
- name: {{ .Values.config.name }}
|
||||
mountPath: /usr/share/defaults/mariadb/my.cnf.d
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.enabled }}
|
||||
- name: data
|
||||
mountPath: /var/lib/mysql
|
||||
{{- end }}
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
key: mariadb-root-password
|
||||
- name: MYSQL_USER
|
||||
value: {{ .Values.mariadbUser | quote }}
|
||||
- name: MYSQL_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
key: mariadb-password
|
||||
@@ -0,0 +1,14 @@
|
||||
{{- if .Values.persistence.enabled }}
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
labels:
|
||||
{{ include "mariadb.labels" . | indent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.accessMode | quote }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size | quote }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
labels:
|
||||
{{ include "mariadb.labels" . | indent 4 }}
|
||||
type: Opaque
|
||||
data:
|
||||
mariadb-root-password: {{ default "" .Values.mariadbRootPassword | b64enc | quote }}
|
||||
mariadb-password: {{ default "" .Values.mariadbPassword | b64enc | quote }}
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "mariadb.fullname" . }}
|
||||
labels:
|
||||
{{ include "mariadb.labels" . | indent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.service.targetPort }}
|
||||
nodePort: {{ .Values.service.nodePort }}
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ include "mariadb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
@@ -0,0 +1,44 @@
|
||||
# Default values for mariadb.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
image:
|
||||
replicaCount: 2
|
||||
repository: docker.io/clearlinux/mariadb
|
||||
imagePullPolicy: IfNotPresent
|
||||
|
||||
service:
|
||||
type: NodePort
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
nodePort: 30001
|
||||
|
||||
config:
|
||||
enabled: True
|
||||
name: config-volume
|
||||
content: |-
|
||||
[galera]
|
||||
bind-address=0.0.0.0
|
||||
|
||||
[mysqld]
|
||||
skip-log-bin
|
||||
ssl=0
|
||||
table_open_cache = 200000
|
||||
table_open_cache_instances=64
|
||||
|
||||
mariadbRootPassword:
|
||||
mariadbUser:
|
||||
mariadbPassword:
|
||||
|
||||
persistence:
|
||||
enabled: True
|
||||
accessMode: ReadWriteMany
|
||||
size: 1Gi
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
annotations: {}
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths: []
|
||||
tls: []
|
||||
Reference in New Issue
Block a user