Dockerizing IBM Spectrum Symphony service instances with Kubernetes

Dockerize an IBM® Spectrum Symphony service instance to run the service instance inside of a Docker container on Docker enabled hosts.

Dockerizing service instances overview

Once you have created the IBM Spectrum Symphony primary host in the Kubernetes YAML file, you can start a service instance inside of a new Docker container and submit workload to that service instance. The Dockerized service instance will start inside a new Docker container, and will run outside of the compute host Docker container. To run a service instance outside of the compute host Docker container, the compute host must have read/write (rw) permissions to the Docker socket file and the Docker binary file by mounting them to the compute host.
Note: The Docker binary file has dependency libraries on the host OS, which must also be mounted to the compute host if the dependencies do not exist within the Docker image. Use the following command to test whether the Docker image can run the required Docker binaries:
$ docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock -v
/usr/bin/docker:/usr/bin/docker -v /etc/sysconfig/docker:/etc/sysconfig/docker -v
/usr/bin/docker-current:/usr/bin/docker-current rhel docker ps

For Dockerized service instances in a Kubernetes environment, the service instance's Docker container is started by the Docker daemon on the host OS with the Docker 'host' network mode. If the host name is retrieved, the host name of host OS is returned. With symping, the symping service will return the host name of the Docker host in the service code to the symping client.

The service instance manager starts the Docker controller with the start command. By default, IBM Spectrum Symphony uses the consumer OS execution user as the Docker container user.

Docker configuration

You can control the Docker configuration within the Docker section of the application profile, or from the client API.

IBM Spectrum Symphony applies mounted data volumes in the following order:
  1. Default mounted data volumes from deployment directories like $EGO_TOP and $SOAM_DEPLOY_DIR.
  2. Container definition mounted data volumes in the application profile, from beginning to end.
  3. Mounted data volumes from the client API, in the order of the API calls that are made.
The host directory specified for a data volume must be an absolute path; environment variables cannot be specified for a data volume host directory. If more than one data volume is mounted to the container with the same host directory specified, the first data volume to appear in the order listed is overridden. The same rule applies to specified container directories. For example, hostDir1:containerDir1 defined in the application profile would be overridden by hostDir1:containerDir2 defined by the client API.
Note: Default mounted data volumes from deployment directories like $EGO_TOP and $SOAM_DEPLOY_DIR cannot be overridden. You will receive a warning message if you attempt to override these data volumes, and the default definitions for $EGO_TOP and $SOAM_DEPLOY_DIR are used.
The following is a sample of the Docker configuration in the application profile:
<Consumer applicationName="myapp" resourceGroupName="DockerRG"
enableDockerForServiceInstance="true" dockerVersions="1.7.0"
enableSlotRatioResourceLimitScaling="true".../>
<Docker>
  <ContainerDefinition
    name="containerDef1" imageName="RHEL7_IMG"
    registryUrl="192.168.7.26:5000"   containerUser="root" >
      <mount hostDir="/data1" containerDir="/data1" permission="ro" />
      <mount hostDir="/opt/data2"
      containerDir="/data2"   permission="rw" />
      ......
  </ContainerDefinition>
</Docker>
<Service name="myservice" packageName="mypackage" dockerContainerDefinitionName="containerDef1">
  <osTypes>
    <osType startCmd="java -classpath ${SOAM_DEPLOY_DIR}/MyService.jar MyService">           
      <resourceUsage>
        <memory physicalMemoryLimit="1024" virtualMemoryLimit="1024"/>
        <cpu cpuLimit="10"/>           
      </resourceUsage>
    </osType>
  </osTypes>
  …
</Service>
To configure the application profile to run service instance inside of a Docker container, see Configuring Docker for IBM Spectrum Symphony service instances.