This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the kvm-libvirt platform to lokoctl
The KVM libvirt Terraform module was not yet available from lokoctl despite it being an easy way to try out Lokomotive without any cloud provider accounts (and their attached costs). It allows to use Lokomotive on any Flatcar Container Linux image, even local development builds. It also gives direct access to the VGA console for debugging. The cluster VMs can be shut down in virt-manager while they are not needed.
- Loading branch information
Showing
13 changed files
with
851 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cluster "kvm-libvirt" { | ||
asset_dir = pathexpand("~/lokoctl-assets") | ||
ssh_pubkeys = [file(pathexpand("~/.ssh/id_rsa.pub"))] | ||
cluster_name = "vmcluster" | ||
machine_domain = "vmcluster.k8s" | ||
os_image_unpacked = "file:///var/tmp/flatcar_production_qemu_image.img" | ||
|
||
worker_pool "one" { | ||
count = 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Lokomotive KVM libvirt configuration reference | ||
|
||
## Contents | ||
|
||
* [Introduction](#introduction) | ||
* [Prerequisites](#prerequisites) | ||
* [Configuration](#configuration) | ||
* [Attribute reference](#attribute-reference) | ||
* [Applying](#applying) | ||
* [Destroying](#destroying) | ||
|
||
## Introduction | ||
|
||
This configuration reference provides information on configuring a Lokomotive cluster on KVM libvirt VMs | ||
with all the configuration options available to the user. | ||
|
||
## Prerequisites | ||
|
||
* Terraform providers and libvirt setup from the [quickstart guide](../../quickstarts/kvm-libvirt.md) | ||
* `lokoctl` [installed locally.](../../installer/lokoctl.md) | ||
* `kubectl` installed locally to access the Kubernetes cluster. | ||
|
||
### Configuration | ||
|
||
To create a Lokomotive cluster, we need to define a configuration. | ||
|
||
Example configuration file: | ||
|
||
```tf | ||
cluster "kvm-libvirt" { | ||
asset_dir = pathexpand("./assets") | ||
cluster_name = "vmcluster" | ||
machine_domain = "vmcluster.k8s" | ||
os_image_unpacked = "file:///home/myuser/Downloads/flatcar_production_qemu_image.img" | ||
ssh_pubkeys = [file(pathexpand("~/.ssh/id_rsa.pub"))] | ||
controller_count = 1 | ||
node_ip_pool = "192.168.192.0/24" | ||
disable_self_hosted_kubelet = false | ||
kube_apiserver_extra_flags = [] | ||
controller_virtual_cpus = 1 | ||
controller_virtual_memory = 2048 | ||
controller_clc_snippets = [] | ||
network_mtu = 1480 | ||
network_ip_autodetection_method = "first-found" | ||
pod_cidr = "10.1.0.0/16" | ||
service_cidr = "10.2.0.0/16" | ||
cluster_domain_suffix = "cluster.local" | ||
enable_reporting = false | ||
enable_aggregation = true | ||
certs_validity_period_hours = 8760 | ||
worker_pool "worker-pool-1" { | ||
count = 2 | ||
virtual_cpus = 1 | ||
virtual_memory = 2048 | ||
labels = "foo=oof,bar=,baz=zab" | ||
clc_snippets = [ | ||
<<EOF | ||
systemd: | ||
units: | ||
- name: helloworld.service | ||
dropins: | ||
- name: 10-helloworld.conf | ||
contents: | | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
, | ||
] | ||
} | ||
} | ||
``` | ||
|
||
|
||
## Attribute reference | ||
|
||
| Argument | Description | Default | Type | Required | | ||
|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------:|:------------:|:--------:| | ||
| `asset_dir` | Location where Lokomotive stores cluster assets. | - | string | true | | ||
| `certs_validity_period_hours` | Validity of all the certificates in hours. | 8760 | number | false | | ||
| `cluster_domain_suffix` | Cluster's DNS domain. | "cluster.local" | string | false | | ||
| `cluster_name` | Name of the cluster. | - | string | true | | ||
| `controller_clc_snippets` | Controller Flatcar Container Linux Config snippets. | [] | list(string) | false | | ||
| `controller_count` | Number of controller nodes. | 1 | number | false | | ||
| `controller_virtual_cpus` | Number of virtual CPUs for the controller VMs. | 1 | int | false | | ||
| `controller_virtual_memory` | Virtual RAM in MB for the controller VMs. | 2048 | int | false | | ||
| `disable_self_hosted_kubelet` | Disable self-hosting the kubelet as pod on the cluster. | false | bool | false | | ||
| `enable_aggregation` | Enable the Kubernetes Aggregation Layer. | true | bool | false | | ||
| `enable_reporting` | Enables usage or analytics reporting to upstream. | false | bool | false | | ||
| `kube_apiserver_extra_flags` | Extra flags to pass to the kube-apiserver binary. | [] | list(string) | false | | ||
| `machine_domain` | DNS zone. | - | string | true | | ||
| `network_mtu` | CNI interface MTU | 1480 | number | false | | ||
| `node_ip_pool` | Unique VM IP CIDR. | "192.168.192.0/24" | string | false | | ||
| `os_image_unpacked` | Path to unpacked Flatcar Container Linux image flatcar_production_qemu_image.img (probably after a qemu-img resize IMG +5G). | - | string | true | | ||
| `pod_cidr` | CIDR IPv4 range to assign Kubernetes pods. | "10.2.0.0/16" | string | false | | ||
| `service_cidr` | CIDR IPv4 range to assign Kubernetes services. | "10.3.0.0/16" | string | false | | ||
| `ssh_pubkeys` | List of SSH public keys for user `core`. Each element must be specified in a valid OpenSSH public key format, as defined in RFC 4253 Section 6.6, e.g. "ssh-rsa AAAAB3N...". | - | list(string) | true | | ||
| `worker_pool.clc_snippets` | Flatcar Container Linux Config snippets for nodes in the worker pool. | [] | list(string) | false | | ||
| `worker_pool` | Configuration block for worker pools. There can be more than one. | - | list(object) | true | | ||
| `worker_pool.count` | Number of workers in the worker pool. Can be changed afterwards to add or delete workers. | 1 | number | true | | ||
| `worker_pool.labels` | Custom labels to assign to worker nodes. | - | string | false | | ||
| `worker_pool.virtual_cpus` | List of tags that will be propagated to nodes in the worker pool. | - | map(string) | false | | ||
| `worker_pool.virtual_memory` | Disable BGP on nodes. Nodes won't be able to connect to Packet BGP peers. | false | bool | false | | ||
|
||
|
||
## Applying | ||
|
||
To create the cluster, execute the following command: | ||
|
||
```console | ||
lokoctl cluster apply | ||
``` | ||
|
||
## Destroying | ||
|
||
To destroy the Lokomotive cluster, execute the following command: | ||
|
||
```console | ||
lokoctl cluster destroy --confirm | ||
``` | ||
|
Oops, something went wrong.