Skip to content

Commit ddfc3a2

Browse files
author
Jeff McCormick
committed
add prelim support for running in openshift
1 parent 8fa7f86 commit ddfc3a2

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

docs/build.asciidoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ from source, you can download them from the following:
1313
== Requirements
1414

1515
* Kubernetes 1.5.3+
16+
* Openshif Origin 1.5.1+
1617
* link:https://hub.docker.com/r/crunchydata/crunchy-postgres/[PostgreSQL 9.5+ Container]
1718
* link:https://hub.docker.com/r/crunchydata/crunchy-backup/[PostgreSQL Backup Container]
1819

@@ -55,6 +56,46 @@ kubectl create clusterrolebinding permissive-binding \
5556
See https://kubernetes.io/docs/admin/authorization/rbac/ for more
5657
details on how to enable RBAC roles.
5758

59+
To test the *postgres-operator* you will need a Kubernetes cluster
60+
61+
== Openshift Origin Environment
62+
63+
The postgres operator has been tested using Openshift Origin 1.5.1.
64+
65+
The operator works the same as in a Kubernetes environment except
66+
that you have to configure the Origin permissions to allow
67+
the operator to function.
68+
69+
The HostPath volume is by default restricted in Origin, so you
70+
will have to grant access to the HostPath volume plugin for the
71+
operator to access the Docker socket as a HostPath volume.
72+
73+
There is more than one way to alter the HostPath access, see:
74+
75+
....
76+
oc edit scc restricted set allowHostDirVolumePlugin: true to let
77+
....
78+
79+
This command will allow *all* pods to access HostPath volumes which
80+
may not be permissible in your environment.
81+
82+
Alternatively you can create a service account, have the operator
83+
use that service account, and grant the service account access
84+
to use a HostPath volume.
85+
86+
see the following links for examples:
87+
https://gitlab.com/gitlab-org/gitlab-ce/issues/24557
88+
https://docs.openshift.org/latest/admin_guide/manage_scc.html#use-the-hostpath-volume-plugin
89+
90+
To test on an Origin system, you will need to specify
91+
a CMD environment variable with the value of *oc* as follows:
92+
....
93+
export CMD=oc
94+
....
95+
96+
This will cause the *oc* command to be used within the operator
97+
startup script.
98+
5899
== Create Project and Clone
59100
In your .bashrc file, include the following:
60101
....

examples/operator/cleanup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
kubectl delete configmap operator-conf
15+
$CMD delete configmap operator-conf
1616

17-
kubectl --namespace=$NAMESPACE delete deployment postgres-operator
17+
$CMD --namespace=$NAMESPACE delete deployment postgres-operator
1818

1919
sleep 10
2020

examples/operator/deployment.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"spec": {
1616
"containers": [{
1717
"securityContext": {
18-
"privileged": true
1918
},
2019
"name": "postgres-operator",
2120
"image": "crunchydata/postgres-operator:centos7-1.2.0",

examples/operator/run.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,24 @@
1515

1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1717

18-
$DIR/cleanup.sh
1918

2019
if [ -z "$NAMESPACE" ]; then
2120
echo "NAMESPACE not set, using default"
2221
export NAMESPACE=default
2322
fi
23+
if [ -z "$CMD" ]; then
24+
echo "CMD not set, using kubectl"
25+
export CMD=kubectl
26+
fi
2427

25-
kubectl --namespace=$NAMESPACE get pvc crunchy-pvc
28+
$DIR/cleanup.sh
29+
30+
$CMD --namespace=$NAMESPACE get pvc crunchy-pvc
2631
rc=$?
2732

2833
if [ ! $rc -eq 0 ]; then
2934
echo "crunchy-pvc does not exist...creating crunchy-pvc "
30-
kubectl --namespace=$NAMESPACE create -f $DIR/crunchy-pvc.json
35+
$CMD --namespace=$NAMESPACE create -f $DIR/crunchy-pvc.json
3136
$DIR/create-pv.sh
3237
else
3338
echo "crunchy-pvc already exists..."
@@ -39,14 +44,12 @@ if [ ! -d /data ]; then
3944
sudo chmod 777 /data
4045
fi
4146

42-
kubectl create configmap operator-conf \
47+
$CMD create configmap operator-conf \
4348
--from-file=$COROOT/conf/postgres-operator/backup-job.json \
4449
--from-file=$COROOT/conf/postgres-operator/pvc.json \
4550
--from-file=$COROOT/conf/postgres-operator/cluster/1
4651

47-
envsubst < $DIR/deployment.json | kubectl --namespace=$NAMESPACE create -f -
52+
envsubst < $DIR/deployment.json | $CMD --namespace=$NAMESPACE create -f -
4853

4954
sleep 3
50-
kubectl get pod --selector=name=postgres-operator
51-
sleep 3
52-
kubectl logs --selector=name=postgres-operator
55+
$CMD get pod --selector=name=postgres-operator

operator/util/waituntil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func WaitUntilDeploymentIsDeleted(clientset *kubernetes.Clientset, depname strin
119119

120120
conditions := []watch.ConditionFunc{
121121
func(event watch.Event) (bool, error) {
122+
log.Infof("waiting for deployment to be deleted got event=%v\n", event.Type)
122123
if event.Type == watch.Deleted {
123124
log.Info("deployment delete event received in WaitUntilDeploymentIsDeleted")
124125
return true, nil

0 commit comments

Comments
 (0)