Add volumes and files to a container in Azure using Pulumi

300 views Asked by At

I'm starting to use Pulumi for container deployment in Azure cloud. At the moment I am facing problems because I need to load some configuration files to a container of Traefik but I cannot find the correct way. The idea is that Traefik works as a reverse proxy for the other containers in the group.

My problem is that no matter how much I specify the creation of a volume and try to connect it to the container, when I go to the Azure dashboard, it appears that the container does not have any connected volume.

import pulumi
import pulumi_azure_nextgen as azure

data_rg = azure.resources.latest.ResourceGroup(
       "data-rg",
       resource_group_name="data-rg",
       location="West Europe")
datahike_group = azure.containerinstance.latest.ContainerGroup(
        "data-group",
        location="West Europe",
        container_group_name="data-cg",
        resource_group_name=data_rg.name,
        containers=[{
                    "name":"data",
                    "image": "wordpress:latest",
                    "resources": {
                        "requests": { "cpu": 0.5, "memory_in_gb": 1.5}
                    },
                },
                {
                    "name": "proxy",
                    "image": "traefik:latest",
                    "resources": {
                        "requests": { "cpu": 0.5, "memory_in_gb": 1.5}
                    },
                    "ports": [{
                        "port": 80,
                        "protocol": "TCP",
                        }],
                    "VolumeMount": [{
                        "mount_path": "/etc/traefik/config_base.yml",
                        "name": "traefik-volume",
                    }],
                    "environment_variables": [{
                        "name": "TRAEFIK_CONFIG_FILE",
                        "value": "file"
                        },{
                        "name": "TRAEFIK_CONFIG_PATH",
                        "value": "/etc/traefik/config_base.yml"
                        }
                    ],                    
                },        
        ],
        ip_address={
            "dnsNameLabel": "dnsnamelabel1",
            "ports": [{
                "port": 80,
                "protocol": "TCP",
            }],
            "type": "Public",
        },
        volumes=[
            {
                "emptyDir": {},
                "name": "datahike-volume",
            },
            {
                "name": "traefik-volume",
                "secret": {
                    "secretKey1": "SecretValue1InBase64",
                },
            },            
        ],
        os_type="Linux",
        tags={
            "environment": "testing",
        })

pulumi.export("data_ip", data_group.ip_address)

Does anyone know why its failing?

1

There are 1 answers

0
4c74356b41 On BEST ANSWER

in this case, the error was due to a typo:

"volumeMounts": [{
    "mount_path": "/etc/traefik/config_base.yml",
    "name": "traefik-volume",
}],