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: v3 project_name: "{{ $cndi.get_prompt_response(project_name) }}" provider: "{{ $cndi.get_prompt_response(deployment_target_provider) }}" distribution: "{{ $cndi.get_prompt_response(deployment_target_distribution) }}" region: "{{ $cndi.get_prompt_response(region) }}" 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