Skip to content

Commit

Permalink
Use local icon PNG file for ECS
Browse files Browse the repository at this point in the history
  • Loading branch information
grkvlt committed May 16, 2017
1 parent acb9684 commit 0a6dbd9
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 76 deletions.
161 changes: 85 additions & 76 deletions ecs/catalog/ecs/ecs.bom
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ brooklyn.catalog:
description: |
Creates a cluster of Docker engines for use with Amazon ECS
itemType: template
iconUrl: https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/AWS_Simple_Icons_Compute_ECS.svg/240px-AWS_Simple_Icons_Compute_ECS.svg.png
iconUrl: classpath://io.brooklyn.clocker.ecs:icons/ecs.png
item:
services:
- type: ecs-cluster
Expand All @@ -22,7 +22,7 @@ brooklyn.catalog:
description: |
Creates a cluster of Docker engines for use with Amazon ECS
itemType: entity
iconUrl: https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/AWS_Simple_Icons_Compute_ECS.svg/240px-AWS_Simple_Icons_Compute_ECS.svg.png
iconUrl: classpath://io.brooklyn.clocker.ecs:icons/ecs.png
item:
type: org.apache.brooklyn.entity.stock.BasicApplication

Expand Down Expand Up @@ -154,7 +154,7 @@ brooklyn.catalog:
description: |
A docker-engine customised with the ECS agent
itemType: entity
iconUrl: https://raw.githubusercontent.com/docker-library/docs/c350af05d3fac7b5c3f6327ac82fe4d990d8729c/docker/logo.png
iconUrl: classpath://io.brooklyn.clocker.common:icons/docker.png
item:
type: docker-engine

Expand Down Expand Up @@ -194,84 +194,93 @@ brooklyn.catalog:
enabled: $brooklyn:config("docker.sharedsecuritygroup.create")

brooklyn.children:
- type: child-software-process
- type: ecs-agent
id: ecs-agent
name: "ecs-agent"

brooklyn.parameters:
- name: ecs.agent.version
label: "ECS Agent Version"
type: string
default: "1.13.0"
- name: ecs.cluster.name
label: "ECS Cluster Name"
description: |
The name of the ECS cluster
type: string
default: "clocker"
- id: ecs-agent
name: "ECS Agent"
description: |
The ECS agent Docker container
itemType: entity
iconUrl: classpath://io.brooklyn.clocker.ecs:icons/ecs.png
item:
type: child-software-process

brooklyn.config:
shell.env:
ECS_AGENT_VERSION: $brooklyn:config("ecs.agent.version")
ECS_CLUSTER_NAME: $brooklyn:config("ecs.cluster.name")
brooklyn.parameters:
- name: ecs.agent.version
label: "ECS Agent Version"
type: string
default: "1.13.0"
- name: ecs.cluster.name
label: "ECS Cluster Name"
description: |
The name of the ECS cluster
type: string
default: "clocker"

brooklyn.config:
shell.env:
ECS_AGENT_VERSION: $brooklyn:config("ecs.agent.version")
ECS_CLUSTER_NAME: $brooklyn:config("ecs.cluster.name")

install.command: |
sudo yum install -y jq
sudo mkdir -p /var/log/ecs
sudo mkdir -p /var/lib/ecs/data
sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -A PREROUTING \
-p tcp -d 169.254.170.2 --dport 80 \
-j DNAT --to-destination 127.0.0.1:51679
sudo iptables -t nat -A OUTPUT \
-d 169.254.170.2 -p tcp -m tcp \
--dport 80 -j REDIRECT --to-ports 51679
install.command: |
sudo yum install -y jq
sudo mkdir -p /var/log/ecs
sudo mkdir -p /var/lib/ecs/data
sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -A PREROUTING \
-p tcp -d 169.254.170.2 --dport 80 \
-j DNAT --to-destination 127.0.0.1:51679
sudo iptables -t nat -A OUTPUT \
-d 169.254.170.2 -p tcp -m tcp \
--dport 80 -j REDIRECT --to-ports 51679

launch.command: |
docker run --name ecs-agent \
--detach=true \
--restart=on-failure:10 \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--volume=/var/log/ecs/:/log \
--volume=/var/lib/ecs/data:/data \
--net=host \
--env=ECS_LOGFILE=/log/ecs-agent.log \
--env=ECS_LOGLEVEL=info \
--env=ECS_DATADIR=/data \
--env=ECS_CLUSTER=${ECS_CLUSTER_NAME} \
--env=ECS_ENABLE_TASK_IAM_ROLE=true \
--env=ECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST=true \
amazon/amazon-ecs-agent:v${ECS_AGENT_VERSION}
launch.command: |
docker run --name ecs-agent \
--detach=true \
--restart=on-failure:10 \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--volume=/var/log/ecs/:/log \
--volume=/var/lib/ecs/data:/data \
--net=host \
--env=ECS_LOGFILE=/log/ecs-agent.log \
--env=ECS_LOGLEVEL=info \
--env=ECS_DATADIR=/data \
--env=ECS_CLUSTER=${ECS_CLUSTER_NAME} \
--env=ECS_ENABLE_TASK_IAM_ROLE=true \
--env=ECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST=true \
amazon/amazon-ecs-agent:v${ECS_AGENT_VERSION}

checkRunning.command: |
[[ $(docker inspect --format "{{ .State.Running }}" ecs-agent) == "true" ]]
checkRunning.command: |
[[ $(docker inspect --format "{{ .State.Running }}" ecs-agent) == "true" ]]

brooklyn.initializers:
- type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: ecs.agent.version
description: |
ECS installed version details
targetType: string
command: |
curl http://localhost:51678/v1/metadata |
jq '.Version'
- type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: ecs.instance.arn
description: |
ECS instance ARN identifier
targetType: string
command: |
curl http://localhost:51678/v1/metadata |
jq '.ContainerInstanceArn'
- type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: ecs.tasks.count
description: |
ECS task count for the instance
targetType: integer
command: |
curl http://localhost:51678/v1/tasks |
jq '.Tasks[] | .Arn' ~/tmp/ecs/tasks.json |
wc -l
brooklyn.initializers:
- type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: ecs.agent.version
description: |
ECS installed version details
targetType: string
command: |
curl http://localhost:51678/v1/metadata |
jq '.Version'
- type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: ecs.instance.arn
description: |
ECS instance ARN identifier
targetType: string
command: |
curl http://localhost:51678/v1/metadata |
jq '.ContainerInstanceArn'
- type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: ecs.tasks.count
description: |
ECS task count for the instance
targetType: integer
command: |
curl http://localhost:51678/v1/tasks |
jq '.Tasks[] | .Arn' ~/tmp/ecs/tasks.json |
wc -l
4 changes: 4 additions & 0 deletions ecs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<directory>catalog</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>tests</directory>
<filtering>false</filtering>
Expand Down
Binary file added ecs/resources/icons/ecs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a6dbd9

Please sign in to comment.