|
| 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 | +``` |
0 commit comments