Skip to content

Commit dbb1456

Browse files
committed
Merge branch 'master' of github.com:CrunchyData/postgres-operator
2 parents a6ab7fb + c15b7d3 commit dbb1456

File tree

17 files changed

+330
-1586
lines changed

17 files changed

+330
-1586
lines changed

README.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ The operator is template-driven; this makes it simple to configure both the clie
4949
== Commands
5050

5151
*postgres-operator* commands are documented on the link:docs/commands.asciidoc[Commands] page.
52+
53+
== Building From Source
54+
55+
For people wanting to build from source, instructions are documented on the link:docs/build.asciidoc[Build] page.

apiserver/versionservice/versionimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Version() msgs.VersionResponse {
2525
resp := msgs.VersionResponse{}
2626
resp.Status.Code = msgs.Ok
2727
resp.Status.Msg = "apiserver version"
28-
resp.Version = "2.6"
28+
resp.Version = "2.6-rc2"
2929

3030
return resp
3131
}

bin/get-deps.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash
22

33
# Copyright 2017-2018 Crunchy Data Solutions, Inc.
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
echo "getting project dependencies...."
16+
echo "Getting project dependencies..."
1717
#godep restore
1818

1919
go get github.com/inconshreveable/mousetrap
@@ -47,4 +47,3 @@ git fetch --all --tags --prune
4747
git checkout kubernetes-1.8.5
4848
cd $GOPATH/src/github.com/kubernetes/code-generator/cmd/deepcopy-gen
4949
go build main.go && mv main $GOPATH/bin/deepcopy-gen
50-

conf/apiserver/pgo.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ Pgo:
4141
Metrics: false
4242
LSPVCTemplate: /config/pgo.lspvc-template.json
4343
LoadTemplate: /config/pgo.load-template.json
44-
COImagePrefix: crunchydata
45-
COImageTag: centos7-2.6
44+
COImagePrefix: kubeadm-master:5000/crunchydata
45+
COImageTag: centos7-2.6-rc2

conf/postgres-operator/cluster/1/pgpool.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ pcp_socket_dir = '/tmp'
5555
backend_hostname0 = '{{.PG_PRIMARY_SERVICE_NAME}}'
5656
backend_port0 = 5432
5757
backend_weight0= 1
58-
backend_flag0= 'DISALLOW_TO_FAILOVER'
58+
backend_flag0= 'ALLOW_TO_FAILOVER'
5959

6060
backend_hostname1 = '{{.PG_REPLICA_SERVICE_NAME}}'
6161
backend_port1 = 5432
6262
backend_weight1= 1
63-
backend_flag1= 'DISALLOW_TO_FAILOVER'
63+
backend_flag1= 'ALLOW_TO_FAILOVER'
6464

6565
#backend_hostname0 = 'master'
6666
# Host name or IP address to connect to for backend 0

deploy/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ if [ "$CO_CMD" = "kubectl" ]; then
2121
NS="--namespace=$CO_NAMESPACE"
2222
fi
2323

24-
$CO_CMD create -f $DIR/service-account.yaml
24+
expenv -f $DIR/service-account.yaml | $CO_CMD create -f -
2525
#$CO_CMD create -f $DIR/cluster-role-binding.yaml
26-
$CO_CMD create -f $DIR/rbac.yaml
26+
expenv -f $DIR/rbac.yaml | $CO_CMD create -f -
2727

2828
$CO_CMD create secret generic apiserver-conf-secret \
2929
--from-file=server.crt=$COROOT/conf/apiserver/server.crt \

deploy/rbac.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ roleRef:
3838
subjects:
3939
- apiGroup: rbac.authorization.k8s.io
4040
kind: User
41-
name: system:serviceaccount:demo:postgres-operator
41+
name: system:serviceaccount:$CO_NAMESPACE:postgres-operator
4242

4343
---
4444

4545
kind: Role
4646
apiVersion: rbac.authorization.k8s.io/v1beta1
4747
metadata:
4848
name: nspostgresrole
49-
namespace: demo
49+
namespace: $CO_NAMESPACE
5050
rules:
5151
- verbs:
5252
- '*'
@@ -61,14 +61,14 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
6161
kind: RoleBinding
6262
metadata:
6363
name: nspgrolebind
64-
namespace: demo
64+
namespace: $CO_NAMESPACE
6565
roleRef:
6666
apiGroup: rbac.authorization.k8s.io
6767
kind: Role
6868
name: nspostgresrole
6969
subjects:
7070
- kind: ServiceAccount
7171
name: postgres-operator
72-
namespace: demo
72+
namespace: $CO_NAMESPACE
7373

7474
---

deploy/service-account.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ apiVersion: v1
22
kind: ServiceAccount
33
metadata:
44
name: postgres-operator
5-
namespace: demo
5+
namespace: $CO_NAMESPACE

docs/build.asciidoc

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
= PostgreSQL Operator Build Instructions
2+
:toc:
3+
v2.6, {docdate}
4+
5+
== Overview
6+
7+
This document describes how to build from source code the
8+
Postgres Operator, mostly this is for developers or people
9+
wanting to hack on the operator.
10+
11+
This document assumes you have already followed the Install instructions and have a working Kube environment.
12+
13+
== Requirements
14+
15+
The operator is developed with the Golang versions great than or equal to version 1.8 See
16+
link:https://golang.org/dl/[Golang website] for details on installing golang.
17+
18+
The Operator project builds and operates with the following containers:
19+
20+
* link:https://hub.docker.com/r/crunchydata/pgo-lspvc/[PVC Listing Container]
21+
* link:https://hub.docker.com/r/crunchydata/pgo-rmdata/[Remove Data Container]
22+
* link:https://hub.docker.com/r/crunchydata/postgres-operator/[postgres-operator Container]
23+
* link:https://hub.docker.com/r/crunchydata/pgo-apiserver/[apiserver Container]
24+
* link:https://hub.docker.com/r/crunchydata/pgo-load/[file load Container]
25+
26+
This Operator is developed and tested on the following operating systems but is known to run on other operating systems:
27+
28+
* *CentOS 7*
29+
* *RHEL 7*
30+
31+
=== Kubernetes Environment
32+
33+
To test the *postgres-operator*, it is required to have a Kubernetes cluster
34+
environment. The Operator is tested on Kubeadm Kubernetes installed clusters. Other Kubernetes installation methods have been known to work as well.
35+
36+
link:https://kubernetes.io/docs/setup/independent/install-kubeadm/[Installing kubeadm - Official Kubernetes Documentation]
37+
38+
39+
== Build from Source
40+
41+
Install a golang compiler, this can be done with either your package manager or by following directions from https://golang.org/dl/. The operator is currently built using golang version 1.8.X but also runs using golang version 1.9.X
42+
43+
Then install the project library dependencies, the godep dependency manager is used as follows:
44+
....
45+
cd $COROOT
46+
make setup
47+
....
48+
49+
==== Compiling the PostgreSQL Operator
50+
....
51+
cd $COROOT
52+
make all
53+
which pgo
54+
....
55+
56+
=== Create Namespace
57+
58+
This example is based on a kubeadm installation with the admin
59+
user being already created. The example below assumes the cluster name is *kubernetes* and the cluster default user is *kubernetes-admin*.
60+
....
61+
kubectl create -f $COROOT/examples/demo-namespace.json
62+
kubectl get namespaces
63+
....
64+
65+
then set your context to the new demo namespace
66+
....
67+
sudo chmod o+w /etc/kubernetes
68+
sudo chmod o+w /etc/kubernetes/admin.conf
69+
kubectl config set-context demo --namespace=demo --cluster=kubernetes --user=kubernetes-admin
70+
kubectl config use-context demo
71+
kubectl config current-context
72+
....
73+
74+
Permissions are granted to the Operator by means of a Service Account called *postgres-operator*. That service account is added to the Operator deployment.
75+
76+
The postgres-operator service account is granted cluster-admin priviledges using a cluster role binding *postgres-operator-cluster-role-binding*.
77+
78+
See link:https://kubernetes.io/docs/admin/authorization/rbac/[here] for more details on how to enable RBAC roles and modify the scope of the permissions to suit your needs.
79+
80+
The sample service account and cluster role bindings specify the *demo* namespace. Edit the yaml definitions of these to match the namespace you are deploying the operator into.
81+
82+
If you are not using the *demo* namespace, you will edit the following:
83+
84+
* $COROOT/deploy/service-account.yaml
85+
* $COROOT/deploy/cluster-role-binding.yaml
86+
87+
=== Deploy the PostgreSQL Operator
88+
*NOTE*: This will create and use */data* on your
89+
local system as the persistent store for the operator to use
90+
for its persistent volume.
91+
....
92+
cd $COROOT
93+
make deployoperator
94+
kubectl get pod -l 'name=postgres-operator'
95+
....
96+
97+
You should see output similar to:
98+
....
99+
NAME READY STATUS RESTARTS AGE
100+
postgres-operator-7f8db87c7b-4tk52 2/2 Running 0 8s
101+
....
102+
103+
This output shows that both the *apiserver* and *postgres-operator* containers
104+
are in ready state and the pod is running.
105+
106+
You can find the operator service IP address as follows:
107+
....
108+
kubectl get service postgres-operator
109+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
110+
postgres-operator ClusterIP 10.105.56.167 <none> 8080/TCP,8443/TCP 1m
111+
....
112+
113+
In this example, the *apiserver* is reachable at *https://10.105.56.167:8443*.
114+
115+
116+
When you first run the operator, it will create the required
117+
CustomResourceDefinitions. You can view these as follows:
118+
119+
....
120+
kubectl get crd
121+
....
122+
123+
Instead of using the bash script you can also deploy the operator using the provided Helm chart:
124+
....
125+
cd $COROOT/chart
126+
helm install ./postgres-operator
127+
helm ls
128+
....
129+
130+
=== Verify Installation
131+
132+
When you first run the operator, it will look for the presence of the
133+
predefined custom resource definitions, and create them if not found.
134+
The best way to verify a successful deployment of the Operator is by
135+
viewing these custom resource definitions:
136+
137+
....
138+
kubectl get crd
139+
kubectl get pgclusters
140+
kubectl get pgreplicas
141+
kubectl get pgbackups
142+
kubectl get pgupgrades
143+
kubectl get pgpolicies
144+
kubectl get pgingests
145+
kubectl get pgtasks
146+
....
147+
148+
At this point, you should be ready to start using the *pgo* client! Be
149+
sure to set the environment variable *CO_APISERVER_URL* to the DNS
150+
name of the *postgres-operator* service or to the IP address of the
151+
*postgres-operator* service IP address. For example:
152+
153+
....
154+
export CO_APISERVER_URL=https://10.105.56.167:8443
155+
....
156+
157+
Or if you have DNS configured on your client host:
158+
....
159+
export CO_APISERVER_URL=https://postgres-operator.demo.svc.cluster.local:8443
160+
....
161+
162+
== Makefile Targets
163+
164+
The following table describes the Makefile targets:
165+
.Makefile Targets
166+
[width="80%",frame="topbot",options="header,footer"]
167+
|======================
168+
|Target | Description
169+
|all | compile all binaries and build all images
170+
|setup | fetch the dependent packages required to build with
171+
|deployoperator | deploy the Operator (apiserver and postgers-operator) to Kubernetes
172+
|main | compile the postgres-operator
173+
|runmain | locally execute the postgres-operator
174+
|pgo | build the pgo binary
175+
|runpgo | run the pgo binary
176+
|runapiserver | run the apiserver binary outside of Kube
177+
|clean | remove binaries and compiled packages, restore dependencies
178+
|operatorimage | compile and build the postgres-operator Docker image
179+
|apiserverimage | compile and build the apiserver Docker image
180+
|lsimage | build the lspvc Docker image
181+
|loadimage | build the file load Docker image
182+
|rmdataimage | build the data deletion Docker image
183+
|release | build the postgres-operator release
184+
|======================
185+
186+

docs/commands.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ to creating a new Job with the same name.
162162

163163
To delete a backup enter the following:
164164
....
165-
pgo delete backup mybackup
165+
pgo delete backup mycluster
166166
....
167167

168168
=== pgo delete cluster

0 commit comments

Comments
 (0)