This plugin is a prototype developed as a part of GSoC 2019 under the organisation The Postgres Operator
https://github.com/VineethReddy02/GSoC-Kubectl-Plugin-for-Postgres-Operator-tracker
https://gist.github.com/VineethReddy02/159283bd368a710379eaf0f6bd60a40a
This project uses Go Modules for dependency management to build locally
Install go and enable go modules export GO111MODULE=on
From Go >=1.13 Go modules will be enabled by default
# Assumes you have a working KUBECONFIG
$ GO111MODULE="on"
# As of now go by default doesn't support Go mods. So explicit enabling is required.
$ GOPATH/src/github.com/zalando/postgres-operator/kubectl-pg go mod vendor
# This generate a vendor directory with all dependencies needed by the plugin.
$ $GOPATH/src/github.com/zalando/postgres-operator/kubectl-pg go install
# This will place the kubectl-pg binary in your $GOPATH/bin
Ideally KUBECONFIG is found in $HOME/.kube/config else specify the KUBECONFIG path here.
export KUBECONFIG=$HOME/.kube/config
kubectl pg --help (or) kubectl pg
kubectl pg check
kubectl pg create -f acid-minimal-cluster.yaml
kubectl pg update -f acid-minimal-cluster.yaml
kubectl pg delete -f acid-minimal-cluster.yaml
kubectl pg delete acid-minimal-cluster
--namespace or -n flag to specify namespace if cluster is in other namespace.
kubectl pg delete acid-minimal-cluster -n namespace01
kubectl pg list
kubectl pg list all
kubectl pg add-user USER01 -p CREATEDB,LOGIN -c acid-minimal-cluster
Privileges can only be [SUPERUSER, REPLICATION, INHERIT, LOGIN, NOLOGIN, CREATEROLE, CREATEDB, BYPASSURL]
Note: A login user is created by default unless NOLOGIN is specified, in which case the operator creates a role.
kubectl pg add-db DB01 -o OWNER01 -c acid-minimal-cluster
kubectl pg ext-volume 2Gi -c acid-minimal-cluster
kubectl pg version (optional -n NAMESPACE allows to know specific to a namespace)
kubectl pg connect -c CLUSTER #This connects to a random pod
kubectl pg connect -c CLUSTER -m #This connects the master
kubectl pg connect -c CLUSTER -r 0 #This connects to the desired replica
kubectl pg connect -c CLUSTER -p -u username #This connects to a random pod. Not master
kubectl pg connect -c CLUSTER -m -p -u username #This connects the master
kubectl pg connect -c CLUSTER -r 0 -p -u username #This connects to the desired replica
Note: -p represents psql prompt
kubectl pg logs -o
kubectl pg logs -c CLUSTER #Fetches the logs of a random pod. Not master
kubectl pg logs -c CLUSTER -m #Fetches the logs of master
kubectl pg logs -c CLUSTER -r 2 #Fecthes the logs of specified replica
- When making changes to plugin make sure to change the major or patch version
of plugin in
build.shand run./build.sh