Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
373 stars 168 forks source link

POC: Adds support for multiple containers for supported service targets (ACA/AKS) #3457

Closed wbreza closed 2 weeks ago

wbreza commented 3 months ago

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: todo-nodejs-mongo-aks@0.0.1-beta
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.

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

# azure.yaml

name: todo-nodejs-mongo-aca
metadata:
  template: todo-nodejs-mongo-aca@0.0.1-beta
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
microsoft-github-policy-service[bot] commented 3 weeks ago

Hi @wbreza. Thank you for your interest in helping to improve the Azure Developer CLI experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

microsoft-github-policy-service[bot] commented 2 weeks ago

Hi @wbreza. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass.