Zum Inhalt springen

Connect to your Key Value Store instance

Zuletzt aktualisiert am

After installing, open a shell of your choice and connect to your database. The valkey-cli command supports the connection string format. You need the connection string and the endpoint of your instance to provide the necessary flags. You can look up all these parameters in the Credentials tab of your instance. You will need to extract the endpoint from the connection string.

Terminal window
valkey-cli -u <Connection String> --tls --sni <Endpoint> --cacert /path/to/ca.pem

If you don’t want to expose the password directly in the command line history, you should use this connection format instead:

Terminal window
valkey-cli -h <Endpoint> -p <Port> --user <Username> --sni <Endpoint> --askpass --tls --cacert /path/to/ca.pem

The console will show something like this:

kvd4219b0-master-1.data.eu01.onstackit.cloud:53137>

Now type ping to see if you are connected successfully:

Terminal window
kvd4219b0-master-1.data.eu01.onstackit.cloud:53137> ping

If you are connected properly, the database will answer with:

PONG

Now you can start using the database.

Press CTRL + D to close the connection and return to your command prompt.

Depending on where your Key Value Store instance is hosted, you require a specific CA (Certificate Authority) certificate to establish your secure TLS connection.

If you created your instance through the STACKIT Portal, the service uses public certificates issued by SwissSign.

  • Public projects: Modern operating systems natively trust SwissSign. You can usually connect by using the --tls flag without specifying a certificate. If your system does not trust it (e.g., minimal Docker containers), you must download the SwissSign Root and Intermediate CAs from the SwissSign Repository and pass them through the --cacert flag.
  • Internal projects (Schwarz): Corporate devices natively trust the internal network certificates by default. No manual certificate configuration is required.

If your database runs within the Cloud Foundry runtime, it uses a private Certificate Authority. You must extract this certificate from your service key to connect.

  1. Generate or view your Cloud Foundry service key.

  2. Locate the cacrt field in the JSON output.

  3. Copy the entire certificate string (including -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----).

  4. Replace the \n characters with actual line breaks and save the output to a file named cf_ca.pem.

  5. When connecting through the CLI, append the certificate to your command:

    Terminal window
    valkey-cli -h <Endpoint> -p <Port> --user <Username> --askpass --tls --cacert /path/to/cf_ca.pem