Skip to content

Provision and manage Aiven Services from your Kubernetes cluster.

License

Notifications You must be signed in to change notification settings

aiven/aiven-operator

Folders and files

NameName
Last commit message
Last commit date
Jul 16, 2024
Oct 7, 2024
Sep 17, 2024
Sep 19, 2024
Sep 17, 2024
Sep 17, 2024
Sep 19, 2024
Sep 3, 2024
Feb 5, 2024
May 13, 2024
May 16, 2024
Sep 17, 2024
Jun 24, 2024
Oct 17, 2022
Feb 13, 2023
Sep 3, 2024
Sep 19, 2024
Dec 22, 2023
Jun 25, 2024
Jul 2, 2021
Jun 17, 2024
Jun 24, 2024
Jul 1, 2024
Apr 30, 2024
Sep 19, 2024
Sep 19, 2024
Apr 5, 2024

Repository files navigation

Aiven Operator

Provision and manage Aiven Services from your Kubernetes cluster.

See the full documentation here.

Installation

To install the Operator, please follow the installation instructions.

Deploying PostgreSQL at Aiven

Now let's create a PostgreSQL resource with the following YAML – please fill in your project name under in the project field:

apiVersion: aiven.io/v1alpha1
kind: PostgreSQL
metadata:
  name: aiven-pg
spec:
  # reads the authentication token
  authSecretRef:
    name: aiven-token
    key: token

  # stores the PostgreSQL connection information on the specified Secret
  connInfoSecretTarget:
    name: pg-connection

  project: PROJECT_NAME
  cloudName: google-europe-west1
  plan: hobbyist
  maintenanceWindowDow: friday
  maintenanceWindowTime: 23:00:00
  userConfig:
    pg_version: "15"

Watch the resource being created and wait until its status is RUNNING:

watch kubectl get postgresql.aiven.io aiven-pg

After created, the Operator will create a Kubernetes Secret containing the PostgreSQL connection information:

kubectl describe secret pg-connection

Use the following jq command to decode the Secret:

kubectl get secret pg-connection -o json | jq '.data | map_values(@base64d)'

Connecting to PostgreSQL

Let's run a psql command to test the database connection using the generated Secret:

apiVersion: v1
kind: Pod
metadata:
  name: psql-test-connection
spec:
  restartPolicy: Never
  containers:
    - image: postgres:11
      name: postgres
      command: ["psql", "$(DATABASE_URI)", "-c", "SELECT version();"]
      envFrom:
        - secretRef:
            name: pg-connection

The Pod should the PostgreSQL version. You can verify with the following command:

$ kubectl logs psql-test-connection
                                           version
---------------------------------------------------------------------------------------------
 PostgreSQL 11.12 on x86_64-pc-linux-gnu, compiled by gcc, a 68c5366192 p 6b9244f01a, 64-bit
(1 row)

Contributing

We welcome and encourage contributions to this project. Please take a look at our Contribution guide line.

License

Apache 2.