Skip to content

Commit

Permalink
[capi images] Update to use AMI lookup rather than hardcoded amis
Browse files Browse the repository at this point in the history
  • Loading branch information
detiber committed Aug 26, 2019
1 parent fdda8f2 commit 6b197f4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
2 changes: 1 addition & 1 deletion images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ all: build

# A list of the supported distribution/version combinations. Each member
# of BUILD_NAMES must have a corresponding file "config/BUILD_NAME.json".
BUILD_NAMES ?= ova-centos-7 ova-ubuntu-1804 ami-base-images-us-east-1
BUILD_NAMES ?= ova-centos-7 ova-ubuntu-1804 ami-default

# The version of Kubernetes to install.
KUBE_JSON ?= packer/config/kubernetes.json packer/config/cni.json packer/config/containerd.json
Expand Down
18 changes: 8 additions & 10 deletions images/capi/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
### Build OVAs and AMIs:
# Build OVAs and AMIs

[build ova instructions](packer/ova/README.md)
[build ami instructions](packer/ami/README.md)


### Make targets
## Make targets

Check the Makefile to see a list of images may be built

| Targets |
| Targets |
|---------|
| `make build-ova-centos-7` |
| `make build-ova-ubuntu-1804` |
| `make build-ami-base-images-us-east-1` |

| `make build-ova-ubuntu-1804` |
| `make build-ami-default` |

### Configuration
## Configuration

The `packer/config` directory includes several JSON files that define the configuration for the images:

Expand All @@ -25,6 +23,6 @@ The `packer/config` directory includes several JSON files that define the config
| `packer/config/cni.json` | The version of Kubernetes CNI to install |
| `packer/config/containerd.json` | The version of containerd to install |

### Output
## Output

The OVA images are built and located in `output/BUILD_NAME+kube-KUBERNETES_VERSION`
3 changes: 1 addition & 2 deletions images/capi/packer/ami/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Note: If making the images public (the default), you must use one of the [Public
To build the Ubuntu, CentOS, and Amazon Linux 2 AMIs:

```sh
packer build -var-file base-images-us-east-1.json packer.json
packer build -var-file ami-default.json packer.json
```

The output of this command is a list of created AMIs. To format them you can
Expand All @@ -144,7 +144,6 @@ echo 'us-fake-1: ami-123
us-fake-2: ami-234' | column -t | sed 's/^/| /g' | sed 's/: //g' | sed 's/ami/| ami/g' | sed 's/$/ |/g'
```


By default images are copied to all available AWS regions. The list of all
available regions can be obtained running:

Expand Down
6 changes: 0 additions & 6 deletions images/capi/packer/ami/ami-base-images-us-east-1.json

This file was deleted.

3 changes: 3 additions & 0 deletions images/capi/packer/ami/ami-default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"aws_region": "us-east-1"
}
31 changes: 31 additions & 0 deletions images/capi/packer/ami/packer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"aws_access_key": "",
"aws_secret_key": "",
"aws_region": "",
"build_timestamp": "{{timestamp}}",
"encrypted": "false",
"containerd_version": null,
Expand Down Expand Up @@ -29,6 +30,16 @@
"type": "amazon-ebs",
"instance_type": "t2.small",
"source_ami": "{{user `ubuntu_18_04_ami`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-bionic-18.04-amd64-server-*",
"root-device-type": "ebs",
"architecture": "x86_64"
},
"owners": ["099720109477"],
"most_recent": true
},
"ami_name": "capa-ami-ubuntu-18.04-{{user `kubernetes_version`}}-{{user `build_timestamp`}}",
"ami_groups": "{{user `ami_groups`}}",
"ami_users": "{{user `ami_users`}}",
Expand Down Expand Up @@ -56,6 +67,16 @@
"type": "amazon-ebs",
"instance_type": "t2.small",
"source_ami": "{{user `centos_7_ami`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "CentOS Linux 7 x86_64 HVM EBS ENA*",
"root-device-type": "ebs",
"architecture": "x86_64"
},
"owners": ["410186602215"],
"most_recent": true
},
"ami_name": "capa-ami-centos-7-{{user `kubernetes_version`}}-{{user `build_timestamp`}}",
"ami_groups": "{{user `ami_groups`}}",
"ami_users": "{{user `ami_users`}}",
Expand Down Expand Up @@ -84,6 +105,16 @@
"type": "amazon-ebs",
"instance_type": "t2.small",
"source_ami": "{{user `amazon_2_ami`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "amzn2-ami-hvm-2*",
"root-device-type": "ebs",
"architecture": "x86_64"
},
"owners": ["amazon"],
"most_recent": true
},
"ami_name": "capa-ami-amazon-2-{{user `kubernetes_version`}}-{{user `build_timestamp`}}",
"ami_groups": "{{user `ami_groups`}}",
"ami_users": "{{user `ami_users`}}",
Expand Down

0 comments on commit 6b197f4

Please sign in to comment.