Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add sample docs for running GOE via Google Cloud Run #186

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/google_cloud_run/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 The GOE Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM google/cloud-sdk:slim
RUN apt-get update
# Oracle client
RUN apt-get -y install libaio1 libaio-dev unzip wget
RUN wget -q https://download.oracle.com/otn_software/linux/instantclient/218000/instantclient-sdk-linux.x64-21.8.0.0.0dbru.zip && \
wget -q https://download.oracle.com/otn_software/linux/instantclient/218000/instantclient-basic-linux.x64-21.8.0.0.0dbru.zip && \
wget -q https://download.oracle.com/otn_software/linux/instantclient/218000/instantclient-tools-linux.x64-21.8.0.0.0dbru.zip && \
mkdir /opt/oracle && \
unzip instantclient-sdk-linux.x64-21.8.0.0.0dbru.zip -d /opt/oracle/ && \
unzip instantclient-basic-linux.x64-21.8.0.0.0dbru.zip -d /opt/oracle/ && \
unzip instantclient-tools-linux.x64-21.8.0.0.0dbru.zip -d /opt/oracle/
ENV ORACLE_HOME=/opt/oracle/instantclient_21_8
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_21_8
# Python pre-reqs (gcc for cx_Oracle)
RUN apt-get install python3.11 python3.11-venv gcc -y
# Install GOE
ENV OFFLOAD_HOME=/opt/goe/offload
RUN mkdir /opt/goe
COPY goe.tar.gz /opt/goe/
RUN cd /opt/goe && tar xf goe.tar.gz
RUN cd ${OFFLOAD_HOME} && python3.11 -m venv ./.venv
COPY offload.env ${OFFLOAD_HOME}/conf/
RUN . ${OFFLOAD_HOME}/.venv/bin/activate && pip install --root-user-action=ignore --upgrade pip
RUN . ${OFFLOAD_HOME}/.venv/bin/activate && pip install --root-user-action=ignore ${OFFLOAD_HOME}/lib/goe-$(cat ${OFFLOAD_HOME}/version)-py3-none-any.whl
# Entrypoint
COPY goe.sh /opt/goe/
RUN chmod 500 /opt/goe/goe.sh
ENTRYPOINT ["/opt/goe/goe.sh"]
84 changes: 84 additions & 0 deletions docs/google_cloud_run/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Executing GOE Commands via Cloud Run Jobs

Below is an example of how to submit GOE using Cloud Build and then execute GOE commands via Cloud Run.

## Pre-requisites

You must first have:

- Installed the GOE repository into the source RDBMS system using the same version of the software that will be built in this process.
- Prepared and tested your `offload.env` file.

## Helper variables

```
GOE_VERSION=1.0.3
PROJECT=your-project
REGION=europe-west1
NETWORK=goe
BUCKET=your-bucket
SVC_ACCOUNT="your-goe-service-account@${PROJECT}.iam.gserviceaccount.com"
```

## Create a GOE Build

Follow these steps from within the directory containing the `Dockerfile` and `goe.sh` files.

### Download a GOE release

For example:
```
wget -q -O goe.tar.gz \
https://github.com/gluent/goe/releases/download/v${GOE_VERSION}/goe.tar.gz
```

### Include an Offload configuration file

For example:
```
scp goe-node:/opt/goe/offload/conf/offload.env ./
```

It is recommended to set OFFLOAD_LOGDIR to a Google Cloud Storage location in your `offload.env` file.

### Submit the Build

```
gcloud builds submit . --tag gcr.io/${PROJECT}/goe-${GOE_VERSION} \
--project=${PROJECT} --region=${REGION} \
--gcs-log-dir=gs://${BUCKET}/gcbr-logs
```

## Example Connect Command

```
JOB_NAME=connect-$(date +'%Y%m%d-%H%M%S')

gcloud run jobs create ${JOB_NAME} \
--project=${PROJECT} --region ${REGION} \
--network=${NETWORK} \
--service-account=${SVC_ACCOUNT} \
--image gcr.io/${PROJECT}/goe-${GOE_VERSION} \
--max-retries 0 \
--args "connect,--no-ansi"

gcloud run jobs execute ${JOB_NAME} --wait \
--project=${PROJECT} --region=${REGION}
```

## Example Offload Command

```
JOB_NAME=offload-ACME-FACT-$(date +'%Y%m%d-%H%M%S')

gcloud run jobs create ${JOB_NAME} \
--project=${PROJECT} --region ${REGION} \
--network=${NETWORK} \
--service-account=${SVC_ACCOUNT} \
--image gcr.io/${PROJECT}/goe-${GOE_VERSION} \
--max-retries 0 \
--args "offload,-t,acme.fact,-x,--no-ansi"

gcloud run jobs execute ${JOB_NAME} --wait \
--project=${PROJECT} --region=${REGION}
```
30 changes: 30 additions & 0 deletions docs/google_cloud_run/goe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2024 The GOE Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [[ -z "$1" ]];then
echo "Usage: $0 offload ..."
echo " or: $0 connect"
exit 1
fi

if [[ "$1" != "connect" && "$1" != "offload" ]];then
echo "Usage: $0 offload ..."
echo " or: $0 connect"
exit 1
fi

export USER=$(whoami)
. ${OFFLOAD_HOME}/.venv/bin/activate
$*
Loading