export GOPATH=$HOME/odev mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg mkdir -p $GOPATH/src/github.com/crunchydata/
v2.6, 2018-04-27
To perform an installation of the operator, first create the project structure as follows on your host, here we assume a local directory called odev -
export GOPATH=$HOME/odev mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg mkdir -p $GOPATH/src/github.com/crunchydata/
Next, get a tagged release of the source code -
cd $GOPATH/src/github.com/crunchydata git clone https://github.com/CrunchyData/postgres-operator.git cd postgres-operator git checkout 2.6
To run the operator and the pgo client, you will need the following -
a running Kubernetes or OpenShift cluster
the kubectl or oc clients installed in your PATH and configured to connect to the cluster (e.g. export KUBECONFIG=/etc/kubernetes/admin.conf)
a Kubernetes namespace created and set to where you want the operator installed. For this install we assume a namespace of demo has been created.
kubectl create -f examples/demo-namespace.json kubectl config set-context $(kubectl config current-context) --namespace=demo kubectl config view | grep namespace
|
Warning
|
If you are not using the demo namespace, it will be required to edit the following and change the namespace where the service account and cluster role bindings will be deployed.
|
Permissions are granted to the Operator by means of a Service Account called postgres-operator. That service account is added to the Operator deployment.
The postgres-operator service account is granted cluster-admin priviledges using a cluster role binding postgres-operator-cluster-role-binding.
See here for more details on how to enable RBAC roles and modify the scope of the permissions to suit your needs.
The basic installation uses the default operator configuration settings, these settings assume you want to use HostPath storage on your Kube cluster for database persistence. Other persistent options are available but require the Advanced Installation below.
The default Persistent Volume script assumes a default HostPath directory be created called /data:
sudo mkdir /data sudo chown 777 /data
Create some sample Persistent Volumes using the following script:
export CO_NAMESPACE=demo export CO_CMD=kubectl export COROOT=$GOPATH/src/github.com/crunchydata/postgres-operator go get github.com/blang/expenv $COROOT/pv/create-pv.sh
The following table describes the Makefile targets -
| Target | Description |
|---|---|
all |
compile all binaries and build all images |
setup |
fetch the dependent packages required to build with |
deployoperator |
deploy the Operator (apiserver and postgers-operator) to Kubernetes |
main |
compile the postgres-operator |
runmain |
locally execute the postgres-operator |
pgo |
build the pgo binary |
runpgo |
run the pgo binary |
runapiserver |
run the apiserver binary outside of Kube |
clean |
remove binaries and compiled packages, restore dependencies |
operatorimage |
compile and build the postgres-operator Docker image |
apiserverimage |
compile and build the apiserver Docker image |
lsimage |
build the lspvc Docker image |
loadimage |
build the file load Docker image |
rmdataimage |
build the data deletion Docker image |
release |
build the postgres-operator release |
Next, visit the Deployment page to deploy the Operator, verify the installation, and view various storage configurations.