Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
101 stars 28 forks source link

how to link two containers for communication in ECS using shippable #5103

Open tkumark opened 4 years ago

tkumark commented 4 years ago

I have 2 seperate deployment one is aws xray daemon and another is my application which needs to link to aws xray daemon to send telematry. Below is task definition fo xray-daemon

    {
      "name": "xray-daemon",
      "image": "amazon/aws-xray-daemon",
      "cpu": 32,
      "memoryReservation": 256,
      "portMappings" : [
          {
              "hostPort": 0,
              "containerPort": 2000,
              "protocol": "udp"
          }
       ],
    }

shippable.resources.yml

resources:
  - name: aws-xray-daemon-img
    type: image
    integration: docker-hub-integration
    versionTemplate: 
      sourceName: "amazon/aws-xray-daemon"
      versionName: latest

  - name: daemon-docker-opts
    type: dockerOptions
    version:
      cpuShares: 32
      logConfig:
        type: "json-file"
      portMappings:
        - "0:2000"
      service:
        schedulingStrategy: DAEMON

Shippable.jobs.yml

jobs:
  - name: aws-xray-daemon-man
    type: manifest
    steps:
      - IN: aws-xray-daemon-img
      - IN: daemon-docker-opts
    flags:
      - xray-daemon

  - name: xray-daemon-dev-ecs
    type: deploy
    steps:
      - IN: aws-xray-daemon-man
      - IN: splat-dev-clu
      - TASK: managed

This this is the sample task definition of my application should look like. As you see below you will see 2 references to aws xay one at the links and another at the environment variable. I need help how to describe this in shippable and link to aws xray daemon?

    {
      "name": "scorekeep-api",
      "image": "123456789012.dkr.ecr.us-east-2.amazonaws.com/scorekeep-api",
      "cpu": 192,
      "memoryReservation": 512,
      "environment": [
          { "name" : "AWS_REGION", "value" : "us-east-2" },
          { "name" : "NOTIFICATION_TOPIC", "value" : "arn:aws:sns:us-east-2:123456789012:scorekeep-notifications" },
          { "name" : "AWS_XRAY_DAEMON_ADDRESS", "value" : "xray-daemon:2000" }
      ],
      "portMappings" : [
          {
              "hostPort": 5000,
              "containerPort": 5000
          }
      ],
      "links": [
        "xray-daemon"
      ]
    }
a-murphy commented 4 years ago

Links may be specified in a dockerOptions resource used as an input to the manifest job, and environment variables in a params resource. However, you may need to deploy both together for the connections between them to work as expected. Linking by container name usually expects the containers to be in the same task definition.