This is a cache of https://docs.openshift.com/serverless/1.34/knative-serving/config-applications/multi-container-support-for-serving.html. It is a snapshot of the page at 2024-11-26T16:32:18.137+0000.
Multi-container support - Configuring OpenShift Serverless applications | Serving | Red Hat OpenShift Serverless 1.34
×

You can deploy a multi-container pod by using a single Knative service. This method is useful for separating application responsibilities into smaller, specialized parts.

Configuring a multi-container service

Multi-container support is enabled by default. You can create a multi-container pod by specifiying multiple containers in the service.

Procedure
  1. Modify your service to include additional containers. Only one container can handle requests, so specify ports for exactly one container. Here is an example configuration with two containers:

    Multiple containers configuration
    apiVersion: serving.knative.dev/v1
    kind: service
    ...
    spec:
      template:
        spec:
          containers:
            - name: first-container (1)
              image: gcr.io/knative-samples/helloworld-go
              ports:
                - containerPort: 8080 (2)
            - name: second-container (3)
              image: gcr.io/knative-samples/helloworld-java
    1 First container configuration.
    2 Port specification for the first container.
    3 Second container configuration.

Probing a multi-container service

You can specify readiness and liveness probes for multiple containers. This feature is not enabled by default and you must configure it using the KnativeServing custom resource (CR).

Procedure
  1. Configure multi-container probing for your service by enabling the multi-container-probing feature in the KnativeServing CR.

    Multi-container probing configuration
    ...
    spec:
      config:
        features:
          "multi-container-probing": enabled (1)
    ...
    1 Enabled multi-container-probing feature
  2. Apply the updated KnativeServing CR.

    $ oc apply -f <filename>
  3. Modify your multi-container service to include the specified probes.

    Multi-container probing
    apiVersion: serving.knative.dev/v1
    kind: service
    ...
    spec:
     template:
       spec:
         containers:
           - name: first-container
             image: ghcr.io/knative/helloworld-go:latest
             ports:
               - containerPort: 8080
             readinessProbe: (1)
               httpGet:
                 port: 8080
           - name: second-container
             image: gcr.io/knative-samples/helloworld-java
             readinessProbe: (2)
               httpGet:
                 port: 8090
    1 Readiness probe of the first container
    2 Readiness probe of the second container