Install Zalando Postgres operator

2 minute read

This was a bit painful, yet I managed. Used apparently v1.6.2.

Add helm repos

If you pull a little trick you can install the operator using helm, just add a helm repo pointing to the github repo:

# found here: https://git.io/J3C7S
export ZALANDO_BASE=https://raw.githubusercontent.com/zalando/postgres-operator
helm repo add zalando-pg $ZALANDO_BASE/master/charts/postgres-operator/
helm repo add zalando-ui $ZALANDO_BASE/master/charts/postgres-operator-ui/
helm repo update

Install postgres-operator

To use CRD configuration (recommended) this must be present in the helm values.yaml file:

# values.yaml - INCOMPLETE; DO NOT USE; use the one further down.
configTarget: "OperatorConfigurationCRD"

Unfortunately the helm chart is broken, and you have to re-create the default values.yaml file (see also below). Using this file you can now install the operator:

helm upgrade -i \
  --create-namespace -n zalando-pg-operator \
  -f values.yaml \
  pg-operator \
  zalando-pg/postgres-operator

Install operator-ui

Just use default values, so no values.yaml needed.

helm upgrade -i \
  --create-namespace -n zalando-pg-operator \
  pg-operator-ui \
  zalando-ui/postgres-operator-ui

To access the service you have to do a port-forward, since there is no authentication that I know of:

kubectl port-forward svc/pg-operator-ui-postgres-operator-ui 8081:80 -n zalando-pg
curl localhost:8081

Uninstallation

Since it’s helm I’d assume a simple helm uninstall.

Impressions

  • I dislike the helm chart quality.
  • I have a feeling the thing is pretty AWS specific, in the UI you can enable “ELB"s, which is AWS speak for “load balancers”
  • I really like the UI, and I like the way you see which objects are created.

Resources

values.yaml for helm

The settings in the default values.yaml file do not have the correct data type and validation will fail once you try to install it. A working version can be found in this gist or below (identical contents). The file has the exact same values but in the correct data types (so a boolean is actually true and not "true", which is a string and not a bool value).

## INSTALL / UPGRADE:
##   helm upgrade -i --create-namespace -n zalando-pg pg-operator zalando/postgres-operator -f values.yaml

# enable CRD configuration
configTarget: OperatorConfigurationCRD

# the following values ARE THE DEFAULT VALUES. unfortunately they are coded as
# strings in the default values.yaml, and the verification (rightfully) complains
# that either boolean or integer values are needed. so we have to re-include them
# here but with the correct data type.
# the only exceptions to this are the commented-out values, which contain integers,
# but are needed as strings. what a mess.

configGeneral:
  enable_crd_validation: true
  enable_lazy_spilo_upgrade: false
  enable_pgversion_env_var: true
  enable_shm_volume: true
  enable_spilo_wal_path_compat: false
  min_instances: -1
  max_instances: -1
  workers: 8

configKubernetes:
  cluster_labels:
    application: spilo
  enable_init_containers: true
  enable_pod_antiaffinity: false
  enable_pod_disruption_budget: true
  enable_sidecars: true
  spilo_privileged: false
  spilo_allow_privilege_escalation: true

#configPostgresPodResources:
#  default_cpu_limit: 1

configLoadBalancer:
  enable_master_load_balancer: false
  enable_replica_load_balancer: false

configDebug:
  debug_logging: true
  enable_database_access: true

configLoggingRestApi:
  api_port: 8080
  cluster_history_entries: 1000
  ring_log_lines: 100

configAwsOrGcp:
  enable_ebs_gp3_migration: false

configTeamsApi:
  enable_postgres_team_crd: false
  enable_teams_api: false

configConnectionPooler:
  connection_pooler_max_db_connections: 60
  connection_pooler_number_of_instances: 2
  #connection_pooler_default_cpu_limit: 1