Following these instructions will allow you to install the required Kubernetes environment in addition to postgres-operator, start-to-finish, in no time at all. This is an optimal testing environment.
Follow this link to set up a one-node Kubernetes installation on Vagrant - this will make life much easier for testing.
The kubeadm installation will create /etc/kubernetes/admin.conf for the kubeconfig file you will use to execute the postgres-operator, it needs to be readable from your user account, to enable this change the permissions:
sudo chmod +r /etc/kubernetes/admin.conf
Once you have your Kube VM created, install some of the required dependencies:
sudo apt-get install git gettext
In your .bashrc file, include the following:
export GOPATH=$HOME/odev export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN export COROOT=$GOPATH/src/github.com/crunchydata/postgres-operator export CO_BASEOS=centos7 export CO_VERSION=1.5 export CO_IMAGE_TAG=$CO_BASEOS-$CO_VERSION
Don’t forget to log out and back into the Vagrant machine at this point to refresh your .bashrc file.
Then execute these commands to build the project structure:
mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg mkdir -p $GOPATH/src/github.com/crunchydata/ cd $GOPATH/src/github.com/crunchydata git clone https://github.com/CrunchyData/postgres-operator.git cd postgres-operator
Next, enable Docker for the standard Ubuntu user:
sudo usermod -a -G docker ubuntu
Remember to log out of the Vagrant session for the Docker group to be added to your current session. Once it’s added, you’ll be able to run Docker commands from your user account.
You can ensure your someuser account is added correctly by running the following command and ensuring docker appears as one of the results:
groups
At this point if you want to avoid building the images and binary from source, you can pull down the Docker images as follows:
docker pull crunchydata/lspvc:centos7-1.5 docker pull crunchydata/postgres-operator:centos7-1.5
Then to get the pgo client, go to the Releases page and download the tar ball, uncompress it into your $HOME directory:
cd $HOME wget https://github.com/CrunchyData/postgres-operator/releases/download/v1.5/postgres-operator.1.5.tar.gz tar xvzf ./postgres-operator.1.5.tar.gz
Lastly, add the pgo client into your PATH.
Note: This will create and use /data on your local system as the persistent store for the operator to use for its persistent volume:
cd $COROOT/examples/operator ./deploy.sh kubectl get pod -l 'name=postgres-operator' kubectl get thirdpartyresources
There are example scripts that will create PV and PVC resources that can be used in your testing. Execute the following scripts:
$COROOT/examples/operator/create-pv-nfs.sh $COROOT/examples/operator/create-pv.sh kubectl create -f $COROOT/examples/operator/crunchy-pvc.json
Note that this example will create a PVC called crunchy-pvc that is referenced in the examples and pgo configuration file as the desired PVC to use when databases and clusters are created.
When you first run the operator, it will create the required ThirdPartyResources.
The pgo client requires two configuration files be copied to your $HOME as follows:
cp $COROOT/examples/pgo.yaml.emptydir $HOME/.pgo.yaml cp $COROOT/examples/pgo.lspvc-template.json $HOME/.pgo.lspvc-template.json vi $HOME/.pgo.yaml
Edit the $HOME/.pgo.yaml file changing the following settings:
KUBECONFIG: /etc/kubernetes/admin.conf LSPVC_TEMPLATE: /home/yourid/.pgo.lspvc-template.json
Note that this config file assumes your Kubernetes config file is located in /etc/kubernetes/admin.conf. Update this kubeconfig path to match your local Kube config file location. Also, update the location of the LSPVC_TEMPLATE value to match your $HOME value.
When you first run the operator, it will look for the presence of its third party resources, and create them if not found. You can view the various resources created and used by the operator as follows:
kubectl get thirdpartyresources kubectl get pgclusters kubectl get pgbackups kubectl get pgupgrades kubectl get pgpolicies kubectl get pgclones
At this point, you should be ready to start using the pgo client!