Skip to content

Commit 61c1d7b

Browse files
tjmoore4cahoonpwork
authored andcommitted
Disabletls (#952)
* Initial changes to allow for disable tls flag (with port) and no verify tls * Added error handling for missing port value * Converted ansible service.json to template for apiserver port update. Removed duplicate variable reference. * Added Ansible template for service.json, default values for both Bash and Ansible install and documentation updates. * Removed preflight port check since default is set. Cleanup comments and fixed comma error. * Updated service.json path in main.yml * Added a note about updates to TLS or port settings. * Updated default behavior in deploy.sh
1 parent 1181a4d commit 61c1d7b

File tree

14 files changed

+119
-54
lines changed

14 files changed

+119
-54
lines changed

ansible/inventory

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ pgo_image_tag='centos7-4.1.0'
7272
pgo_client_install='true'
7373
pgo_client_version='v4.1.0'
7474

75-
# PGO TLS
76-
pgo_tls_no_verify='false'
75+
# PGO Apiserver TLS Settings
76+
#pgo_tls_no_verify='false'
77+
#pgo_disable_tls='false'
78+
#pgo_apiserver_port=8443
7779

7880
# Set to 'true' to assign the cluster-admin role to the PGO service account. Needed for
7981
# OCP installs to enable dynamic namespace creation (see the PGO docs for more details).

ansible/roles/pgo-operator/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ crunchy_debug: "false"
2121
pgo_client_install: "true"
2222
pgo_cluster_admin: "false"
2323
pgo_disable_tls: "false"
24+
pgo_tls_no_verify: "false"
2425
pgo_disable_eventing: "false"
26+
pgo_apiserver_port: 8443
2527

2628
delete_operator_namespace: "false"
2729
delete_watched_namespaces: "false"

ansible/roles/pgo-operator/files/service.json

Lines changed: 0 additions & 37 deletions
This file was deleted.

ansible/roles/pgo-operator/tasks/main.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@
131131
mode: '0600'
132132
tags: [install, update]
133133

134+
- name: Template PGO Service Configuration
135+
template:
136+
src: service.json.j2
137+
dest: "{{ output_dir }}/service.json"
138+
mode: '0600'
139+
tags: [install, update]
140+
134141
- name: Template BackRest AWS S3 Configuration
135142
template:
136143
src: aws-s3-credentials.yaml.j2
@@ -166,7 +173,7 @@
166173

167174
- name: Create PGO Service
168175
command: |
169-
{{ kubectl_or_oc }} create --filename='{{ role_path }}/files/service.json' -n {{ pgo_operator_namespace }}
176+
{{ kubectl_or_oc }} create --filename='{{ output_dir }}/service.json' -n {{ pgo_operator_namespace }}
170177
tags: [install, update]
171178

172179
- name: Template PGO Deployment

ansible/roles/pgo-operator/templates/deployment.json.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"imagePullPolicy": "IfNotPresent",
2626
"ports": [
2727
{
28-
"containerPort": 8443
28+
"containerPort": {{ pgo_apiserver_port }}
2929
}
3030
],
3131
"env": [
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"name": "PORT",
38-
"value": "8443"
38+
"value": "{{ pgo_apiserver_port }}"
3939
},
4040
{
4141
"name": "PGO_INSTALLATION_NAME",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"kind": "Service",
3+
"apiVersion": "v1",
4+
"metadata": {
5+
"name": "postgres-operator",
6+
"labels": {
7+
"name": "postgres-operator"
8+
}
9+
},
10+
"spec": {
11+
"ports": [
12+
{
13+
"name": "apiserver",
14+
"protocol": "TCP",
15+
"port": {{ pgo_apiserver_port }},
16+
"targetPort": {{ pgo_apiserver_port }}
17+
},
18+
{
19+
"name": "nsqadmin",
20+
"protocol": "TCP",
21+
"port": 4151,
22+
"targetPort": 4151
23+
},
24+
{
25+
"name": "nsqd",
26+
"protocol": "TCP",
27+
"port": 4150,
28+
"targetPort": 4150
29+
}
30+
],
31+
"selector": {
32+
"name": "postgres-operator"
33+
},
34+
"type": "ClusterIP",
35+
"sessionAffinity": "None"
36+
}
37+
}

deploy/deploy.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,19 @@ $PGO_CMD --namespace=$PGO_OPERATOR_NAMESPACE create secret tls pgo.tls --key=$PG
4848
$PGO_CMD --namespace=$PGO_OPERATOR_NAMESPACE create configmap pgo-config \
4949
--from-file=$PGOROOT/conf/postgres-operator
5050

51+
52+
#
53+
# check if custom port value is set, otherwise set default values
54+
#
55+
56+
if [[ -z ${PGO_APISERVER_PORT} ]]
57+
then
58+
echo "PGO_APISERVER_PORT is not set. Setting to default port value of 8443."
59+
export PGO_APISERVER_PORT=8443
60+
fi
61+
5162
#
5263
# create the postgres-operator Deployment and Service
5364
#
5465
expenv -f $DIR/deployment.json | $PGO_CMD --namespace=$PGO_OPERATOR_NAMESPACE create -f -
55-
$PGO_CMD --namespace=$PGO_OPERATOR_NAMESPACE create -f $DIR/service.json
66+
expenv -f $DIR/service.json | $PGO_CMD --namespace=$PGO_OPERATOR_NAMESPACE create -f -

deploy/deployment.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"imagePullPolicy": "IfNotPresent",
2525
"ports": [
2626
{
27-
"containerPort": 8443
27+
"containerPort": $PGO_APISERVER_PORT
2828
}
2929
],
3030
"env": [
@@ -34,7 +34,7 @@
3434
},
3535
{
3636
"name": "PORT",
37-
"value": "8443"
37+
"value": "$PGO_APISERVER_PORT"
3838
},
3939
{
4040
"name": "PGO_INSTALLATION_NAME",
@@ -50,15 +50,15 @@
5050
},
5151
{
5252
"name": "TLS_NO_VERIFY",
53-
"value": "false"
53+
"value": "$TLS_NO_VERIFY"
5454
},
5555
{
5656
"name": "DISABLE_TLS",
57-
"value": "false"
57+
"value": "$DISABLE_TLS"
5858
},
5959
{
6060
"name": "DISABLE_EVENTING",
61-
"value": "false"
61+
"value": "$DISABLE_EVENTING"
6262
},
6363
{
6464
"name": "EVENT_ADDR",
@@ -112,7 +112,7 @@
112112
},
113113
{
114114
"name": "DISABLE_EVENTING",
115-
"value": "false"
115+
"value": "$DISABLE_EVENTING"
116116
},
117117
{
118118
"name": "EVENT_ADDR",

deploy/service.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
{
1313
"name": "apiserver",
1414
"protocol": "TCP",
15-
"port": 8443,
16-
"targetPort": 8443
15+
"port": $PGO_APISERVER_PORT,
16+
"targetPort": $PGO_APISERVER_PORT
1717
},
1818
{
1919
"name": "nsqadmin",

examples/envs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ export PGO_BASEOS=centos7
2424
export PGO_VERSION=4.1.0
2525
export PGO_IMAGE_TAG=$PGO_BASEOS-$PGO_VERSION
2626

27+
# for setting the pgo apiserver port, disabling TLS or not verifying TLS
28+
# if TLS is disabled, ensure setip() function port is updated and http is used in place of https
29+
export PGO_APISERVER_PORT=8443 # Defaults: 8443 for TLS enabled, 8080 for TLS disabled
30+
export DISABLE_TLS=false
31+
export TLS_NO_VERIFY=false
32+
33+
# for disabling the Operator eventing
34+
export DISABLE_EVENTING=false
35+
2736
# for the pgo CLI to authenticate with using TLS
2837
export PGO_CA_CERT=$PGOROOT/conf/postgres-operator/server.crt
2938
export PGO_CLIENT_CERT=$PGOROOT/conf/postgres-operator/server.crt

hugo/content/Installation/install-with-ansible/prerequisites.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ The following are the variables available for configuration:
137137
| `pgo_image_tag` | | Configures the image tag used when creating containers for the Crunchy PostgreSQL Operator (apiserver, operator, scheduler..etc) |
138138
| `pgo_operator_namespace` | | Set to configure the namespace where Operator will be deployed. |
139139
| `pgo_tls_no_verify` | | Set to configure Operator to verify TLS certificates. |
140-
| `pgo_disable_tls` | false | Set to configure whether or not TLS should be enabled for the Crunchy PostgreSQL Operator apiserver. |
140+
| `pgo_disable_tls` | false | Set to configure whether or not TLS should be enabled for the Crunchy PostgreSQL Operator apiserver.
141+
142+
| `pgo_apiserver_port` | 8443 | Set to configure the port used by the Crunchy PostgreSQL Operator apiserver.
143+
|
141144
| `pgo_disable_eventing` | false | Set to configure whether or not eventing should be enabled for the Crunchy PostgreSQL Operator installation. |
142145
| `primary_storage` | storageos | Set to configure which storage definition to use when creating volumes used by PostgreSQL primaries on all newly created clusters. |
143146
| `prometheus_install` | true | Set to true to install Crunchy Prometheus timeseries database. |

hugo/content/Installation/install-with-ansible/updating-operator.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ To configure the environment variables used by `pgo` run the following command:
8484

8585
Note: `<PGO_NAMESPACE>` should be replaced with the namespace the Crunchy PostgreSQL
8686
Operator was deployed to.
87+
Also, if TLS was disabled, or if the port was changed, update PGO_APISERVER_URL accordingly.
8788

8889
```bash
8990
cat <<EOF >> ~/.bashrc
@@ -114,6 +115,8 @@ kubectl port-forward <OPERATOR_POD_NAME> -n <OPERATOR_NAMESPACE> 8443:8443
114115
oc port-forward <OPERATOR_POD_NAME> -n <OPERATOR_NAMESPACE> 8443:8443
115116
```
116117

118+
Note: If a port other than 8443 was configured, update the above command accordingly.
119+
117120
On a separate terminal verify the `pgo` can communicate with the Crunchy PostgreSQL
118121
Operator:
119122

hugo/content/Security/_index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,28 @@ following:
315315

316316
This server.key and server.crt can then be used to access the *pgo-apiserver*
317317
REST API from the pgo CLI on your client host.
318+
319+
Should you desire to alter the default TLS settings for the Postgres Operator, you can set the
320+
following variables in bash:
321+
322+
To disable TLS and make an unsecured connection on port 8080 instead of connecting securely over
323+
the default port, 8443, set:
324+
325+
Bash environment variables
326+
327+
DISABLE_TLS=true
328+
PGO_APISERVER_PORT=8080
329+
330+
Or inventory variables if using Ansible
331+
332+
pgo_disable_tls='false'
333+
pgo_apiserver_port=8443
334+
335+
To disable TLS verifcation, set the follwing as a Bash environment variable
336+
337+
export TLS_NO_VERIFY=false
338+
339+
Or the following in the inventory file is using Ansible
340+
341+
pgo_tls_no_verify='false'
342+

hugo/content/gettingstarted/Design/eventing.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ NSQ looks for events currently at port 4150. The Operator sends
8181
events to the NSQ address as defined in the EVENT_ADDR environment
8282
variable.
8383

84-
If you want to disable eventing, set the following environment
85-
variable in the Operator Deployment:
84+
If you want to disable eventing when installing with Bash, set the following
85+
environment variable in the Operator Deployment:
8686
"name": "DISABLE_EVENTING"
8787
"value": "true"
8888

89+
To disable eventing when installing with Ansible, add the following to
90+
your inventory file:
91+
pgo_disable_eventing='true'

0 commit comments

Comments
 (0)