Skip to content
logo
Percona Operator for PostgreSQL
Generic Kubernetes installation
Initializing search
    percona/k8spg-docs
    percona/k8spg-docs
    • Welcome
      • System Requirements
      • Design and architecture
      • Comparison with other solutions
      • Install with kubectl
      • Install on Google Kubernetes Engine (GKE)
      • Generic Kubernetes installation
        • Verifying the cluster operation
      • Application and system users
      • Exposing the cluster
      • Anti-affinity and tolerations
      • Transport Encryption (TLS/SSL)
      • Telemetry
      • Backup and restore
      • High availability and scaling
      • Monitor with Percona Monitoring and Management (PMM)
      • Add sidecar containers
      • Restart or pause the cluster
      • Custom Resource options
      • Percona certified images
      • Release notes index
      • Percona Operator for PostgreSQL 2.1.0 Tech preview (2023-05-04)
      • Percona Operator for PostgreSQL 2.0.0 Tech preview (2022-12-30)
    • Join K8S Squad

    • Verifying the cluster operation

    Install Percona Distribution for PostgreSQL on Kubernetes¶

    Following steps will allow you to install the Operator and use it to manage Percona Distribution for PostgreSQL in a Kubernetes-based environment.

    1. First of all, clone the percona-postgresql-operator repository:

      $ git clone -b v2.1.0 https://github.com/percona/percona-postgresql-operator
      $ cd percona-postgresql-operator
      

      Note

      It is crucial to specify the right branch with -b option while cloning the code on this step. Please be careful.

    2. The next thing to do is to add the postgres-operator namespace to Kubernetes, not forgetting to set the correspondent context for further steps:

      $ kubectl create namespace postgres-operator
      $ kubectl config set-context $(kubectl config current-context) --namespace=postgres-operator
      

      Note

      To use different namespace, you should edit all occurrences of the namespace: postgres-operator line in both deploy/cr.yaml and deploy/bundle.yaml configuration files.

    3. Deploy the operator with the following command:

      $ kubectl apply --server-side  -f deploy/bundle.yaml
      
    4. After the operator is started Percona Distribution for PostgreSQL can be created at any time with the following command:

      $ kubectl apply -f deploy/cr.yaml
      

      Creation process will take some time. The process is over when both Operator and replica set Pods have reached their Running status:

      $ kubectl get pods
      
      Expected output
      NAME                                           READY   STATUS      RESTARTS   AGE
      cluster1-backup-7hsq-9ch48                     0/1     Completed   0          35s
      cluster1-instance1-mtnz-0                      4/4     Running     0          87s
      cluster1-pgbouncer-f4dcfffc8-lrs2d             2/2     Running     0          87s
      cluster1-repo-host-0                           2/2     Running     0          87s
      percona-postgresql-operator-75fd989d98-wvx4h   1/1     Running     0          109s
      

    Verifying the cluster operation¶

    When creation process is over, you can try to connect to the cluster.

    1. During the installation, the Operator has generated several secrets, including the one with password for default PostgreSQL user. This default user has the login name same as the the cluster.

      Use kubectl get secrets command to see the list of Secrets objects. The Secrets object you are interested in is named as <cluster_name>-pguser-<cluster_name>, so the default variant will be cluster1-pguser-cluster1. You can use the following command to get the password of this user:

      $ kubectl get secret <cluster_name>-<user_name>-<cluster_name> --template='{{.data.password | base64decode}}{{"\n"}}'
      
    2. Run a container with psql tool and connect its console output to your terminal. The following command will do this, naming the new Pod pg-client:

      $ kubectl run -i --rm --tty pg-client --image=perconalab/percona-distribution-postgresql:15 --restart=Never -- bash -il
      [postgres@pg-client /]$ PGPASSWORD='pguser_password' psql -h cluster1-pgbouncer.postgres-operator.svc -p 5432 -U cluster1 cluster1
      

      Executing it may require some time to deploy the correspondent Pod.

      This command will connect you as a cluster1 user to a cluster1 database via the PostgreSQL interactive terminal.

      psql (15)
      SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
      Type "help" for help.
      pgdb=>
      

    Contact Us

    For free technical help, visit the Percona Community Forum.

    To get early access to new product features, invite-only ”ask me anything” sessions with Percona Kubernetes experts, and monthly swag raffles, join K8S Squad.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: 2023-05-22
    Percona LLC and/or its affiliates, © 2009 - 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.