Create database
You can create a database in your existing ClickHouse® cluster using a custom ClickhouseDatabase resource.
The ClickhouseDatabase resource must reside in the same namespace as the ClickhouseCluster cluster. The resource name must follow this pattern: <cluster_name>-<database_name>.
Using the CLI
-
Create the
ClickhouseDatabaseresource file, e.g., using thetouch clickhousedatabase.yamlcommand. -
Open the file and paste the configuration below into it:
apiVersion: clickhouse.stackland.yandex.cloud/v1alpha1 kind: ClickhouseDatabase metadata: name: <cluster_name>-<database_name> spec: cluster: <cluster_name> name: <database_name> comment: "Database description"Where:
spec.cluster: Name of theClickhouseClustercluster you are creating the database in.spec.name: Database name in ClickHouse®.spec.comment: Optional comment to the database. Once the database is created, you cannot edit this comment.
-
Apply the manifest:
kubectl apply -f clickhousedatabase.yaml -n <project_name>.
Using the management console
-
If you have not opened a project yet, select one.
-
In the left-hand menu, select ClickHouse® Clusters.
-
Select a cluster.
-
Navigate to the Databases tab.
-
Click Create.
-
Fill out the fields as follows:
- Name: Database name in ClickHouse®.
- Comment: Optional database description.
-
Click Create.
Done. The database will now appear in the list on the Databases tab.