<?xml version="1.0" encoding="UTF-8" ?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0"><channel><title>Patrick McLaughlin | CrunchyData Blog</title>
<atom:link href="https://www.crunchydata.com/blog/author/patrick-mclaughlin/rss.xml" rel="self" type="application/rss+xml" />
<link>https://www.crunchydata.com/blog/author/patrick-mclaughlin</link>
<image><url>https://www.crunchydata.com/build/_assets/default.png-W4XGD4DB.webp</url>
<title>Patrick McLaughlin | CrunchyData Blog</title>
<link>https://www.crunchydata.com/blog/author/patrick-mclaughlin</link>
<width>256</width>
<height>256</height></image>
<description>PostgreSQL experts from Crunchy Data share advice, performance tips, and guides on successfully running PostgreSQL and Kubernetes solutions</description>
<language>en-us</language>
<pubDate>Thu, 13 Jun 2019 05:00:00 EDT</pubDate>
<dc:date>2019-06-13T09:00:00.000Z</dc:date>
<dc:language>en-us</dc:language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<item><title><![CDATA[ Deploying the PostgreSQL Operator on GKE ]]></title>
<link>https://www.crunchydata.com/blog/install-postgres-operator-kubernetes-on-gke-ansible</link>
<description><![CDATA[ Guide to installing the Crunchy PostgreSQL Operator for Kubernetes on Google Cloud Platform GKE using Ansible ]]></description>
<content:encoded><![CDATA[ <p>The <a href=/blog/crunchy-postgres-kubernetes-operator-4.0>Crunchy PostgreSQL Operator 4.0</a> provides an open source PostgreSQL-as-a-Service for Kubernetes platform.<p>This post provides some easy steps to help you get started, specifically deploying the Crunchy PostgreSQL Operator in <a href=https://cloud.google.com/kubernetes-engine/><dfn>Google Kubernetes Engine</dfn> (<abbr>GKE</abbr>)</a> making use of the <a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/installation/install-with-ansible/>Crunchy PostgreSQL Operator Ansible Installer</a>.<h2 id=postgresql-operator-ansible-installer><a href=#postgresql-operator-ansible-installer>PostgreSQL Operator Ansible Installer</a></h2><p>The Crunchy PostgreSQL Operator 4.0 provides <a href=https://www.ansible.com/>Ansible</a> playbooks to automate the installation. These Ansible playbooks allow users to deploy the operator to a variety of Kubernetes platforms and automate a number of installation steps, including:<ul><li>Generate TLS certificates required by the PostgreSQL Operator<li>Configure PostgreSQL Operator settings from a single inventory file</ul><h2 id=preparation-of-gke-environment><a href=#preparation-of-gke-environment>Preparation of GKE Environment</a></h2><p>Given that this example leverages GKE, perhaps it goes without saying that you must be either an existing GKE user or begin by creating a GKE account.<p><em>If you are an existing GKE user</em>, with the Google Cloud SDK installed and Kubernetes Engine Admin privileges, you can move on to "<strong>Installation of the PostgreSQL Operator Playbooks"</strong><p><em>If you are not currently a GKE user</em>, Google Cloud Platform provides a <a href=https://cloud.google.com/kubernetes-engine/docs/quickstart>quickstart</a> with the necessary steps. A few tips to consider:<ul><li><p>Ensure that the <a href=https://console.cloud.google.com/apis/library/container.googleapis.com/>Google Kubernetes Engine API</a> is enabled for your project. If you do not see “API enabled”, then you may enable the API by clicking the “Enable this API” button.<li><p>It is necessary to install and configure the <a href=https://cloud.google.com/sdk/docs/>Google Cloud SDK</a> and include the kubectl component.<li><p>Set your default compute service account to include: (1) Kubernetes Engine Admin and (2) Editor (on by default). To set this up, navigate to the IAM section of the <a href=https://console.cloud.google.com/iam-admin/iam/project>Cloud Console.</a></ul><h2 id=installation-of-the-postgresql-operator-playbooks><a href=#installation-of-the-postgresql-operator-playbooks>Installation of the PostgreSQL Operator Playbooks</a></h2><p>The Crunchy PostgreSQL Operator roles associated with the Crunchy PostgreSQL Operator Installer are available in the <a href=https://github.com/CrunchyData/postgres-operator>postgres-operator project</a> repository. These roles are dependent on Ansible 2.4.6+.<p>In order to deploy those roles it is necessary to clone that repository in your local environment.<h2 id=configuration-of-permissions><a href=#configuration-of-permissions><strong>Configuration of Permissions</strong></a></h2><p>The installation of the Crunchy PostgreSQL Operator requires elevated privileges. In particular, it is required that the playbooks are run as a cluster-admin to ensure the playbooks can install:<ul><li><a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/gettingstarted/design/designoverview/#custom-resource-definitions-1>Custom Resource Definitions</a><li><a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/security/#operator-rbac>Cluster RBAC</a><li><a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/gettingstarted/design/namespace/>Create required namespaces</a></ul><p>Please confirm that you have the necessary cluster-admin privileges before proceeding.<h3 id=configuration-of-operator-variables-in-the-inventory-file><a href=#configuration-of-operator-variables-in-the-inventory-file>Configuration of Operator Variables in the Inventory File</a></h3><p>The <a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/installation/install-with-ansible/prerequisites/>inventory file</a> included with the PostgreSQL Operator Playbooks allows the Ansible installer to configure how the operator will function when deployed into Kubernetes.<p>The table provided at the end of this post under the heading "<a href=#more-information---default-installation-configurations><strong>More Information - Default Installation Configurations</strong></a>" provides a list of the installed operator variables implemented by the Ansible playbook.<p>It is of course worth noting that these values are provided for a simple single zone, "getting started" deployment to evaluate and test the operator, and are not intended for production environments.<p>This table is provided for your information only, no action is required to complete the install.<h2 id=install-the-postgresql-operator><a href=#install-the-postgresql-operator>Install the PostgreSQL Operator</a></h2><p>In order to install the PostgreSQL Operator, it is necessary to simply run the following command:<pre><code class=language-shell>ansible-playbook -i /path/to/inventory --tags=install --ask-become-pass main.yml
</code></pre><p>This may take a few minutes to deploy.<h2 id=verifying-the-installation><a href=#verifying-the-installation>Verifying the Installation</a></h2><p>To check the status of the deployment run the following:<pre><code class=language-shell>kubectl get deployments -n pgo
kubectl get pods -n pgo
</code></pre><p>After the Crunchy PostgreSQL Operator has successfully been installed we will need to configure local environment variables before using the pgo client.<p>To configure the environment variables used by pgo run the following command:<pre><code class=language-shell>cat &#60&#60EOF >> ~/.bashrc
export PGO_NAMESPACE=pgo
export PGOUSER="${HOME?}/.pgo/pgo/pgouser"
export PGO_CA_CERT="${HOME?}/.pgo/pgo/client.crt"
export PGO_CLIENT_CERT="${HOME?}/.pgo/pgo/client.crt"
export PGO_CLIENT_KEY="${HOME?}/.pgo/pgo/client.pem"
export PGO_APISERVER_URL='https://127.0.0.1:8443'
EOF
</code></pre><p>Apply those changes to the current session by running:<pre><code class=language-shell>source ~/.bashrc
</code></pre><h2 id=verify-pgo-connection><a href=#verify-pgo-connection>Verify pgo Connection</a></h2><p>In a separate terminal we need to setup a port forward to the Crunchy PostgreSQL Operator to ensure connection can be made outside of the cluster:<pre><code class=language-shell>kubectl port-forward &#60OPERATOR_POD_NAME> -n pgo 8443:8443
</code></pre><p>On a separate terminal verify the pgo can communicate with the Crunchy PostgreSQL Operator:<pre><code class=language-shell>pgo version
</code></pre><p>If the above command outputs versions of both the client and API server, the Crunchy PostgreSQL Operator has been installed successfully.<h2 id=ready-to-deploy-postgresql-clusters><a href=#ready-to-deploy-postgresql-clusters>Ready to Deploy PostgreSQL Clusters</a></h2><p>With the Crunchy PostgreSQL Operator Installed, you are ready to go.<p>Crunchy PostgreSQL Operator extends Kubernetes to support the creation, configuration and management of PostgreSQL clusters at scale. Built on top of the Crunchy PostgreSQL Container Suite, the Crunchy PostgreSQL Operator provides an open source software solution for PostgreSQL scaling, high-availability, disaster recovery, monitoring, and more.<p>You can find out more about the available PostgreSQL Operator commands available <a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/operatorcli/pgo-overview/>here</a>. To view all of the commands available you can run <code>pgo --help</code> or review the PGO CLI command help <a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/operatorcli/cli/>here</a>.<h2 id=more-information---default-installation-configurations><a href=#more-information---default-installation-configurations>More Information - Default Installation Configurations</a></h2><p>The Crunchy PostgreSQL Operator enables enterprise to deploy Kubernetes native PostgreSQL-as-a-Service. In order to support a broad range of enterprise requirements, the Operator provides a number of configuration variables that are intended to enable a broad range of use cases.<p>To learn more about the range of configuration options in the Crunchy PostgreSQL Operator, please see the <a href=https://access.crunchydata.com/documentation/postgres-operator/4.0.0/configuration/>Operator documentation</a>.<p>The table provided below reflects the installed operator variables implemented by the Ansible playbook. It is worth repeating that these default values are provided for a simple single zone, "getting started" deployment to evaluate and test the operator, and are not intended for production environments.</p><figure>
<figcaption><p><strong><em>Default Operator Configurations from Ansible Install</em></strong></p></figcaption><table><thead><tr><th>Configuration Variable<th>Configuration Variable Notes<th>Ansible Installer Default GKE Value<tbody><tr><td><code>kubernetes_context</code><td>Set to configure the context name of the kubeconfig used for authentication<td>To retrieve the <code>kubernetes_context</code> value, run the following command: <code>kubectl config current-context</code><tr><td><code>pgo_admin_username</code><td>Configures pgo administrator username<td><code>admin</code><tr><td><code>pgo_admin_password</code><td>Configures pgo administrator password<td><code>admin</code><tr><td><code>pgo_operator_namespace</code><td>Set to configure namespace where Operator will be deployed<td><code>pgo</code><tr><td><code>namespace</code><td>Set to a comma delimited string of all namespaces Operator will manage. For this demonstration, only one namespace - namespace where the operator will be deployed - will be watched.<td><code>pgo</code><tr><td><code>ccp_image_prefix</code><td>Configures image prefix used when creating containers from Crunchy Container Suite<td><code>crunchydata</code><tr><td><code>ccp_image_tag</code><td>Configures image tag (version) used when creating containers from Crunchy Container Suite<td><code>centos7-11.3-2.4.0</code><tr><td><code>pgo_image_prefix</code><td>Configures image prefix used when creating containers for Operator (apiserver, operator, scheduler..etc)<td><code>crunchydata</code><tr><td><code>pgo_image_tag</code><td>Configures image tag used when creating containers for Operator (apiserver, operator, scheduler..etc)<td><code>centos7-4.0.0</code><tr><td><code>pgo_client_install</code><td>Configures playbooks to install pgo client if set to true<td><code>TRUE</code><tr><td><code>pgo_client_version</code><td>Configures which version of pgo playbooks should install.<td><code>4.0.0</code><tr><td><code>pgo_tls_no_verify</code><td>Set to configure Operator to verify TLS certificates<td><code>FALSE</code><tr><td><code>backrest_storage</code><td>Set to configure storage definition to use when creating volumes used by pgBackRest on all newly created clusters<td><code>storage1</code><tr><td><code>backup_storage</code><td>Set to configure storage definition to use when creating volumes used by pgBaseBackup on all newly created clusters<td><code>storage1</code><tr><td><code>primary_storage</code><td>Set to configure storage definition to use when creating volumes used by PostgreSQL primaries on all newly created clusters<td><code>storage1</code><tr><td><code>replica_storage</code><td>Set to configure storage definition to use when creating volumes used by PostgreSQL replicas on all newly created clusters<td><code>storage1</code><tr><td><code>storage&#60ID>_access_mode</code><td>Set to configure storage definition to all primary pods created by Operator.<td><code>storage1_access_mode='ReadWriteOnce'</code><tr><td><code>storage&#60ID>_size</code><td>Set to configure storage definition to all primary pods created by Operator.<td><code>storage1_size='10G'</code><tr><td><code>storage&#60ID>_type</code><td>Set to configure storage definition to all primary pods created by the Operator.<td><code>storage1_type='dynamic'</code><tr><td><code>storage&#60ID>_class</code><td>Set to configure storage definition to all primary pods created by the Operator.<td><code>storage1_class='standard'</code><tr><td><code>storage&#60ID>_supplemental_groups</code><td>Set to configure storage definition to all primary pods created by the Operator.<td>Since this demonstration is for GKE, this parameter should be commented out as it’s not applicable to GKE<tr><td><code>storage&#60ID>_fs_group</code><td>Set to configure storage definition to all primary pods created by the Operator.<td><code>storage1_fs_group=26</code></table></figure> ]]></content:encoded>
<category><![CDATA[ Kubernetes ]]></category>
<author><![CDATA[ Patrick.McLaughlin@crunchydata.com (Patrick McLaughlin) ]]></author>
<dc:creator><![CDATA[ Patrick McLaughlin ]]></dc:creator>
<guid isPermalink="false">https://blog.crunchydata.com/blog/install-postgres-operator-kubernetes-on-gke-ansible</guid>
<pubDate>Thu, 13 Jun 2019 05:00:00 EDT</pubDate>
<dc:date>2019-06-13T09:00:00.000Z</dc:date>
<atom:updated>2019-06-13T09:00:00.000Z</atom:updated></item></channel></rss>