Extending containerized agents

To extend the containerized agents, you need to add this functionality to the IBM® UrbanCode® Deploy container agent.

  1. Create Dockerfile for extended image.
    Extending the agent container image can be accomplished by specifying the agent build level that you wish to enhance as your base image and then invoking the docker entrypoint provided by the base image. Here is an example Dockerfile and shell script that can be used to add Python 3.8 to the 7.1.2.1 agent image:
    • Dockerfile
      # Base image for 7.1.2.1 agent version
      ARG BASE_IMAGE=”cp.icr.io/cp/ibm-ucda@sha256:76ddedef53b5b5f6f5f72d1f14068967b133b04ad4018df014b1228f5eb259a3”
      FROM ${BASE_IMAGE}
      # Copy shell script into /tmp directory
      COPY artifacts/* /tmp/
      # Important: Need root access to install packages
      USER root
      # Install packages to extend agent functionality
      RUN bash /tmp/install-pkgs-extend.sh
      USER 1001
      # Important: Must invoke existing docker-entrypoint script provided by base image
      ENTRYPOINT [“/usr/local/bin/docker-entrypoint.sh”]
      
    • install-pkgs-extend.sh
      #!/bin/bash
      # List of packages to install
      PKG_LIST="python38"
      # Agent is based on RHEL8 ubi-minimal image which uses microdnf to install packages
      microdnf update -y
      microdnf install -y --nodocs ${PKG_LIST}
      microdnf clean all
      rm -rf /var/cache/microdnf
      rm -rf /var/tmp/microdnf-*
  2. Identify the agent base image.
    The base image that you use is based on the agent version that you wish to extend. The supported agent versions can be located in the templates/_ucd-chart-config.tpl file of the agent Helm Chart. Here are some examples:
    {{- define "{{ .Chart.Name }}.imageSpec" -}}
    {{- if contains "extended" .Values.version -}}
     {{ .Values.version }}
    {{- else if eq .Values.version "7.1.2.1" -}}
     cp.icr.io/cp/ibm-ucda@sha256:76ddedef53b5b5f6f5f72d1f14068967b133b04ad4018df014b1228f5eb259a3
    {{- else if eq .Values.version "7.1.2.0" -}}
     cp.icr.io/cp/ibm-ucda@sha256:366642772a2e84decfcbeda42745494f23a494d24248f838a00e8f2139a122d8
    {{- else if eq .Values.version "7.1.1.2" -}}
     cp.icr.io/cp/ibm-ucda@sha256:0bf58dc592ca7127fec75148df8ba92f29a55e072c6b056e534ab1ab0695709c
    {{- else if eq .Values.version "7.1.1.1" -}}
     cp.icr.io/cp/ibm-ucda@sha256:8a3c5815cdfc7852a74fb62ba5c4a954246a17a6947cefc561f29de2181081ae
    {{- else if eq .Values.version "7.1.1.0" -}}
     cp.icr.io/cp/ibm-ucda@sha256:6b34cf4a0ce9b2f6398ea2bb41e8d614bba7befe8f5cbdce6d06d78c9207042d
    {{- else if eq .Values.version "7.1.0.3" -}}
     cp.icr.io/cp/ibm-ucda:7.1.0.3.1069281
    {{- else -}}
     cp.icr.io/cp/ibm-ucda:unknownProductVersion{{- end -}}
    {{- end -}}
  3. Authenticate to IBM Entitlement Registry prior to building the image.
    To pull the base image from the desired entitlement registry, you must perform a docker login prior to the running docker build command. Here is an example docker login command to use:
    docker login cp.icr.io -u cp -p EntitlementKey
    The EntitlementKey can be obtained by logging into MyIBM Container Software Library with your IBMid and password that are associated with the entitled software. In the Entitlement keys section, select Copy key to copy the key to the clipboard and use it in your docker login command.
  4. Update the agent Helm chart.
    Note: This step is only required for agent releases prior to 7.2.0.0
    In order to use the extended agent image, you will need to update the _ucd-chart-config.tpl file to look something like this:
    {{- define "{{ .Chart.Name }}.imageSpec" -}}
    {{- if contains "extended" .Values.version -}}
     {{ .Values.version }}
    {{- else if eq .Values.version "7.1.2.1" -}}
     cp.icr.io/cp/ibm-ucda@sha256:76ddedef53b5b5f6f5f72d1f14068967b133b04ad4018df014b1228f5eb259a3
    {{- else if eq .Values.version "7.1.2.0" -}}
     cp.icr.io/cp/ibm-ucda@sha256:366642772a2e84decfcbeda42745494f23a494d24248f838a00e8f2139a122d8
    {{- else if eq .Values.version "7.1.1.2" -}}
     cp.icr.io/cp/ibm-ucda@sha256:0bf58dc592ca7127fec75148df8ba92f29a55e072c6b056e534ab1ab0695709c
    {{- else if eq .Values.version "7.1.1.1" -}}
     cp.icr.io/cp/ibm-ucda@sha256:8a3c5815cdfc7852a74fb62ba5c4a954246a17a6947cefc561f29de2181081ae
    {{- else if eq .Values.version "7.1.1.0" -}}
     cp.icr.io/cp/ibm-ucda@sha256:6b34cf4a0ce9b2f6398ea2bb41e8d614bba7befe8f5cbdce6d06d78c9207042d
    {{- else if eq .Values.version "7.1.0.3" -}}
     cp.icr.io/cp/ibm-ucda:7.1.0.3.1069281
    {{- else -}}
     cp.icr.io/cp/ibm-ucda:unknownProductVersion
    {{- end -}}
    {{- end -}}
    Note that lines 2 and 3 are added to the logic.
  5. Specify the new ImageSpec for deployment.
    To use the extended image, specify the imagespec in the version parameter of your values.yaml file. The tag for your image must include the word “extended” for this process to work. Here is an example values.yaml:
    # Agent Version
    version: "myregistry/agent:7.1.2.1-extended-amd64"
    Update remaining parameters in values.yaml for your modified helm chart and then run the helm install command.
  6. Verify successful agent deployment.
    To verify your packages were installed successfully, you can run the kubectl exec -it <podname> -- /bin/sh command to open a command prompt into the running agent.