Skip to content

Instantly share code, notes, and snippets.

@xenophenes
Last active September 4, 2017 18:14
Show Gist options
  • Save xenophenes/05552cadbba42c6abcc039aad7273e60 to your computer and use it in GitHub Desktop.
Save xenophenes/05552cadbba42c6abcc039aad7273e60 to your computer and use it in GitHub Desktop.

Revisions

  1. Sarah Conway revised this gist Sep 4, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions install-postgres-operator.adoc
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,6 @@ Follow this link to set up a one-node Kubernetes installation on Vagrant - this

    https://blog.openebs.io/setting-up-kubernetes-1-5-5-cluster-with-vagrant-dda11e33b5bc

    === Configuring Kubernetes

    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:

    ....
  2. Sarah Conway revised this gist Sep 4, 2017. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions install-postgres-operator.adoc
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,14 @@
    = Installing Kubernetes
    = Installing postgres-operator

    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.

    == Installing Kubernetes

    Follow this link to set up a one-node Kubernetes installation on Vagrant - this will make life much easier for testing.

    https://blog.openebs.io/setting-up-kubernetes-1-5-5-cluster-with-vagrant-dda11e33b5bc

    == Configuring Kubernetes
    === Configuring Kubernetes

    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:

    @@ -18,7 +22,7 @@ Once you have your Kube VM created, install some of the required dependencies:
    sudo apt-get install git gettext
    ....

    = Create Project and Clone
    == Create Project and Clone

    In your .bashrc file, include the following:

    @@ -44,7 +48,7 @@ git clone https://github.com/CrunchyData/postgres-operator.git
    cd postgres-operator
    ....

    = Get Packaged Dependencies
    == Get Packaged Dependencies

    Next, enable Docker for the standard Ubuntu user:

    @@ -77,7 +81,7 @@ tar xvzf ./postgres-operator.1.5.tar.gz

    Lastly, add the pgo client into your PATH.

    = Deploy the PostgreSQL Operator
    == Deploy the PostgreSQL Operator

    *Note*: This will create and use /data on your local system as the persistent store for the operator to use for its persistent volume:

    @@ -100,7 +104,7 @@ Note that this example will create a PVC called crunchy-pvc that is referenced i

    When you first run the operator, it will create the required ThirdPartyResources.

    = Configuration
    == Configuration

    The pgo client requires two configuration files be copied to your $HOME as follows:

    @@ -119,7 +123,7 @@ 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.

    = Viewing Operator Resources
    == Viewing Operator Resources

    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:

  3. Sarah Conway created this gist Sep 4, 2017.
    135 changes: 135 additions & 0 deletions install-postgres-operator.adoc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,135 @@
    = Installing Kubernetes

    Follow this link to set up a one-node Kubernetes installation on Vagrant - this will make life much easier for testing.

    https://blog.openebs.io/setting-up-kubernetes-1-5-5-cluster-with-vagrant-dda11e33b5bc

    == Configuring Kubernetes

    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
    ....

    = Create Project and Clone

    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
    ....

    = Get Packaged Dependencies

    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.

    = Deploy the PostgreSQL Operator

    *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.

    = Configuration

    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.

    = Viewing Operator Resources

    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!