Skip to content

Commit ca9815c

Browse files
committed
Check for tools rather than install them
Different systems use different package managers.
1 parent 5685f63 commit ca9815c

File tree

4 files changed

+43
-71
lines changed

4 files changed

+43
-71
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
ANSIBLE_VERSION ?= 2.9.*
44
PGOROOT ?= $(CURDIR)
55
PGO_BASEOS ?= centos7
6-
PGO_CMD ?= kubectl
76
PGO_IMAGE_PREFIX ?= crunchydata
87
PGO_IMAGE_TAG ?= $(PGO_BASEOS)-$(PGO_VERSION)
9-
PGO_OPERATOR_NAMESPACE ?= pgo
108
PGO_VERSION ?= 4.5.0
119
PGO_PG_VERSION ?= 12
1210
PGO_PG_FULLVERSION ?= 12.4
@@ -104,6 +102,7 @@ installrbac:
104102

105103
setup:
106104
PGOROOT='$(PGOROOT)' ./bin/get-deps.sh
105+
./bin/check-deps.sh
107106

108107
setupnamespaces:
109108
PGOROOT='$(PGOROOT)' ./deploy/setupnamespaces.sh

bin/check-deps.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash -e
2+
3+
# Copyright 2020 Crunchy Data Solutions, Inc.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
echo "Ensuring project dependencies..."
17+
18+
if ! command -v go &> /dev/null; then
19+
echo 'Cannot find `go`. Perhaps:'
20+
echo ' sudo yum install golang'
21+
exit 1
22+
fi
23+
if ! sort -VC <<< $'go1.13\n'"$( read -ra array <<< "$(go version)"; echo "${array[2]-}" )"; then
24+
echo 'Old version of `go`: «' "$(go version)" '» Perhaps:'
25+
echo ' sudo yum update golang'
26+
exit 1
27+
fi
28+
29+
if ! command -v buildah &> /dev/null; then
30+
echo 'Cannot find `buildah`. Perhaps:'
31+
echo ' sudo yum install buildah'
32+
exit 1
33+
fi
34+
if ! sort -VC <<< $'1.14.9\n'"$( read -ra array <<< "$(buildah --version)"; echo "${array[2]-}" )"; then
35+
echo 'Old version of `buildah`: «' "$(buildah --version)" '» Perhaps:'
36+
echo ' sudo yum update buildah'
37+
exit 1
38+
fi

bin/get-deps.sh

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,64 +13,19 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
echo "Ensuring project dependencies..."
16+
echo "Getting project dependencies..."
1717
BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1818
EVTDIR="$BINDIR/pgo-event"
1919
POSTGRES_EXPORTER_VERSION=0.8.0
2020

2121

22-
# Idempotent installations
23-
if (yum repolist | egrep -q '^epel/') ; then
24-
echo "Confirmed EPEL repo exists..."
25-
else
26-
echo "=== Installing EPEL ==="
27-
# Prefer distro-managed epel-release if it exists (e.g. CentOS)
28-
if (yum -q list epel-release 2>/dev/null); then
29-
sudo yum -y install epel-release
30-
else
31-
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
32-
fi
33-
fi
34-
35-
if which go; then
36-
echo -n " Found: " && go version
37-
else
38-
echo "=== Installing golang ==="
39-
sudo yum -y install golang
40-
fi
41-
4222
if ! [ -f $EVTDIR/nsqd -a -f $EVTDIR/nsqadmin ]; then
4323
echo "=== Installing NSQ binaries ==="
4424
NSQ=nsq-1.1.0.linux-amd64.go1.10.3
4525
curl -S https://s3.amazonaws.com/bitly-downloads/nsq/$NSQ.tar.gz | \
4626
tar xz --strip=2 -C $EVTDIR/ '*/bin/*'
4727
fi
4828

49-
if which docker; then
50-
# Suppress errors for this call, as docker returns non-zero when it can't talk to the daemon
51-
set +e
52-
echo -n " Found: " && docker version --format '{{.Client.Version}}' 2>/dev/null
53-
set -e
54-
else
55-
echo "=== Installing docker ==="
56-
if [ -f /etc/centos-release ]; then
57-
sudo yum -y install docker
58-
else
59-
sudo yum -y install docker --enablerepo=rhel-7-server-extras-rpms
60-
fi
61-
fi
62-
63-
if which buildah; then
64-
echo -n " Found: " && buildah --version
65-
else
66-
echo "=== Installing buildah ==="
67-
if [ -f /etc/centos-release ]; then
68-
sudo yum -y install buildah
69-
else
70-
sudo yum -y install buildah --enablerepo=rhel-7-server-extras-rpms
71-
fi
72-
fi
73-
7429
# Download Postgres Exporter, only required to build the Crunchy Postgres Exporter container
7530
wget -O $PGOROOT/postgres_exporter.tar.gz https://github.com/wrouesnel/postgres_exporter/releases/download/v${POSTGRES_EXPORTER_VERSION?}/postgres_exporter_v${POSTGRES_EXPORTER_VERSION?}_linux-amd64.tar.gz
7631

docs/content/contributing/developer-setup.md

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This guide is intended for those wanting to build the Operator from source or co
1212

1313
# Prerequisites
1414

15-
The target development host for these instructions is a CentOS 7 or RHEL 7 host. Others operating systems
15+
The target development host for these instructions is a CentOS 8 or RHEL 8 host. Others operating systems
1616
are possible, however we do not support building or running the Operator on others at this time.
1717

1818
## Environment Variables
@@ -23,11 +23,6 @@ Variable | Example | Description
2323
-------- | ------- | -----------
2424
`PGOROOT` | $HOME/postgres-operator | Operator repository location
2525
`PGO_CONF_DIR` | $PGOROOT/installers/ansible/roles/pgo-operator/files | Operator Config Template Directory
26-
`PGO_BASEOS` | {{< param centosBase >}} | Base OS for container images
27-
`PGO_CMD` | kubectl | Cluster management tool executable
28-
`PGO_IMAGE_PREFIX` | crunchydata | Container image prefix
29-
`PGO_OPERATOR_NAMESPACE` | pgo | Kubernetes namespace for the operator
30-
`PGO_VERSION` | {{< param operatorVersion >}} | Operator version
3126

3227
{{% notice tip %}}
3328
`examples/envs.sh` contains the above variable definitions as well as others used by postgres-operator tools
@@ -36,10 +31,9 @@ Variable | Example | Description
3631

3732
## Other requirements
3833

39-
* The development host has been created, has access to `yum` updates, and has a regular user account with `sudo` rights to run `yum`.
4034
* The development host has `git` installed and has cloned the [postgres-operator](https://github.com/CrunchyData/postgres-operator.git) repository. Makefile targets below are run from the repository directory.
4135
* Deploying the Operator will require deployment access to a Kubernetes or OpenShift cluster
42-
* Once you have cloned the git repository, you will need to download the CentOS 7 repository files and GPG keys and place them in the `$PGOROOT/conf` directory. You can do so with the following code:
36+
* Once you have cloned the git repository, you will need to download the CentOS repository files and GPG keys and place them in the `$PGOROOT/conf` directory. You can do so with the following code:
4337

4438
```shell
4539
cd $PGOROOT
@@ -58,14 +52,10 @@ Configuring build dependencies is automated via the `setup` target in the projec
5852

5953
The setup target ensures the presence of:
6054

61-
* EPEL yum repository
6255
* [`go`](https://golang.org/) compiler version 1.13+
6356
* NSQ messaging binaries
64-
* `docker` container tool
6557
* `buildah` OCI image building tool version 1.14.9+
6658

67-
By default, docker is not configured to run its daemon. Refer to the [docker post-installation instructions](https://docs.docker.com/install/linux/linux-postinstall/) to configure it to run once or at system startup. This is not done automatically.
68-
6959
## Code Generation
7060

7161
Code generation is leveraged to generate the clients and informers utilized to interact with the
@@ -110,17 +100,7 @@ After a full compile, you will have a `pgo` binary in `$PGOROOT/bin` and the Ope
110100
# Deployment
111101

112102
Now that you have built the PostgreSQL Operator images, you can now deploy them
113-
to your Kubernetes cluster. To deploy the image and associated Kubernetes
114-
manifests, you can execute the following command:
115-
116-
```shell
117-
make deployoperator
118-
```
119-
120-
If your Kubernetes cluster is not local to your development host, you will need
121-
to specify a config file that will connect you to your Kubernetes cluster. See
122-
the [Kubernetes documentation](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)
123-
for details.
103+
to your Kubernetes cluster by following the [Bash Installation Guide]({{< relref "installation/other/bash.md" >}}).
124104

125105
# Testing
126106

0 commit comments

Comments
 (0)