Skip to content

Commit

Permalink
Vital Readme updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlabarge committed May 9, 2019
1 parent 734c41a commit 4e435c0
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions base-image-builder/README.md
Expand Up @@ -11,30 +11,45 @@ The builder also adds the [packer builder](https://github.com/GoogleCloudPlatfor
* PACKER_SPEC the path to the Packer specification in the workspace (passed in as a [substitution with GCB](https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values#using_user-defined_substitutions))


## Create the Builder
## Setup the Cloud Build service account
```
PROJECT=$(gcloud config get-value project)
GCB_SA=$(gcloud projects get-iam-policy $PROJECT --filter="(bindings.role:roles/cloudbuild.builds.builder)" --flatten="bindings[].members" --format="value(bindings.members[])")
gcloud projects add-iam-policy-binding $PROJECT \
--member $GCB_SA --role roles/compute.instanceAdmin.v1
gcloud projects add-iam-policy-binding $PROJECT \
--member $GCB_SA --role roles/iam.serviceAccountUser
```

## Create the base-image-builder

Run this build step and it will:

1. Create a **packer** container image in your GCP Project GCR (later used as a build step)
2. Create a custom GCE image with Nested Virtualization Enabled
3. Create a Packer Agent with **packer** installed and Nested Virtualization Enabled
4. Create a **build-image-builder** container image in your GCP Project GCR
2. Create a custom GCE image with nested virtualization enabled
3. Create a Packer Agent with **packer** installed and nested virtualization enabled
4. Create a **base-image-builder** container image in your GCP Project GCR

```
$ git clone git@github.com:GoogleCloudPlatform/cloud-builders-community
$ git clone https://github.com:GoogleCloudPlatform/cloud-builders-community
$ cd cloud-builders-community/base-image-builder
$ gcloud builds submit .
# or pass in custom substitutions
$ export ZONE=us-central1-c
$ gcloud builds submit . --substitutions "_IMAGE_ZONE=$ZONE,_BUILD_PACKER_AGENT_IMAGE=false,_BUILD_NESTED_VIRT_IMAGE=false"
$ gcloud builds submit . --substitutions "_IMAGE_ZONE=$ZONE,_BUILD_PACKER_AGENT_IMAGE=true,_BUILD_NESTED_VIRT_IMAGE=true"
```

## Create a storage bucket for uploading your custom images
```
gsutil mb gs://$PROJECT-custom-images
```

## Use the Builder to Create a custom GCE image
## Use the base-image-builder to create a custom GCE image

After the builder is successfully built (with the above steps), you can use it to build custom images from an ISO:

```
$ git clone git@github.com:GoogleCloudPlatform/compute-custom-boot-images
$ git clone https://github.com/GoogleCloudPlatform/compute-custom-boot-images
$ cd compute-custom-boot-images
$ gcloud builds submit . --config cloudbuild/custom-boot-image-build.yaml
```
Expand Down

0 comments on commit 4e435c0

Please sign in to comment.