Skip to content

Commit 5cb51b3

Browse files
author
Jeff McCormick
committed
add quickstart for gce
1 parent 8e12a7c commit 5cb51b3

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

examples/quickstart.sh

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/bin/bash
2+
3+
echo "installing deps if necessary"
4+
5+
6+
which git > /dev/null 2> /dev/null
7+
if [[ $? -ne 0 ]]; then
8+
echo "git is missing on your system, a required dependency"
9+
exit 1
10+
fi
11+
which go > /dev/null 2> /dev/null
12+
if [[ $? -ne 0 ]]; then
13+
echo "golang is missing on your system, a required dependency"
14+
exit 1
15+
fi
16+
which wget > /dev/null 2> /dev/null
17+
if [[ $? -ne 0 ]]; then
18+
echo "wget is missing on your system, a required dependency"
19+
exit 1
20+
fi
21+
which kubectl > /dev/null 2> /dev/null
22+
if [[ $? -ne 0 ]]; then
23+
echo "kubectl is missing on your system, a required dependency"
24+
exit 1
25+
fi
26+
27+
echo "testing kubectl connection"
28+
kubectl get namespaces
29+
if [[ $? -ne 0 ]]; then
30+
echo "kubectl is not connecting to your Kube Cluster, required to proceed"
31+
exit 1
32+
fi
33+
34+
35+
echo "setting environment variables"
36+
37+
cat <<'EOF' >> $HOME/.bashrc
38+
39+
# operator env vars
40+
export GOPATH=$HOME/odev
41+
export GOBIN=$GOPATH/bin
42+
export PATH=$PATH:$GOBIN
43+
export COROOT=$GOPATH/src/github.com/crunchydata/postgres-operator
44+
export CO_BASEOS=centos7
45+
export CO_VERSION=2.4
46+
export CO_IMAGE_TAG=$CO_BASEOS-$CO_VERSION
47+
export CO_NAMESPACE=demo
48+
export CO_CMD=kubectl
49+
export CO_APISERVER_URL=https://postgres-operator:8443
50+
export PGO_CA_CERT=$COROOT/conf/apiserver/server.crt
51+
export PGO_CLIENT_CERT=$COROOT/conf/apiserver/server.crt
52+
export PGO_CLIENT_KEY=$COROOT/conf/apiserver/server.key
53+
#
54+
55+
EOF
56+
57+
source $HOME/.bashrc
58+
59+
echo "setting up directory structure"
60+
61+
mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg
62+
mkdir -p $GOPATH/src/github.com/crunchydata/
63+
64+
echo "installing deps if necessary"
65+
66+
go get github.com/blang/expenv
67+
if [[ $? -ne 0 ]]; then
68+
echo "problem installing expenv dependency"
69+
exit 1
70+
fi
71+
72+
73+
echo "installing pgo server config"
74+
cd $GOPATH/src/github.com/crunchydata
75+
git clone https://github.com/CrunchyData/postgres-operator.git
76+
if [[ $? -ne 0 ]]; then
77+
echo "problem getting pgo server config"
78+
exit 1
79+
fi
80+
cd $COROOT
81+
#git checkout 2.4
82+
git checkout master
83+
if [[ $? -ne 0 ]]; then
84+
echo "problem getting 2.4 release"
85+
exit 1
86+
fi
87+
88+
echo "installing pgo client"
89+
90+
cd $HOME
91+
wget https://github.com/CrunchyData/postgres-operator/releases/download/2.4/postgres-operator.2.4.tar.gz
92+
if [[ $? -ne 0 ]]; then
93+
echo "problem getting postgres-operator release"
94+
exit 1
95+
fi
96+
97+
tar xvzf $HOME/postgres-operator.2.4.tar.gz
98+
99+
mv pgo $GOBIN
100+
mv pgo-mac $GOBIN
101+
102+
echo "creating demo namespace"
103+
104+
kubectl create -f $COROOT/examples/demo-namespace.json
105+
#if [[ $? -ne 0 ]]; then
106+
# echo "problem creating Kube demo namespace"
107+
## exit 1
108+
#fi
109+
Kubectl get namespaces
110+
kubectl config view
111+
112+
echo "enter your Kube cluster name:"
113+
read CLUSTERNAME
114+
echo "enter your Kube user name:"
115+
read USERNAME
116+
117+
kubectl config set-context demo --namespace=demo --cluster=$CLUSTERNAME --user=$USERNAME
118+
kubectl config use-context demo
119+
120+
echo "setting up pgo storage configuration for GCE standard storageclass"
121+
cp $COROOT/examples/pgo.yaml.storageclass $COROOT/conf/apiserver/pgo.yaml
122+
123+
echo "deploy the operator to the Kube cluster"
124+
cd $COROOT
125+
#./deploy/deploy.sh
126+
127+
echo "setting up pgo client auth"
128+
cp $COROOT/conf/apiserver/pgouser $HOME/.pgouser
129+
130+
echo "for pgo bash completion you will need to install the bash-completion package"
131+
132+
mv $HOME/pgo-bash-completion $HOME/.bash_completion
133+
134+
echo "install complete, try 'pgo version' command"

0 commit comments

Comments
 (0)