Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ supported operating systems
currently supported image formats (more to follow)
--------------------------------------------------
- AMI
- OpenStack

image building
--------------
Expand Down
46 changes: 33 additions & 13 deletions packer/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
building images
===============
# Building Images

Building images for Kubernetes is easily accomplished with the [Packer](https://github.com/hashicorp/packer) and the templates found in this directory.

aws-quickstart
--------------
## General Prerequisites

- [Packer](https://www.packer.io/docs/installation.html)
- [Ansible](http://docs.ansible.com/ansible/latest/intro_installation.html) version >= 2.4.0.0

## AWS Quickstart

This directory contains the build scripts for the AWS AMI that's used by Heptio's [AWS Quick Start](https://github.com/heptioaws-quickstart). Heptio's AMI is, in turn, built on Ubuntu 16.04 LTS.

prerequisites
-------------
### Prerequisites

To build the AMI, you need:

- [Packer](https://www.packer.io/docs/installation.html)
- [Ansible](http://docs.ansible.com/ansible/latest/intro_installation.html) version >= 2.4.0.0
- An AWS account
- The AWS CLI installed and configured

build the AMI's
---------------
### Build the AMI's

From this directory, simply run:

```
Expand All @@ -26,20 +29,37 @@ This will build AMI images in the us-east AWS region (additional region support

You may limit which images build by adding the `-only=` flag to Packer.

testing the AMIs
----------------
### Testing the AMIs

```
wget https://dl.k8s.io/v1.9.3/kubernetes-test.tar.gz
tar -zxvf kubernetes-test.tar.gz
cd kubernetes/platforms/linux/amd64
sudo ./ginkgo --nodes=8 --flakeAttempts=2 --focus="\[Conformance\]" --skip="\[Flaky\]|\[Serial\]" ./e2e_node.test -- --k8s-bin-dir=/usr/bin
```

deployment
### Deployment
----------
There is a helper script to aid in seeding built AMI's to all other AWS regions.
You can install them with `python3 setup.py install`.

```
copy-ami -r <SOURCE_REGION> -i <SOURCE_AMI> [-q]
```

## OpenStack Quickstart

To get started with pushing Kubernetes-ready images to OpenStack, you'll need to make sure you meet the following requirements:

- Have a running OpenStack environment
- Have OpenStack credentials that can push images

Please note that it is a good idea to brush up on the variables that can be set by reading through the [Packer documentation for OpenStack found here](https://www.packer.io/docs/builders/openstack.html). Once you have done so, please perform the following to build an image and push it to OpenStack:

First, copy the `openstack.json` file found in this folder; rename it to something like `my-custom-options.json`. Next, to build an image and push it OpenStack, run the following command:

```
/path/to/packer build -var-file <COPIED-FILENAME>.json -var kubernetes_version=<YOUR K8S VERSION> -var kubernetes_cni_version=<YOUR K8S CNI VERSION> -var build_version=`git rev-parse HEAD` packer.json
```

If everything was successful, you'll have pushed an image to OpenStack which can be readily used to deploy VMs at your dispense. These images can be treated like any other images in OpenStack and even deployed via [Terraform](https://www.terraform.io/). Please note that Packer cannot build images without a correct OpenStack configuration; which greatly varies based on your unique OpenStack installations. This configuration has been tested with a local dev environment and AWS.
17 changes: 17 additions & 0 deletions packer/openstack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"flavor": "",
"image_name": "",
"identity_endpoint": "",
"source_image": "",
"openstack_username": "",
"openstack_password": "",
"availability_zone": "",
"config_drive": "",
"cacert": "",
"cert": "",
"key": "",
"domain_name": "",
"endpoint_type": "",
"image_visibility": "private",
"insecure": false
}
25 changes: 25 additions & 0 deletions packer/packer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@
"kubernetes_version": "{{user `kubernetes_version`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_version`}}"
}
},
{
"type": "openstack",
"flavor": "{{user `flavor`}}",
"image_name": "{{user `image_name`}}",
"identity_endpoint": "{{user `identity_endpoint`}}",
"source_image": "{{user `source_image`}}",
"username": "{{user `openstack_username`}}",
"password": "{{user `openstack_password`}}",
"availability_zone": "{{user `availability_zone`}}",
"config_drive": "{{user `config_drive`}}",
"cacert": "{{user `cacert`}}",
"cert": "{{user `cert`}}",
"domain_name": "{{user `domain_name`}}",
"endpoint_type": "{{user `endpoint_type`}}",
"image_visibility": "{{user `image_visibility`}}",
"insecure": "{{user `insecure`}}",
"key": "{{user `key`}}",
"metadata": {
"build_version": "{{user `build_version`}}",
"source_image": "{{user `source_image`}}",
"build_date": "{{isotime}}",
"kubernetes_version": "{{user `kubernetes_version`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_version`}}"
}
}
],
"provisioners": [
Expand Down