Giter Club home page Giter Club logo

kubevirt-cloud-image-builder's Introduction

KubeVirt Cloud Image Builder

The repo contains scripts and playbooks that can be used to build and test an Amazon AWS AMI/GCP image containing Kubernetes and KubeVirt.

Build

Packer is used to build the KubeVirt AMIs/GCP Images, so you will need to install it first.

After you have installed packer, then take a look at the environment file corresponding to your platform. The file contains all of the enviroment variables that are expected to be filled for the build process to work. Some of these variables include your AWS key, instance type, region, security group id, path to packer, and the packer build template. Before running the build.sh script, you will need to either source this file with the appropriate values or populate them directly into your environment.

To build the Image, run the build.sh script. The script clones the kubevirt-ansible directory, copies a playbook to allow localhost installation of Kubernetes, and invokes the packer build command using the specified build template. The build template for CentOS is kubevirt-ami-centos.json.

Packer then creates an AWS instance using the base CentOS AMI. If you examine the build template, you will notice that kubevirt-ansible, a few playbooks, a first-boot.sh script, and a kubevirt-installer.service file are copied into the instance. At the very end, some packages that are used by Kubernetes and KubeVirt are preinstalled. When the provisioning steps are complete, packer shuts down the instance and creates an new AMI off of the current instance state.

Why is there a first-boot.sh script and a kubevirt-installer.service file? When you install Kubernetes, the node's hostname is incorporated in certificates and other settings, so we cannot preinstall Kubernetes in the AMI which would mean it would use the build instance's hostname. When a user creates a new instance from the AMI the hostname changes. Therefore, a service was created to execute first-boot.sh which installs Kubernetes and KubeVirt the first time the instance is started, and which will be configured with the correct hostname.

Once the build finishes, note the AMI id. We will use it in the verification step. In the case of Gcp, you can set the image name in the environment file

Verification

You can use the ec2-test-centos.yml playbook to verify that the AMI we built works correctly. The playbook creates an EC2 instance using a specified AMI, waits for the instance to allow SSH, and then sets up KubeVirt with a storage class, CDI, PVC, and finally starts up a cirros VM and waits for it to be in "Running" state. The storage class, CDI, PVC, and VM definitions are from https://github.com/davidvossel/hostpath-pvc-vm-disks-examples/blob/master/README.md.

To run the playbook, first examine the environment file again and fill-in values for everything under "#Ansible ec2-test".

Then execute the playbook with your AWS private key.

ansible-playbook --private-key=<your-aws-private-key> ec2-test-centos.yml

You can inspect the EC2 instance and perform additional tests by logging in using

ssh -i <your-aws-private-key> centos@<ec2_instance_public_ip_or_dns_name>

kubevirt-cloud-image-builder's People

Contributors

karmab avatar rwsu avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.