When I began here at Anchore, I realized I would need to create a quick and offline way to be able to test installation in a way that would better approximate the most common way it is deployed—on Kubernetes.
We have guides to stand up anchore with docker-compose, and how to launch into Amazon EKS, but we didn’t have a quick way to test our helm chart, and other aspects of our application, locally on a laptop in a way that used K3s instead of minikube.
I also wanted to stand up a quick approximation not just on my local laptop, but against various other projects I have. So I created a K3s project base that automatically deploys K3s in vagrant and VirtualBox locally on my laptop. Also, if I need to stand up a Kubernetes cluster on external hosts to my laptop, I can run the playbook against those hosts to stand up a K3s cluster and deploy the anchore engine helm chart.
To get started, you can check out my project page on Github. It’s not a feature-complete project yet, but pull requests are always welcome.
Scenario 1: Standing this Up on your Local Laptop
Step 1: Install dependencies
To use this, just make sure you’ve met the requirements for your laptop, which is to say: make sure you have Ansible, Vagrant and VirtualBox installed. Clone the repo, change directories into that repo and issue the command “vagrant up”. There are more details on the readme file to help get you started.
First, you’ll need to be running a Linux or macOS laptop and have the following things installed:
- Virtualbox v5.2 or later
- Vagrant v2.0 or later
- The Vagrant Virtualbox Guest Additions Plugin
- Ansible v2.7 or later
- A copy of the project repository (git clone)
First, install Virtualbox per the link instructions above. Once that is in place, install Ansible and Vagrant per the links above also. To install the Vagrant VirtualBox Guest Additions Plugin, you issue the following command:
vagrant plugin install vagrant-vbguest
We are now ready to clone the repository and get this running. The following three commands will pull the repository and stand up the K3s cluster: git clone https://github.com/dfederlein/k3s_project_base.git cd k3s_project_base vagrant up
Scenario 2: Run this Playbook Against Hosts External to your Laptop
In this scenario, you have ansible installed on a control host, and you will be building a k3s cluster of hosts you already control. I will assume this scenario is utilized by people already familiar with Ansible and give some shortcut notes.
First, clone the repository with the following command: git clone https://github.com/dfederlein/k3s_project_base.git
Next, we’ll modify the hosts.ini file to reflect the hosts you want to create this cluster on. Once you’ve added those, the following command should get you what you need:
ansible-playbook -i hosts.ini site.yml -u (user)
Add the become password and connection password or private key flags to that command as needed. More information on how to do that in the Ansible documentation.
The end of the processes detailed above should have a working K3s cluster running on your laptop, or on the external hosts you’ve pointed the playbook at, and a helm chart of anchore deployed to that cluster. Please note that the Vagrant/local deploy scenario may need some patience after being created, as it will operate with limited ram and resources.