update quickstart script for mac and debian ( Ubuntu)
**What is the motivation or use case for the change? ** Currently script is written to support RHEL / Centos.
Describe the solution you'd like A clear and concise description of what you want to happen. It needs to be updated to support Mac and Debian ( Ubuntu)
Please tell us about your environment:
- Operating System:
- Where is this running ( Local, Cloud Provider)
- Storage being used (NFS, Hostpath, Gluster, etc):
- Container Image Tag:
- PostgreSQL Version:
- Platform (Docker, Kubernetes, OpenShift):
- Platform Version:
Additional context Add any other context or screenshots about the enhancement request here.
quickstart.sh on ubuntu to GKE works as-is.
Run into sed usage errors with quickstart.sh on macos:
The available storage classes on your system:
NAME PROVISIONER AGE
standard (default) kubernetes.io/gce-pd 7d
Enter the name of the storage class to use: standard
Setting up pgo storage configuration for the selected storageclass...
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
Setting up pgo client authentication...
For pgo bash completion you will need to install the bash-completion package.
Do you want to deploy the operator? [Yn]
Code in question is:
echo ""
echo "Setting up pgo storage configuration for the selected storageclass..." | tee -a $LOG
sed --in-place=.bak 's/Storage: nfsstorage/'"Storage: storageos"'/' $COROOT/conf/postgres-operator/pgo.yaml
sed --in-place=.bak 's/fast/'"$STORAGE_CLASS"'/' $COROOT/conf/postgres-operator/pgo.yaml
sed --in-place=.bak 's/COImagePrefix: crunchydata/'"COImagePrefix: $CO_IMAGE_PREFIX"'/' $COROOT/conf/postgres-operator/pgo.yaml
sed --in-place=.bak 's/CCPImagePrefix: crunchydata/'"CCPImagePrefix: $CCP_IMAGE_PREFIX"'/' $COROOT/conf/postgres-operator/pgo.yaml
sed --in-place=.bak 's/centos7/'"$CO_BASEOS"'/' $COROOT/conf/postgres-operator/pgo.yaml
sed --in-place=.bak 's/demo/'"$CO_NAMESPACE"'/' $COROOT/deploy/cluster-rbac.yaml
sed --in-place=.bak 's/demo/'"$CO_NAMESPACE"'/' $COROOT/deploy/rbac.yaml
Looks like the MacOS sed just uses -i:
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not
recommended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk
space is exhausted, etc.
We may need to edit the command like this to work on both GNU and BSD (MacOS) versions:
sed -i'.bak' -e 's/demo/'"$CO_NAMESPACE"'/' $COROOT/deploy/rbac.yaml
Testing now.
Getting these errors from install-rbac.sh:
/Users/dts/odev/src/github.com/crunchydata/postgres-operator/deploy/install-rbac.sh: line 31: /Users/dts/odev/bin/expenv: cannot execute binary file
error: no objects passed to create
/Users/dts/odev/src/github.com/crunchydata/postgres-operator/deploy/install-rbac.sh: line 34: /Users/dts/odev/bin/expenv: cannot execute binary file
error: no objects passed to create
/Users/dts/odev/src/github.com/crunchydata/postgres-operator/deploy/install-rbac.sh: line 37: /Users/dts/odev/bin/expenv: cannot execute binary file
error: no objects passed to create
Confirmed that the sed syntax I suggested above with the -i and -e syntax works on both GNU and BSD sed. I suggest changing usage to that to work on Linux and MacOS.
Re install-rbac.sh errors, it's set to call expenv and pgo instead of expenv-mac and pgo-mac, respectively. Sorting it out further now.
mv pgo $GOBIN
mv pgo-mac $GOBIN
mv pgo.exe $GOBIN
mv expenv.exe $GOBIN
mv expenv-mac $GOBIN
mv expenv $GOBIN
Might be better to just install the version that is needed for the host's OS (ie cp pgo-mac to pgo).
Dave Youatt suggested this change to detect OS and place file correctly:
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
cp -a pgo $GOBIN/pgo
cp -a expenv $GOBIN/expenv
;;
Darwin*)
cp -a pgo-mac $GOBIN/pgo
cp -a expenv-mac $GOBIN/expenv
;;
CYGWIN*)
cp -a pgo.exe $GOBIN/pgo
cp -a expenv.exe $GOBIN/expenv
;;
MINGW*)
cp -a pgo.exe $GOBIN/pgo
cp -a expenv.exe $GOBIN/expenv
;;
*)
machine="UNKNOWN:${unameOut}"
esac
With these changes, quickstart.sh is working on MacOS for GKE now. I'm going to submit a patch shortly and then shift to testing on OpenShift.
Patch submitted in PR #516
OCS took a bit more time simply because I'm not an OCS admin.
quickstart.sh not only requires OCS to be setup, but requires a storage class to be created (GKE had a "standard" one waiting, I had to manually create one in OCS), but also required the the pgo 3.4.0 and CCP 2.2.0 docker images to be manually pulled and tagged on my OCS VM.
Then I had to be sure to use 3.4.0, quickstart.sh does NOT work with 3.3.0 at all. During this part of testing I learned also that the COROOT directory needs to be wiped, otherwise 3.3.0 json files that were moved to different locations in 3.4.0 will be read twice and trigger duplicate key warnings. Namely container-resources.json.
Also quickstart.sh doesn't set the COROOT env var in the user's .bashrc. It sets it for the script session but it isn't saved. Perhaps it should be?
Otherwise quickstart.sh worked from both ubuntu and macos with the changes from PR #516. No new changes were required in my testing.
I think we are good to go for now, thanks Don for helping out on this.