Setting Up JDBC and MQ Drivers
Starting with Digital.ai Deploy version 24.3.0, there are two types of images available for Kubernetes-based setups with an external database or message queue: slim and non-slim.
Slim Image: This lightweight version of the Release is packaged only with the PostgreSQL driver and the RabbitMQ message queue driver. This helps to reduce the image size and minimize security risks by including only essential components.
Non-Slim Image: The non-slim image comes pre-packaged with a set of supported drivers, such as JDBC database drivers (PostgreSQL, MySQL, H2, and MSSQL) and message queue drivers (ActiveMQ and RabbitMQ).
This document provides instructions on two available options for handling custom drivers:
Using Slim or Non-Slim Images: Focuses on adding JDBC and Message Queue (MQ) drivers to the respective directories in the Deploy container.
Building Custom Deploy Images: Provides steps for creating custom master and worker images that includes specific drivers such as the Oracle JDBC driver.
Option 1: Use Slim Images with Specific Directory for JDBC and Message Queue Driver
Tip: This documentation focuses on the Oracle JDBC driver. However, the process for adding other JDBC and MQ drivers is similar; they should be placed in the /opt/xebialabs/xl-release-server/driver/mq directory.
Directories for JDBC and MQ Drivers:
-
JDBC Drivers Directory:
driver/jdbc
-
Message Queue (MQ) Drivers Directory:
driver/mq
Prerequisites
Ensure you are using the slim version of the Release image, tagged as 24.3-slim (or the version you are working with).
Steps to add Oracle JDBC driver using slim image
- Customize CR with a patch file.
Use the following patch file to download the Oracle JDBC driver and place it in the appropriate directory within the slim image:
cat << EOF > custom-slim-image-patch.yaml
spec:
external:
db:
enabled: true
main:
url: jdbc:oracle:thin:@//db_hostname:1521/db
username: user
password: pass
report:
url: jdbc:oracle:thin:@//db_hostname:1521/db
username: user
password: pass
postgresql:
install: false
initContainers:
- name: db-install
image: library/busybox:stable
imagePullPolicy: IfNotPresent
securityContext:
runAsNonRoot: true
runAsUser: 10001
command:
- "/bin/sh"
- "-c"
args:
- |
export LIB_VERSION=23.4.0.24.05
export LIB_FILE=ojdbc11-${LIB_VERSION}.jar
export LIB_URL=https://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc11/${LIB_VERSION}/${LIB_FILE}
if [ -f "/opt/xebialabs/xl-release-server/driver/jdbc/${LIB_FILE}" ]
then
echo "\${LIB_FILE} exists"
elif wget -P /opt/xebialabs/xl-release-server/driver/jdbc ${LIB_URL}
then
echo "\${LIB_URL} downloaded"
else
echo "Download failed"
fi
volumeMounts:
- name: custom-jdbc-drivers
mountPath: /opt/xebialabs/xl-release-server/driver/jdbc
extraVolumes:
- name: custom-jdbc-drivers
emptyDir: {}
extraVolumeMounts:
- name: custom-jdbc-drivers
mountPath: /opt/xebialabs/xl-release-server/driver/jdbc
readOnly: true
diagnosticMode:
enabled: false
EOF
The initContainer
is configured to download the Oracle JDBC driver and place it directly in the /opt/xebialabs/xl-release-server/driver/jdbc directory, which is already part of the image.
- Patch the CR in digitalai namespace with the following command:
kubectl patch -n digitalai digitalaireleases.xlr.digital.ai dai-xlr \
--type=merge --patch-file custom-slim-image-patch.yaml
- Restart the Release pods.
After restarting, the pods will launch with the new images, which include the Oracle JDBC driver in the lib directory. The external Oracle DB configuration will be applied and used from xl-release.conf file in the conf folder.
Option 2: Build Release Images with Custom Libraries
This option uses custom master and worker images to customize the Release’s lib folder with additional lib - Oracle JDBC. The example starts with building custom images with the additional jar, after that custom images are used to run the containers.
Prerequisites
-
Release installed on a Kubernetes cluster (e.g., in the digitalai namespace).
-
A DockerHub account (or another image registry) to upload the custom images.
With this option, you will have statically built and prepared images that can be scanned and tested with your tool before any production use.
Note: In the following examples, we are downloading the image from the public repository. Ensure that your artifact repository is trusted and secured by your organization. The URL location of the JAR file is provided as an example and can refer to any other repository or library.
Steps to build Deploy images with custom libraries
- Create Dockerfile for master image using the following command:
cat << EOF > Dockerfile
FROM xebialabs/xl-release:24.1.2
USER 0
# download oracle JDBC driver
ENV LIB_VERSION=23.4.0.24.05
ENV LIB_FILE=ojdbc11-\${LIB_VERSION}.jar
ENV LIB_URL=https://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc11/\${LIB_VERSION}/\${LIB_FILE}
# if you need to downaload by using auth for example basic auth, use RUN with curl line instead of following ADD command
# RUN curl -u $user:$pass -o /tmp/\${LIB_FILE} -L \${LIB_URL}
ADD \${LIB_URL} lib/\${LIB_FILE}
RUN chown 10001:10001 lib/\${LIB_FILE} && chmod 664 lib/\${LIB_FILE}
USER 10001
ENTRYPOINT ["/opt/xebialabs/tini", "--", "/opt/xebialabs/xl-release-server/bin/run-in-container.sh"]
EOF
- Build and push the images to the DockerHub:
Note: Use build args for the username and password if you need to log in to your artifact repository.
docker build --build-arg user=your_username --build-arg pass=your_password -t xebialabsunsupported/xl-release:24.1.2-ojdbc11 .
docker push xebialabsunsupported/xl-release:24.1.2-ojdbc11
- Customize CR with patch file:
Here’s how you can use custom images by updating the master and worker image tags and modifying the database configuration to use the Oracle JDBC driver.
cat << EOF > custom-image-and-external-db-patch-1.yaml
spec:
image:
repository: xebialabsunsupported/xl-release
tag: 24.1.2-ojdbc11
imagePullPolicy: Always
external:
db:
enabled: true
main:
url: jdbc:oracle:thin:@//db_hostname:1521/db
username: user
password: pass
report:
url: jdbc:oracle:thin:@//db_hostname:1521/db
username: user
password: pass
postgresql:
install: false
diagnosticMode:
enabled: false
EOF
- Patch the CR in digitalai namespace:
kubectl patch -n digitalai digitalaireleases.xlr.digital.ai dai-xlr \
--type=merge --patch-file custom-image-and-external-db-patch-1.yaml
- Restart the Release pods.
After restarting, the pods will launch with the new images, which include the Oracle JDBC driver in the lib directory. The external Oracle DB configuration will be applied and and used from xl-release.conf
file in the conf folder.