skip to Main Content

I am struggling with a azure container sizing problem. I am using linux-container in western europe. I built my containers from a code-server with a yaml file. The basic setup is that I use:

CPU: 1
Memory: 4

and when I try to change it to :

CPU: 1
Memory: 8

or:

CPU: 2
Memory: 8

The command i use is:
az container create -g {config["general"]["resource_group"]} -f container_deployment.yaml'

And the yaml.file:

additional_properties: {}
apiVersion: '2023-05-01'
extended_location: null
location: westeurope
name: XXX
properties:
  containers:
  - name: "c0"
    properties:
      environmentVariables:
      - name: INDEX
        value: 0      
      image: ABC.azurecr.io/model-factory:v28
      resources:
        requests:
          cpu: 1
          memoryInGB: 4
  - name: "c1"
    properties:
      environmentVariables:
      - name: INDEX
        value: 1      
      image: ABC.azurecr.io/model-factory:v28
      resources:
        requests:
          cpu: 1
          memoryInGB: 4
  - name: "c2"
    properties:
      environmentVariables:
      - name: INDEX
        value: 2      
      image: ABC.azurecr.io/model-factory:v28
      resources:
        requests:
          cpu: 1
          memoryInGB: 4
  - name: "c3"
    properties:
      environmentVariables:
      - name: INDEX
        value: 3
      image: ABC.azurecr.io/model-factory:v28
      resources:
        requests:
          cpu: 1
          memoryInGB: 4
  imageRegistryCredentials: # Credentials to pull a private image
  - server: ABC.azurecr.io
    username: "username"
    password: "pw"
  initContainers: []
  osType: Linux
  restartPolicy: OnFailure
  sku: Standard
  subnetIds:
  - id: /subscriptions/abcd
tags: {}
type: Microsoft.ContainerInstance/containerGroups

I always built 4 containers in my container app.

I get the error:

Deploying Containers
ERROR: (InvalidContainerGroupUpdate) The updates on container group ‘XXX’ are invalid. If you are going to update the Memory Resource (old "16", new "32") for a container group, you must delete it first and then create a new one.
Code: InvalidContainerGroupUpdate
Message: The updates on container group ‘XXX’ are invalid. If you are going to update the Memory Resource (old "16", new "32") for a container group, you must delete it first and then create a new one.
Traceback (most recent call last):

I wonder why this happens, because the offical docs say that I can upsize it to 4 and 16.

2

Answers


  1. Chosen as BEST ANSWER

    The solution is that you cannot create 4 containers with more then 1 cpu and 4 memory, because that would exceed the size limit. They add up to each other.


  2. To adjust memory or CPU resources for an Azure Container Instance, you must recreate the container group with the updated settings, as ACI doesn’t support dynamic resource scaling for running instances. You need to first-

    Delete the Existing Container Group: Remove the current container group using the Azure CLI:

    az container delete -g [ResourceGroupName] -n [ContainerGroupName]
    

    enter image description here

    Update the YAML Configuration: Edit your container_deployment.yaml file to reflect the new resource requirements. For instance, to update to 2 CPUs and 8 GB of memory, modify the resources block:

    resources:
      requests:
        cpu: 2
        memoryInGB: 8
    

    Recreate the Container Group: Deploy the updated container group with the Azure CLI:

    az container create -g [ResourceGroupName] -f container_deployment.yaml
    

    or from portal
    enter image description here

    This process will ensure your container group is configured with the desired resource allocations.
    enter image description here

    References:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search