-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmysql.yaml
243 lines (211 loc) · 9.08 KB
/
mysql.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
blocks:
- name: mysql-ingress
content:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mysql-ingress
namespace: myinnodbcluster
annotations:
cert-manager.io/cluster-issuer: cluster-issuer
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
spec:
ingressClassName: public
tls:
- hosts:
- "{{ $cndi.get_arg(hostname) }}"
secretName: cluster-issuer-private-key
rules:
- host: "{{ $cndi.get_arg(hostname) }}"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: mycluster
port:
number: 3306
prompts:
- $cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/core-prompts.yaml):
{}
- $cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/core-prompts.yaml):
{}
- name: deploy_argocd_ingress
default: true
message: >-
Do you want to expose ArgoCD with an Ingress?
type: Confirm
- name: argocd_hostname
default: argocd.example.com
message: >-
What hostname should ArgoCD be accessible at?
type: Input
validators:
- hostname # FQDN
condition:
- "{{ $cndi.get_prompt_response(deploy_argocd_ingress) }}"
- ==
- true
- name: deploy_mysql_ingress
default: true
message: >-
Do you want to expose Mysql with an Ingress?
type: Confirm
- name: mysql_hostname
default: mysql.example.com
message: >-
What hostname should Mysql be accessible at?
type: Input
validators:
- hostname # FQDN
condition:
- "{{ $cndi.get_prompt_response(deploy_mysql_ingress) }}"
- ==
- true
- name: rootUser
message: Please enter root username
default: root
type: Input
- name: rootPassword
message: "Please enter root password "
default: password
type: Secret
outputs:
cndi_config:
cndi_version: v2
project_name: "{{ $cndi.get_prompt_response(project_name) }}"
provider: "{{ $cndi.get_prompt_response(deployment_target_provider) }}"
distribution: "{{ $cndi.get_prompt_response(deployment_target_distribution) }}"
infrastructure:
cndi:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/observability-config.yaml):
condition:
- "{{ $cndi.get_prompt_response(deploy_grafana_ingress) }}"
- ==
- true
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/argocd-config.yaml):
condition:
- "{{ $cndi.get_prompt_response(deploy_argocd_ingress) }}"
- ==
- true
cert_manager:
email: "{{ $cndi.get_prompt_response(cert_manager_email) }}"
external_dns:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/external-dns/config/{{ $cndi.get_prompt_response(dns_provider) }}.yaml):
condition:
- "{{ $cndi.get_prompt_response(enable_external_dns) }}"
- ==
- true
nodes:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/basic-node-pool.yaml):
{}
open_ports:
- number: 3306
name: mysql
namespace: myinnodbcluster
service: mycluster
cluster_manifests:
mysql-ingress:
$cndi.get_block(mysql-ingress):
args:
ingress_name: mysql-ingress
hostname: "{{ $cndi.get_prompt_response(mysql_hostname) }}"
condition:
- "{{ $cndi.get_prompt_response(deploy_mysql_ingress) }}"
- ==
- true
mysql-innodb-ns:
apiVersion: v1
kind: Namespace
metadata:
name: myinnodbcluster
mycluster-sa:
apiVersion: v1
kind: ServiceAccount
metadata:
name: mycluster-sa
namespace: myinnodbcluster
mycluster-innodbcluster:
apiVersion: mysql.oracle.com/v2
kind: InnoDBCluster
metadata:
name: mycluster
namespace: myinnodbcluster
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
instances: 3
tlsUseSelfSigned: true
router:
instances: 1
secretName: mysql-secret
imagePullPolicy: IfNotPresent
baseServerId: 1000
version: 8.0.33
serviceAccountName: mycluster-sa
mycnf: |-
[mysqld]
max_connections = 200
require_secure_transport = ON
mycluster-secret:
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
namespace: myinnodbcluster
stringData:
rootUser: $cndi_on_ow.seal_secret_from_env_var(ROOT_USER)
rootHost: $cndi_on_ow.seal_secret_from_env_var(ROOT_HOST)
rootPassword: $cndi_on_ow.seal_secret_from_env_var(ROOT_PASSWORD)
external-dns-secret:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/external-dns/secret/{{ $cndi.get_prompt_response(dns_provider) }}.yaml):
condition:
- "{{ $cndi.get_prompt_response(enable_external_dns) }}"
- ==
- true
applications:
mysqloperator:
repoURL: "https://mysql.github.io/mysql-operator/"
targetRevision: 2.1.0
chart: mysql-operator
destinationNamespace: mysql-operator
env:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/git-credentials-{{ $cndi.get_prompt_response(git_credentials_mode) }}-env.yaml):
{}
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/env.yaml):
{}
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/env.yaml):
{}
$cndi.comment(mysql-heading): Mysql Connection Parameters
ROOT_USER: "{{ $cndi.get_prompt_response(rootUser) }}"
ROOT_HOST: "%"
ROOT_PASSWORD: "{{ $cndi.get_prompt_response(rootPassword) }}"
readme:
project_name: "# {{ $cndi.get_prompt_response(project_name) }}"
$cndi.get_string(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/core-readme.md):
{}
$cndi.get_string(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/core.md):
{}
$cndi.get_string(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/{{ $cndi.get_prompt_response(deployment_target_distribution) }}.md):
{}
mysql: |
# MySQL Deployment Guide
This Template deploys a standalone production-ready MySQL database on a Kubernetes cluster using Helm.
MySQL is a widely used open-source relational database management system that is an essential part of the LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack.
It offers a comprehensive range of features that allow for efficient data storage, retrieval, and management, making it suitable for a vast array of applications, from small web projects to large-scale enterprise solutions.
## Customizing Your Deployment
Adjust your MySQL deployment to meet your specific requirements by modifying the `mycluster-innodbcluster` manifest from the `cluster_manifests` section of your [cndi_config.yaml](cndi_config.yaml) file. Important configuration options include:
- **Persistence:** Enable persistent storage to safeguard your data across pod restarts and deployments.
- **Replication:** Set up replication settings to enhance data durability and availability.
- **Resources:** Allocate appropriate CPU and memory resources to your MySQL pods to ensure optimal performance.
- **Authentication:** Implement authentication mechanisms to secure access to your database.
For an exhaustive list of all configurable parameters and their explanations, refer to the the [CRD Reference](https://dev.mysql.com/doc/mysql-operator/en/mysql-operator-innodbcluster-common.html) from the [MySQLOperator Docs](https://dev.mysql.com/doc/mysql-operator/en/).
## Verifying MySQL Accessibility
**Connect to the Database**:
- Use a MySQL client to connect to your instance, specifying the configured domain, e.g., `mysql.yourdomain.com`.
## Connecting to the Database Step-by-Step
Follow these steps to connect to your MySQL database:
1. **Install a MySQL Client:** If not already available, download and install a MySQL client on your local machine.
MySQL Workbench is a popular GUI client, while the `mysql` command-line tool is widely used