|
| 1 | +# Flatcar Provisioning Automation for Brightbox |
| 2 | + |
| 3 | +This repository provides tools to automate Kubernetes provisioning on [Brightbox][brightbox] using [Terraform][terraform] and Flatcar via the Systemd sysext approach: https://www.flatcar.org/docs/latest/container-runtimes/getting-started-with-kubernetes/#deploy-a-kubernetes-cluster-with-flatcar |
| 4 | + |
| 5 | +:warning: This is really for demo purposes but it can serve as a foundation (for example do not pass the admin configuration through HTTP for workers to join) :warning: |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Minimal configuration required (demo deployment works with default settings w/o any customisation, just run `terraform apply`!). |
| 10 | +- Deploy one or multiple workers. |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +1. Brightbox credentials: `api_client`, `api_secret`. |
| 15 | +2. A public SSH key to install on the control plane |
| 16 | + |
| 17 | +## HowTo |
| 18 | + |
| 19 | +This will create a server in 'gb1-a' using a medium instance size for the control plane and small instance sizes for the three workers. |
| 20 | +See "Customisation" below for advanced settings. |
| 21 | + |
| 22 | +1. Clone the repo. |
| 23 | +2. Add credentials and a SSH key in a `terraform.tfvars` file, expected credentials name can be found in `provider.tf` |
| 24 | +3. Run |
| 25 | + ```shell |
| 26 | + terraform init |
| 27 | + ``` |
| 28 | +4. Plan and apply. |
| 29 | + Invoke Terraform: |
| 30 | + ```shell |
| 31 | + terraform plan |
| 32 | + terraform apply |
| 33 | + ``` |
| 34 | + |
| 35 | +Terraform will print the control plane information (ipv4) after deployment concluded. You can now easily fetch the kubernetes `admin` configuration via a secure channel: |
| 36 | + |
| 37 | +``` |
| 38 | +$ scp core@<IP from the output>:/home/core/.kube/config ~/.kube/config |
| 39 | +$ kubectl get nodes |
| 40 | +NAME STATUS ROLES AGE VERSION |
| 41 | +srv-cruzw.gb1.brightbox.com NotReady <none> 55s v1.29.2 |
| 42 | +srv-fltor.gb1.brightbox.com NotReady control-plane 72s v1.29.2 |
| 43 | +srv-gvzhx.gb1.brightbox.com NotReady <none> 59s v1.29.2 |
| 44 | +srv-mipnf.gb1.brightbox.com NotReady <none> 60s v1.29.2 |
| 45 | +``` |
| 46 | + |
| 47 | +From now, you can operate the Kubernetes cluster as usual (deploy CNI, deploy workloads, etc.) |
| 48 | + |
| 49 | +_NOTE_: |
| 50 | +* Server IP address can be found at any moment after deployment by running `terraform output` |
| 51 | +* If you update server configuration(s) in `server-configs` and re-run `terraform apply`, the instance will be **replaced**. |
| 52 | +Consider adding [`create_before_destroy`](https://www.terraform.io/docs/configuration/meta-arguments/lifecycle.html#syntax-and-arguments) to the `brightbox_server` resource in [`compute.tf`](compute.tf) to avoid services becoming unavailable during reprovisioning. |
| 53 | + |
| 54 | +### Customisation |
| 55 | + |
| 56 | +The provisioning automation can be customised via settings in `terraform.tfvars`: |
| 57 | + - `ssh_keys`: SSH public keys to add to core user's `authorized_keys` (needed for fetching the Kubernetes configuration) |
| 58 | + - `release_channel`: Select one of "lts", "stable", "beta", or "alpha". |
| 59 | + Read more about channels [here](https://www.flatcar.org/releases). |
| 60 | + - `flatcar_version`: Select the desired Flatcar version for the given channel (default to "current", which is the latest). |
| 61 | + - `zone`: Where to deploy servers |
| 62 | + - `control_plane_type`: Which instance type used for deploying the controle plane |
| 63 | + - `worker_type`: Which instance type used for deploying the workers |
| 64 | + - `kubernetes_version`: The Kubernetes version to deploy (NOTE: It has to be released on the Flatcar sysext bakery: https://github.com/flatcar/sysext-bakery/releases/tag/latest) |
| 65 | + - `workers`: How many workers to deploy |
| 66 | + |
| 67 | +[butane]: https://www.flatcar.org/docs/latest/provisioning/config-transpiler/configuration/ |
| 68 | +[brightbox]: https://www.brightbox.com/ |
| 69 | +[terraform]: https://www.terraform.io/ |
0 commit comments