Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50932

`hostPort` only works for one pod at a time

XMLWordPrintable

    • 1.12.7

      We are running tests against our environments with a test container and a callback container for the tests in the same pod. The callback container has a hostPort defined to receive the callbacks from the services to be tested. Kubernetes plugin up until version 1.3.3 works with our setup, but starting from 1.4.0 it looks like only one of the three pods running in parallel actually manages to get that hostPort, the other two don't.

      The pod definition we are using in the pipeline script looks like this:

      podTemplate(
        name: podName,
        label: podName,
        instanceCap: 1,
        containers: [
          containerTemplate(
            name: 'clitest',
            image: "private-docker-repo/platform/clitest:${clitestVersion}",
            command: 'cat',
            ttyEnabled: true,
            resourceRequestCpu: '500m',
            resourceLimitCpu: '2000m',
            resourceRequestMemory: '1000Mi',
            resourceLimitMemory: '1000Mi',
          ),
          containerTemplate(
            name: 'rcc',
            image: 'private-docker-repo/platform/rcc:0.2',
            command: '/bin/bash',
            args: '-c "/opt/rcc/start.sh `wget -q -O - http://169.254.169.254/latest/meta-data/public-ipv4` ' + rccPort + ' 30304"',
            ports: [portMapping(name: 'rcc', containerPort: rccPort, hostPort: rccPort)],
            ttyEnabled: true,
            resourceRequestCpu: '500m',
            resourceLimitCpu: '500m',
            resourceRequestMemory: '2000Mi',
            resourceLimitMemory: '2000Mi',
          )
        ],
        volumes: [
          emptyDirVolume(mountPath: '/home/jenkins', memory: false),
        ]
      )

      For every pod running, we randomly select a port number between a certain range to be used as the hostPort for the `rcc` container and make the process running in the container listen to the same port.

      `kubectl describe pod` for three pods started in parallel in a job with is attached. From Jenkins master logs I couldn't find anything meaningful related to this.

      Jenkins version: 2.107.2
      Kubernetes plugin version: 1.5.2

        1. clitest-rcc-pods
          18 kB
          Juha Tiensyrjä
        2. clitest-rcc-pods-1.3.3
          18 kB
          Juha Tiensyrjä

            csanchez Carlos Sanchez
            juhtie01 Juha Tiensyrjä
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: