You can create custom images to support third-party drivers and libraries that are needed
to connect to third-party systems such as SQL Server databases.
About this task
To connect to third-party systems, such as SQL Server databases, Oracle databases, SAP R/3
systems, you must install third-party libraries and drivers. You can create custom images to support
these third-party drivers and libraries. Custom images have the benefits of being unchangeable after
they are built and reliably consistent across different environments. You can also scan the images
for vulnerability.
Procedure
To create a custom image, complete the following steps.
Note:
- For steps 2 - 8 in the procedure, you can use either Docker (for OpenShift Container Platform
(OCP) 3.11) or the Pod Manager tool (Podman) (for OpenShift 4.3+). The example commands in the
procedure use Docker. If you are using Podman, replace docker with
podman.
- You can use an external or internal registry for the procedure. The command examples assume that
you are using an external registry
(default-route-openshift-image-registry.apps.zlnov16.cp.fyre.ibm.com). If you are using an internal
registry, replace the external registry in the examples.
- Identify the location of the image to update:
- Compute
image:
$ oc describe pod ds-engine-compute-0 | grep 'is-en-compute-image:'
Image: image-registry.openshift-image-registry.svc:5000/ds/is-en-compute-image:b1592-develop-b2300
- Conductor
image:
$ oc describe pod is-en-conductor-0 | grep 'is-engine-image:'
Image: image-registry.openshift-image-registry.svc:5000/ds/is-engine-image:b1649-develop-b2356
- Log in to your Docker registry.
If the docker registry appears as 'image-registry.openshift-image-registry.svc:5000', then it's
the internal route to the registry on the cluster. Run one of the following commands to get the
external route:
- Update Docker to add the registry as an insecure registry if you're using the internal
registry on the cluster. Use the current oc session token for login:
$ docker login default-route-openshift-image-registry.apps.zlnov16.cp.fyre.ibm.com -u $(oc whoami) -p $(oc whoami -t)
- Verify that you can pull the image from the registry in OpenShift:
$ docker pull default-route-openshift-image-registry.apps.zlnov16.cp.fyre.ibm.com/ds/is-engine-image:b1649-develop-b2356
- Create a Dockerfile:
FROM default-route-openshift-image-registry.apps.zlnov16.cp.fyre.ibm.com/ds/is-engine-image:b1649-develop-b2356
#Use COPY to copy local files to the build container
#Use RUN to execute commands in the build container
#copy local file install_packages.sh to /tmp in the container
COPY install_packages.sh /tmp
#run install_packages.sh
RUN sh /tmp/install_packages.sh
- Build and tag the image with a new suffix (run the command in the directory that contains
the Dockerfile):
$ docker build -t default-route-openshift-image-registry.apps.zlnov16.cp.fyre.ibm.com/ds/is-engine-image:b1649-develop-b2356-UPDATE1
- Push the image to the registry:
$ docker push default-route-openshift-image-registry.apps.zlnov16.cp.fyre.ibm.com/ds/is-engine-image:b1649-develop-b2356-UPDATE1
- Update the image tag used by the ds-engine-compute StatefulSet. On the cluster, only the
internal route for the registry can be used.
$ oc edit sts is-en-conductor
- Optional: For some situations where entries to Pod /etc/hosts need to be
added, follow the instructions in https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases.
For
example, to add the entry "1.2.3.4 myhost1.fyre.ibm.com myhost1" to the is-en-conductor-0 pod
/etc/hosts file, you can complete the following steps:
- Backup the is-en-conductor
statefulset:
$ oc get sts is-en-conductor -o yaml > is-en-conductor_backup.yaml
- Create a new
file:
$ cp is-en-conductor_backup.yaml is-en-conductor.yaml
- Update the is-en-conductor.yaml file by adding this section under spec: -> template: ->
spec:
hostAliases:
- ip: "1.2.3.4"
hostnames:
- "myhost1.fyre.ibm.com"
- "myhost1"
- Update the sts
is-en-conductor:
$ oc replace -f is-en-conductor.yaml
- Wait for the is-en-conductor-0 pod to be restarted by
checking:
$ oc get pod | grep is-en-conductor-0
- Confirm the entry is added to the /etc/hosts
file:
$ oc exec -it is-en-conductor-0 -- cat /etc/hosts