azure-dev icon indicating copy to clipboard operation
azure-dev copied to clipboard

WIP: Adds support for multiple containers within container based hosts

Open wbreza opened this issue 1 year ago • 0 comments

Resolves #3236, #3239

Adds support to configure multiple containers within either ACA/AKS service targets and deploy them as an atomic unit.

Implementation is based on this gist

Use Case: Develop a Helm chart that references multiple containers

Custom variation of Todo AKS template is available @ https://github.com/wbreza/todo-nodejs-mongo-aks/tree/helm

The following will deploy a single service named todo that contains multiple containers that are built from source. The web and api containers will be built, pushed to the container registry then referenced in a local helm chart.

[!NOTE] This example uses helm but will work in any AKS configuration

# azure.yaml

name: todo-nodejs-mongo-aks
metadata:
  template: [email protected]
services:
  todo:
    host: aks
    # Specify the multiple containers that will be deployed when this `todo` service is deployed.
    containers:
      web:
        project: ./src/web
        dist: build
        language: js
      api:
        project: ./src/api
        language: js
    k8s:
      helm:
        releases:
          - name: todo
            # Reference the local helm chart and values.yaml
            chart: ./charts/todo
            values: ./charts/todo/values.yaml
            namespace: todo-helm
            # Override/set additional values in addition to values.yaml
            overrides:
              cluster.clientId: ${AZURE_AKS_IDENTITY_CLIENT_ID}
              keyvault.endpoint: ${AZURE_KEY_VAULT_ENDPOINT}
              appInsights.connectionString: ${APPLICATIONINSIGHTS_CONNECTION_STRING}
              api.image: ${SERVICE_API_IMAGE_NAME}
              web.image: ${SERVICE_WEB_IMAGE_NAME}

Helm Configuration

The helm chart organization of multiple resource components.

image

Helm chart values.yaml contains the baseline configuration for the chart

# values.yaml

api:
  port: 3100
web:
  port: 3000

Use Case: Deploy multiple sidecar containers to a single Azure Container App

Custom variation of Todo ACA template is available @ https://github.com/wbreza/todo-nodejs-mongo-aca/tree/multi-container-poc

In the following example a Todo application with 2 container apps is deployed.

  • web container app contains a single container with standard configuration
  • api container app contains multiple containers leveraging the new containers configuration section
    • Includes a main container as well as a sidecar

[!IMPORTANT] During the deployment a single revision is added referencing both containers

# azure.yaml

name: todo-nodejs-mongo-aca
metadata:
  template: [email protected]
services:
  web:
    project: ./src/web
    language: js
    host: containerapp
  api:
    host: containerapp
    # Configure multiple containers that will be build, tagged and pushed as part of deployment
    containers: 
      main: 
        project: ./src/api
        language: js
      sidecar:
        project: ./src/sidecar
        language: js

Azure Portal after deployment

image

wbreza avatar May 22 '24 00:05 wbreza