Skip to content

Launch rosco containers tasked with employing Packer to produce vm and docker images

Matt Duftler edited this page May 4, 2015 · 9 revisions

These instructions will walk you step-by-step through:

  • 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
Prerequisites:
Important: All of the following commands are to be executed on a machine that has the Docker daemon installed.
Set some environment variables to save us some typing:
# 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
Launch spinnaker/rosco container to produce AWS image with redis installed:
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 "deb_repo=http://dl.bintray.com/spinnaker/ospackages ./" \
    -var "packages=redis-server" \
    aws-ebs.json
Launch spinnaker/rosco container to produce GCE image with redis installed:
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 "deb_repo=http://dl.bintray.com/spinnaker/ospackages ./" \
    -var "packages=redis-server" \
    gce.json
Launch spinnaker/rosco container to produce Docker image with redis installed:
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 \"deb_repo=http://dl.bintray.com/spinnaker/ospackages ./\" \
        -var \"packages=redis-server\" \
        docker.json"
Launch spinnaker/rosco container to produce AWS image with both redis and kato installed:
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 "deb_repo=http://dl.bintray.com/spinnaker/ospackages ./" \
    -var "packages=redis-server kato" \
    aws-ebs.json
Launch spinnaker/rosco container to produce GCE image with both redis and kato installed:
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 "deb_repo=http://dl.bintray.com/spinnaker/ospackages ./" \
    -var "packages=redis-server kato" \
    gce.json
Launch spinnaker/rosco container to produce Docker image with both redis and kato installed:
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 \"deb_repo=http://dl.bintray.com/spinnaker/ospackages ./\" \
        -var \"packages=redis-server kato\" \
        docker.json"