Skip to content

Commit

Permalink
feat: use multiple containers within snowpark service
Browse files Browse the repository at this point in the history
  • Loading branch information
snandam committed Jul 29, 2024
1 parent 63b3b63 commit 1c2c6c9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
25 changes: 17 additions & 8 deletions examples/command/portals/snowflake/example-5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,18 @@ GRANT ALL ON STREAM CDC_TEST_TABLE_STREAM TO ROLE CDC_TEST_ROLE;


```sh
cd snowflake_cdc_publisher

# Build and push cdc publisher docker image
cd snowflake_cdc_publisher/cdc_publisher
# Use the value of the repository_url from SHOW IMAGE REPOSITORIES command
docker login <repository_url>
docker build --rm --platform linux/amd64 -t <repository_url>/snowflake_cdc_kafka_bridge .
docker push <repository_url>/snowflake_cdc_kafka_bridge

cd -
# Build and push ockam image
cd ../ockam
docker build --rm --platform linux/amd64 -t <repository_url>/ockam .
docker push <repository_url>/ockam

```

## Deploy Snowflake CDC Publisher with Ockam in Snowpark Container services
Expand All @@ -135,7 +139,7 @@ cd -
```sh
#Example
VALUE_LIST = ("k8s-XXX.amazonaws.com:4XXX","k8s-XXX.amazonaws.com:4XXX");
VALUE_LIST = ("k8s-XXX.amazonaws.com:4XXX");
```

> [!IMPORTANT]
Expand All @@ -155,7 +159,7 @@ VALUE_LIST = ('ocsp.snowflakecomputing.com:80');

-- Update VALUE_LIST with ockam egress details
CREATE NETWORK RULE CDC_TEST_OCKAM_OUT TYPE = 'HOST_PORT' MODE = 'EGRESS'
VALUE_LIST = ('TODO:TODO', 'TODO:TODO');
VALUE_LIST = ('TODO:TODO');


-- Create access integration
Expand All @@ -178,6 +182,12 @@ CREATE SERVICE SNOWFLAKE_CDC_KAFKA_BRIDGE
$$
spec:
containers:
- name: ockam
image: /cdc_test_db/cdc_test_schema/cdc_test_repo/ockam
env:
OCKAM_DISABLE_UPGRADE_CHECK: true
OCKAM_OPENTELEMETRY_EXPORT: false
ENROLLMENT_TICKET: "<OCKAM_ENROLLMENT_TICKET>"
- name: publisher
image: /cdc_test_db/cdc_test_schema/cdc_test_repo/snowflake_cdc_kafka_bridge
env:
Expand All @@ -187,17 +197,16 @@ $$
SNOWFLAKE_WAREHOUSE: CDC_TEST_WH
JOB_SUCCESS_SLEEP_TIME: 30
JOB_ERROR_SLEEP_TIME: 60
OCKAM_DISABLE_UPGRADE_CHECK: true
OCKAM_OPENTELEMETRY_EXPORT: false
ENROLLMENT_TICKET: "<OCKAM_ENROLLMENT_TICKET>"
$$
EXTERNAL_ACCESS_INTEGRATIONS = (CDC_TEST_EXTERNAL_ACCESS_INT)
MIN_INSTANCES=1
MAX_INSTANCES=1;


SHOW SERVICES;
SELECT SYSTEM$GET_SERVICE_STATUS('SNOWFLAKE_CDC_KAFKA_BRIDGE');
DESCRIBE SERVICE SNOWFLAKE_CDC_KAFKA_BRIDGE;
CALL SYSTEM$GET_SERVICE_LOGS('SNOWFLAKE_SN_CDC_KAFKA_BRIDGE', '0', 'ockam', 1000);
CALL SYSTEM$GET_SERVICE_LOGS('SNOWFLAKE_CDC_KAFKA_BRIDGE', '0', 'publisher', 1000);
-- Client runs every 30 seconds and pick up changes from CDC_TEST_TABLE_STREAM
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ARG BASE_IMAGE=python:3.10-slim-buster

FROM ghcr.io/build-trust/ockam as ockam

FROM $BASE_IMAGE

RUN pip install --upgrade pip && \
Expand All @@ -10,8 +8,5 @@ RUN pip install --upgrade pip && \
pip install snowflake-connector-python

COPY snowflake_cdc_publisher.py ./
COPY --from=ockam /ockam /usr/local/bin/ockam
COPY --chmod=555 run.sh /run.sh

ENTRYPOINT ["/run.sh"]

CMD ["python", "snowflake_cdc_publisher.py"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG BASE_IMAGE=python:3.10-slim-buster
FROM ${BASE_IMAGE} AS base
EXPOSE 9092
FROM ghcr.io/build-trust/ockam AS builder

# Copy the ockam binary from the builder stage to the base image
FROM base AS final
COPY --from=builder /ockam /usr/local/bin/ockam

# Copy the run.sh script to the base image and set appropriate permissions
COPY --chmod=555 run.sh /run.sh

# Set the entry point to run.sh
ENTRYPOINT ["/run.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ kafka-inlet:
to: /project/default/service/forward_to_kafka/secure/api
EOF

ockam node create --foreground ./ockam.yaml &

sleep 10

python ./snowflake_cdc_publisher.py
ockam node create --foreground ./ockam.yaml

0 comments on commit 1c2c6c9

Please sign in to comment.