Skip to content

Integrate Kubernetes with Tiger Cloud

Automate deployment, scaling, and management of your containerized workloads

Kubernetes is an open-source container orchestration system that automates the deployment, scaling, and management of containerized applications. You can connect Kubernetes to Tiger Cloud, and deploy TimescaleDB within your Kubernetes clusters.

This guide explains how to connect a Kubernetes cluster to Tiger Cloud, configure persistent storage, and deploy TimescaleDB in your kubernetes cluster.

To follow the steps on this page:

Integrate TimescaleDB in a Kubernetes cluster

Section titled “Integrate TimescaleDB in a Kubernetes cluster”

To connect your Kubernetes cluster to your Tiger Cloud service:

  1. Create a default namespace for your Tiger Cloud components

    1. Create a namespace:

      Terminal window
      kubectl create namespace timescale
    2. Set this namespace as the default for your session:

      Terminal window
      kubectl config set-context --current --namespace=timescale

    For more information, see Kubernetes Namespaces.

  2. Create a Kubernetes secret that stores your Tiger Cloud service credentials

    Update the following command with your connection details, then run it:

    Terminal window
    kubectl create secret generic timescale-secret \
    --from-literal=PGHOST=<host> \
    --from-literal=PGPORT=<port> \
    --from-literal=PGDATABASE=<dbname> \
    --from-literal=PGUSER=<user> \
    --from-literal=PGPASSWORD=<password>
  3. Configure network access to Tiger Cloud

    • Managed Kubernetes: outbound connections to external databases like Tiger Cloud work by default. Make sure your cluster’s security group or firewall rules allow outbound traffic to Tiger Cloud IP.

    • Self-hosted Kubernetes: If your cluster is behind a firewall or running on-premise, you may need to allow egress traffic to Tiger Cloud. Test connectivity using your connection details:

      Terminal window
      nc -zv <host> <port>

      If the connection fails, check your firewall rules.

  4. Create a Kubernetes deployment that can access your Tiger Cloud

    Run the following command to apply the deployment:

    Terminal window
    kubectl apply -f - <<EOF
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: timescale-app
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: timescale-app
    template:
    metadata:
    labels:
    app: timescale-app
    spec:
    containers:
    - name: timescale-container
    image: postgres:latest
    envFrom:
    - secretRef:
    name: timescale-secret
    EOF
  5. Test the connection

    1. Create and run a pod that uses the connection details you added to timescale-secret in the timescale namespace:

      Terminal window
      kubectl run test-pod --image=postgres --restart=Never \
      --env="PGHOST=$(kubectl get secret timescale-secret -o=jsonpath='{.data.PGHOST}' | base64 --decode)" \
      --env="PGPORT=$(kubectl get secret timescale-secret -o=jsonpath='{.data.PGPORT}' | base64 --decode)" \
      --env="PGDATABASE=$(kubectl get secret timescale-secret -o=jsonpath='{.data.PGDATABASE}' | base64 --decode)" \
      --env="PGUSER=$(kubectl get secret timescale-secret -o=jsonpath='{.data.PGUSER}' | base64 --decode)" \
      --env="PGPASSWORD=$(kubectl get secret timescale-secret -o=jsonpath='{.data.PGPASSWORD}' | base64 --decode)" \
      -- sleep infinity
    2. Launch a psql shell in the test-pod you just created:

      Terminal window
      kubectl exec -it test-pod -- bash -c "psql -h \$PGHOST -U \$PGUSER -d \$PGDATABASE"

    You start a psql session connected to your Tiger Cloud service.

You have successfully integrated Kubernetes with Tiger Cloud.