Skip to content

Commit 7849878

Browse files
jmckulkjkatz
authored andcommitted
Allow use of kubectl to deploy installer job
Creates install.yml, uninstall.yml, update.yml that will create kube resources and job Adds inventory_template that will be setup based on the environment variables using envsubst. Updates docker file to install envsubst Updates pgo-install.sh to setup env defaults and generate an inventory file based on the environment. adds docs to use kubectl apply
1 parent a890e07 commit 7849878

File tree

9 files changed

+1229
-5
lines changed

9 files changed

+1229
-5
lines changed

centos7/Dockerfile.pgo-installer.centos7

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ RUN yum -y install epel-release \
1313
--setopt=skip_missing_names_on_install=False \
1414
kubectl \
1515
ansible \
16-
which
16+
which \
17+
gettext
1718

1819
USER daemon
1920

2021
COPY installers/ansible /ansible
21-
COPY installers/image/bin/pgo-install.sh pgo-install.sh
22+
COPY installers/image/bin/pgo-install.sh /pgo-install.sh
23+
COPY installers/image/inventory_template /inventory_template
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: "Deploy with Kubectl"
3+
date:
4+
draft: false
5+
weight: 20
6+
---
7+
8+
The `pgo-installer` image can be deployed using the `kubectl` client. The resources
9+
needed to run the installer are described in the
10+
[pgo-installer]({{< relref "/installation/postgres-operator-installer/_index.md" >}})
11+
section of the documentation. The following yaml files include these resources
12+
that are needed to deploy the operator.
13+
14+
### Resources
15+
16+
Each of these resources is defined in the yaml file that is used to deploy the
17+
operator. These resources can be updated to customize your expirence with the
18+
Postgres-Operator but we provide sane defaults so that you can easily deploy.
19+
By default the installer will create each resource based on the resource
20+
definition in the job yaml.
21+
22+
#### Namespace
23+
24+
The namespace definiton will be used to create a namespace for the installer to
25+
run. By default the installer will run in a separate namespace from where the
26+
Postgres-Operator will be deployed. If you want the jobs to run in a
27+
preconfigured namespace you can easily update this file to remove the
28+
namespace definition. The other resources will need to be updated to reference
29+
this preconfigured namespace.
30+
31+
#### ServiceAccount and ClusterRoleBinding
32+
33+
The installer image needs a service account that can access the Kubernetes
34+
cluster where the Postgres-Operator will be installed. The job yaml defines a
35+
service account and clusterrolebinding that gives the service account the
36+
cluster-admin role. This is required for the installer to run correctly. If you
37+
have a preconfigured service account with the cluster-admin role, you can remove
38+
this section of the yaml and update the service account name in the job spec.
39+
40+
#### Job
41+
42+
Once the resources have been configured the job spec will be used to deploy the
43+
Postgres-Operator in your Kubernetes environment. The job spec includes sane
44+
defaults that can be used to deploy a specific version of the Postgres-Operator
45+
based on the version of the pgo-installer image that is used. Each version will
46+
install the corresponding version of the Postgres-Operator.
47+
48+
##### Deployment Options
49+
50+
The installer image uses environment variables to specify deployment options for
51+
the Postgres-Operator. The environment variables that you can define are the
52+
same as the options in the inventory file for the ansible installer. These
53+
options can be found in the
54+
[Configuring the Inventory File]({{< relref "/installation/install-with-ansible/prerequisites.md" >}})
55+
section of the docs. The environment variables will be the same as the inventory
56+
options but in all capital letters. A full list of available environment
57+
variables can be found in the `$PGOROOT/installers/method/kubectl/full_options`
58+
file. The deployment options that are included in the default job spec are
59+
required.
60+
61+
### Installing
62+
63+
```
64+
kubectl apply -f $PGOROOT/installers/method/kubectl/install.yml
65+
```
66+
67+
### Uninstalling
68+
69+
```
70+
kubectl apply -f $PGOROOT/installers/method/kubectl/uninstall.yml
71+
```
72+
73+
### Updating
74+
75+
```
76+
kubectl apply -f $PGOROOT/installers/method/kubectl/update.yml
77+
```
78+
79+
### Cleanup
80+
81+
The job resources can be cleaned up by running a delete on the specific yaml
82+
file for each job. *Please not that this will delete the namespace where the
83+
installer ran. If this is the same as the Postgres-Operator namespace that will
84+
also be deleted.* The resources can also be delete manually through the kubectl
85+
client.
86+
87+
```
88+
kubectl delete -f job.yml
89+
```
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
#!/bin/bash
22

3-
/usr/bin/env ansible-playbook -i /ansible-inventory/inventory --tags=$1 /ansible/main.yml
3+
export BACKREST_PORT=${BACKREST_PORT:-2022}
4+
export SERVICE_TYPE=${SERVICE_TYPE:-ClusterIP}
5+
export CRUNCHY_DEBUG=${CRUNCHY_DEBUG:-false}
6+
export PGO_CLIENT_INSTALL=${PGO_CLIENT_INSTALL:-true}
7+
export PGO_CLIENT_CONTAINER_INSTALL=${PGO_CLIENT_CONTAINER_INSTALL:-false}
8+
export PGO_CLUSTER_ADMIN=${PGO_CLUSTER_ADMIN:-false}
9+
export PGO_DISABLE_TLS=${PGO_DISABLE_TLS:-false}
10+
export PGO_TLS_NO_VERIFY=${PGO_TLS_NO_VERIFY:-false}
11+
export PGO_DISABLE_EVENTING=${PGO_DISABLE_EVENTING:-false}
12+
export PGO_APISERVER_PORT=${PGO_APISERVER_PORT:-8443}
13+
export PGO_ADD_OS_CA_STORE=${PGO_ADD_OS_CA_STORE:-false}
14+
export PGO_APISERVER_URL=${PGO_APISERVER_URL:-https://postgres-operator}
15+
export PGO_CLIENT_CERT_SECRET=${PGO_CLIENT_CERT_SECRET:-pgo.tls}
16+
export POD_ANTI_AFFINITY=${POD_ANTI_AFFINITY:-preferred}
17+
export DELETE_OPERATOR_NAMESPACE=${DELETE_OPERATOR_NAMESPACE:-false}
18+
export DELETE_WATCHED_NAMESPACE=${DELETE_WATCHED_NAMESPACE:-false}
19+
export DELETE_METRICS_NAMESPACE=${DELETE_METRICS_NAMESPACE:-false}
20+
21+
cat /inventory_template | envsubst > /tmp/inventory
22+
/usr/bin/env ansible-playbook -i /tmp/inventory --tags=$1 /ansible/main.yml

0 commit comments

Comments
 (0)