Creating a Postgres Operator Release

The Postgres operator is the controller for Postgres instances resources. You install the Postgres operator using the Helm package manager.

Edit the Operator Configuration

The file operator/values.yaml in the Tanzu SQL with Postgres directory specifies the location of the Postgres operator and instance images.

  • You may edit this file to confirm the container registry location to which you uploaded the images (see Push Docker Images to a Container Registry), and also to verify that the value of the dockerRegistrySecretName field in the operator/values.yaml matches the secret you created in Create Kubernetes Access Secret.

  • Alternatively, you may create a values-overrides.yaml (choose your own name) configuration file under the same location, where you can specify the container registry and secret.

  • For manual changes, you may also set individual parameters using the --set flag on the command line.

See Helm Values Files in the Helm documentation for more information.

If you are using a single node Minikube environment, it is not necessary to edit the operator/values.yaml file because Minikube pulls the images from its local Docker registry.

  1. Go to the directory where you unpacked the Tanzu SQL with Postgres distribution.

    $ cd postgres-v*
    
  2. Edit the file operator/values.yaml.

    • Add the container registry location to the operatorImageRepository value. For Google Cloud Registry, for example:
      operatorImageRepository: gcr.io/my-project/postgres-operator
    
    • Add the container registry location to the postgresImageRepository value. For example:
      postgresImageRepository: gcr.io/my-project/postgres-instance
    

    If you choose to create a values-overrides.yaml file instead, enter these lines in the file, replacing ${REGISTRY} with your private container registry name:

      operatorImageRepository: ${REGISTRY}/postgres-operator
      postgresImageRepository: ${REGISTRY}/postgres-instance
    
  3. Save the file.

Create the Postgres Operator Release

  1. Use Helm to install the Postgres operator in your Kubernetes cluster.

    $ helm install postgres-operator operator/
    

    or

    $ helm install postgres-operator -f operator/values-overrides.yaml operator/
    

    Helm begins installing the new release into the Kubernetes namespace specified in the current Kubernetes context.

    The command displays the following message:

    NAME: postgres-operator
    LAST DEPLOYED: Tue Jun 16 13:28:05 2020
    NAMESPACE: default
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    
  2. Use the command watch kubectl get all to monitor the progress of the deployment. The deployment is complete when the Postgres operator pod status changes to Running.

    $ watch kubectl get all
    
    Every 2.0s: kubectl get all
    
    NAME                                     READY   STATUS    RESTARTS   AGE
    pod/postgres-operator-58b6746b66-v2tn7   1/1     Running   0          2m57s
    
    NAME                                        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
    service/kubernetes                          ClusterIP   10.8.0.1     <none>        443/TCP   30m
    service/postgres-operator-webhook-service   ClusterIP   10.8.14.56   <none>        443/TCP   2m57s
    
    NAME                                READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/postgres-operator   1/1     1            1           2m58s
    
    NAME                                           DESIRED   CURRENT   READY   AGE
    replicaset.apps/postgres-operator-58b6746b66   1         1         1       2m58s
    

Next steps

After you install the Postgres Operator, you can use it to deploy and manage Postgres instances. To interact with the Postgres Operator, you place a set of instructions into a YAML-formatted configuration file (a Kubernetes manifest) and then use the kubectl utility to send the file instructions to the operator. The Postgres Operator is then responsible for following the instructions that you provide, and also for maintaining the state of the Postgres instance according to the properties that you defined.

For more details, see: