-
Notifications
You must be signed in to change notification settings - Fork 641
Launch rosco containers tasked with employing Packer to produce vm and docker images
Matt Duftler edited this page Apr 20, 2015
·
9 revisions
- Producing an AWS image with redis installed
- Producing a GCE image with redis installed
- Producing both AWS and GCE images, each with both redis and kato installed
- A Docker daemon and Docker registry running and accessible (the setup this page describes is sufficient: Run Docker on a GCE Container optimized VM)
- The Docker registry must contain the spinnaker/rosco image that was produced by following these instructions: Build Docker image using spinnaker/rosco artifacts
Important: All of the following commands are to be executed on a machine that has the Docker daemon installed.
# Common:
# Note: Both the AWS and GCE builders will fail to complete their work if
# the specified target image already exists. If you execute the commands
# below multiple times, remember to alter the TARGET_IMAGE_NAME or delete
# the image in between executions.
export DOCKER_IMAGE_NAME=spinnaker/rosco
export DOCKER_REGISTRY=localhost:5000
export TARGET_IMAGE_NAME=newly-baked-image
# Needed for baking AWS images:
# Replace values of aws_access_key and aws_secret_key with your keys.
export AWS_ACCESS_KEY=foo
export AWS_SECRET_KEY=bar
# Needed for baking GCE images:
# You must ensure that the project id specified in gce_project_id is the
# same one for which you retrieved account credentials (i.e. the contents
# of the account.json file).
export GCE_PROJECT_ID=your-project-id
# Needed for baking Docker images:
# You must ensure that this address/port is reachable from the docker daemon.
export TARGET_DOCKER_REGISTRY=docker-1:5000
sudo docker run $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME packer build \
-var "aws_access_key=$AWS_ACCESS_KEY" \
-var "aws_secret_key=$AWS_SECRET_KEY" \
-var "aws_region=us-east-1" \
-var "aws_ssh_username=ubuntu" \
-var "aws_instance_type=t2.micro" \
-var "aws_source_ami=ami-9eaa1cf6" \
-var "aws_target_ami=$TARGET_IMAGE_NAME" \
-var "packages=redis-server" \
aws-ebs.json
sudo docker run $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME packer build \
-var "gce_project_id=$GCE_PROJECT_ID" \
-var "gce_zone=us-central1-a" \
-var "gce_source_image=ubuntu-1404-trusty-v20141212" \
-var "gce_target_image=$TARGET_IMAGE_NAME" \
-var "packages=redis-server" \
gce.json
sudo docker run --privileged=true $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME \
sh -c "sudo service docker start && packer build \
-var \"docker_source_image=ubuntu:trusty\" \
-var \"docker_target_image=$TARGET_IMAGE_NAME\" \
-var \"docker_target_repository=$TARGET_DOCKER_REGISTRY\" \
-var \"packages=redis-server\" \
docker.json"
sudo docker run $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME packer build \
-var "aws_access_key=$AWS_ACCESS_KEY" \
-var "aws_secret_key=$AWS_SECRET_KEY" \
-var "aws_region=us-east-1" \
-var "aws_ssh_username=ubuntu" \
-var "aws_instance_type=t2.micro" \
-var "aws_source_ami=ami-9eaa1cf6" \
-var "aws_target_ami=$TARGET_IMAGE_NAME" \
-var "packages=redis-server kato" \
aws-ebs.json
sudo docker run $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME packer build \
-var "gce_project_id=$GCE_PROJECT_ID" \
-var "gce_zone=us-central1-a" \
-var "gce_source_image=ubuntu-1404-trusty-v20141212" \
-var "gce_target_image=$TARGET_IMAGE_NAME" \
-var "packages=redis-server kato" \
gce.json
sudo docker run --privileged=true $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME \
sh -c "sudo service docker start && packer build \
-var \"docker_source_image=ubuntu:trusty\" \
-var \"docker_target_image=$TARGET_IMAGE_NAME\" \
-var \"docker_target_repository=$TARGET_DOCKER_REGISTRY\" \
-var \"packages=redis-server kato\" \
docker.json"