> For the complete documentation index, see [llms.txt](https://docs.cennso.com/cennso/cennso-db/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/cennso/cennso-db/latest/installation.md).

# Installation

This document describes how to install the Cennso Database extension and lists its requirements and dependencies.

## Requirements

To install the Cennso Database extension, you must meet the [Cennso Core Cluster requirements](https://docs.cennso.com/cennso/cennso/main/requirements/cc-requirements.md).

The Cennso Database extension has the following requirements and dependencies:

- Cennso in version 2.11 or higher with the following Crossplane versions:

   - Crossplane 1.19 or higher for MySQL (`cennso-db` configuration package)
   - Crossplane 2.0 or higher for PostgreSQL (`cennso-postgresql` configuration package)

- The following Crossplane providers and functions must be installed in the Management Cluster. Cennso installs them for you, so you don't need to install them separately. They are listed here so that you can check that your cluster has everything the extension needs, for example, after a Cennso upgrade:

   | Package | Kind | Used by | Tested version |
   | --- | --- | --- | --- |
   | `xpkg.upbound.io/upbound/provider-kubernetes` | Provider | MySQL, PostgreSQL | `v1.2.0` |
   | `xpkg.upbound.io/upbound/provider-helm` | Provider | MySQL, PostgreSQL | `v1.2.0` |
   | `xpkg.upbound.io/crossplane-contrib/function-go-templating` | Function | MySQL, PostgreSQL | `v0.12.0` |
   | `xpkg.upbound.io/crossplane-contrib/function-auto-ready` | Function | MySQL, PostgreSQL | `v0.6.1` |
   | `xpkg.upbound.io/crossplane-contrib/function-sequencer` | Function | MySQL, PostgreSQL | `v0.5.0` |
   | `xpkg.upbound.io/crossplane-contrib/function-patch-and-transform` | Function | MySQL | `v0.10.1` |

   To check which providers and functions are installed, run the following command on the Management Cluster:

   ```bash
   kubectl get providers.pkg.crossplane.io,functions.pkg.crossplane.io
   ```

   > [!NOTE]
   > The Compositions reference the functions by name, so each `Function` resource must have exactly the following name:
   >
   > - `crossplane-contrib-function-go-templating`
   > - `crossplane-contrib-function-auto-ready`
   > - `crossplane-contrib-function-sequencer`
   > - `crossplane-contrib-function-patch-and-transform`
   >
   > PostgreSQL also uses the namespaced APIs of the providers (`kubernetes.m.crossplane.io` and `helm.m.crossplane.io`), which are available in `provider-kubernetes` and `provider-helm` v1.0.0 or higher.

In addition, you must have:

- Access to a [Cennso Management Cluster](https://docs.cennso.com/cennso/cennso/main/concepts/cluster-architecture.md#management-cluster) to deploy the Cennso Database extension
- Access to a [Core Cluster](https://docs.cennso.com/cennso/cennso/main/concepts/core-cluster.md) to deploy the database workloads
- [Monitoring composition](https://docs.cennso.com/cennso/cennso/latest/concepts/monitoring.md) installed on the Management Cluster

## Installation steps

The Cennso Database extension is installed on the Management Cluster in the same way as any other [Cennso extension](https://docs.cennso.com/cennso/cennso/main/configuration/extensions.md#install-extensions). You can install it using either the Cennso Management Console (CMC) or the CLI:

### Installation steps (CMC)

### CMC

To install the Cennso Database extension using CMC:

1. Go to **Cennso Management -> Packages** and choose the `Cennso DB Extension` tile.
2. Choose the package version, select the target namespace, and specify the extension name.
3. Click **Install** to complete the installation.

### Installation steps (CLI)

### CLI

To install the Cennso Database extension using CLI:

1. Create a YAML file (for example: `cennso-database-package.yaml`) defining a `Package` resource for the Cennso Database extension. For example:

   ```yaml
   apiVersion: extension.cennso.com/v1alpha1
   kind: Package
   metadata:
     labels:
       cennso.com/version: "{PACKAGE-VERSION}"
       extension.cennso.com/name: "extension-cennso-db"
     name: "extension-cennso-db-{PACKAGE-VERSION}"
   spec:
     display:
       name: Cennso DB extension
       description: Cennso extension for the database management.
       categories:
         - configuration
         - database
         - application
     defaultNamespace: {CENNSO-DATABASE-PACKAGE-NAMESPACE}
     destination: ManagementCluster
     documentationURL: https://docs.cennso.com/docs/cennso/cennso-db/{PACKAGE-VERSION}
     projectURL: https://cennso.com
     sources:
       - name: cennso-db
         provider: ConfigurationPackage
         repository: {CONFIGURATION_REPOSITORY}
         tag: {PACKAGE-VERSION}
       - name: cennso-postgresql
         provider: ConfigurationPackage
         repository: {CONFIGURATION_REPOSITORY}
         tag: {PACKAGE-VERSION}
       - name: cennso-db-support
         provider: Helm
         repository: {CHART_REPOSITORY}
         tag: {PACKAGE-VERSION}
         properties:
         - description: Enables PrometheusRule resources.
           label: Alerting enabled
           section: prometheus
           type: boolean
           variable: prometheusRule.enabled
           default: "true"
   ```

   Replace the following placeholders with the values that depend on your needs:

   - `{PACKAGE-VERSION}` - the Cennso Database extension version you want to install
   - `{CENNSO-DATABASE-PACKAGE-NAMESPACE}` - the Kubernetes Namespace name on the Management Cluster where you want to install the package
   - `{CONFIGURATION_REPOSITORY}` - the URL which specifies the source from which the configuration package is installed
   - `{CHART_REPOSITORY}` - the URL which specifies the source from which the Helm chart is installed

2. Apply the YAML manifest with the `Package` resource to the Management Cluster:

   ```bash
   kubectl apply -f cennso-database-package.yaml
   ```

3. Create a YAML file (for example: `cennso-database-extension.yaml`) defining a `ClusterInstallation` resource for the Cennso Database extension. For example:

   ```yaml
   apiVersion: extension.cennso.com/v1alpha1
   kind: ClusterInstallation
   metadata:
     name: {EXTENSION-NAME}-{PACKAGE-VERSION}
     namespace: {NAMESPACE}
   spec:
     forProvider:
       packageRef:
         name: extension-cennso-db
         version: {PACKAGE-VERSION}
   ```

   Replace the following placeholders with the values that depend on your needs:

   - `{EXTENSION-NAME}` - the name of the Cennso Database extension installation
   - `{NAMESPACE}` - the Kubernetes Namespace name on the Management Cluster where you want to install the extension
   - `{PACKAGE-VERSION}` - the Cennso Database extension version you want to install

   > [!IMPORTANT]
   > The `{PACKAGE-VERSION}` in the extension manifest must be the same as the `{PACKAGE-VERSION}` specified in the `Package` resource from step 1.

   > [!NOTE]
   > You can configure values of the Cennso Database Support chart by specifying them in the `spec.forProvider.values.cennso-db-support` section of the `ClusterInstallation` resource. For more information about the available configuration options, see the [Cennso Database Support chart reference](https://docs.cennso.com/cennso/cennso-db/latest/technical-reference/charts/cennso-db-support-chart-configuration.generated.md).

4. Apply the manifest to the Management Cluster using the following command:

   ```bash
   kubectl apply -f cennso-database-extension.yaml
   ```

## Next steps

After installing the Cennso Database extension in the Management Cluster, you can deploy the database operator and database clusters. First, decide whether you want to use MySQL or PostgreSQL, then follow the corresponding guide:

- [Deploy Cennso Database](https://docs.cennso.com/cennso/cennso-db/latest/deployment-guides/cennso-database.md) - deploy a MySQL cluster
- [Deploy Cennso PostgreSQL](https://docs.cennso.com/cennso/cennso-db/latest/deployment-guides/cennso-postgresql.md) - deploy a PostgreSQL cluster

For more information about the resources used for the deployment, read the [Concepts](https://docs.cennso.com/cennso/cennso-db/latest/concepts/concepts.md) documentation.
