Bootstrap-Kubernetes-with-LXC
Bootstrap-Kubernetes-with-LXC copied to clipboard
Proxmox + LXC + Ansible + Debian = K8s
Bootstrap Kubernetes with LXC
WARNING: This project is no longer developed as I have moved to using QEMU instead. https://github.com/zimmertr/Bootstrap-Kubernetes-with-QEMU
Summary
Build a 4 node Kubernetes cluster on a Proxmox cluster using Ansible and LXC.
Approximate deployment time: 20 minutes.
WARNING: See problems section before using this repository.
Requirements
- Proxmox server
- DNS Server
- Ansible 2.7.0+. Known incompatibility with a previous build.
Instructions
- Modify the
vars.ymlfile with values specific to your environment. - Provision DNS A records for the IP Addresses & Hostnames you defined for your nodes in the
vars.ymlfile. - Modify the
inventory.inifile to reflect your chosen DNS records and the location of the SSH keys used to connect to the nodes. - Run the deployment:
ansible-playbook -e @vars.yml -i inventory.ini site.yml - After deployment, a
~/.kubedirectory will be created on your workstation. Within yourconfigand anauthentication_tokenfile can be be found. This token is used to authenticate against the Kubernetes API and Dashboard using your account. To connect to the dashboard, installkubectlon your workstation and runkubectl proxythen navigate to the Dashboard Endpoint in your browser.
Tips
- You can rollback the entire deployment with:
ansible-playbook -e @vars.yml -i inventory.ini delete_all_resources.yml - If your LXC instances fail to install
openssh-serverand throw a longyumrelated error, it's likely that they do not have a properly configured network. You can troubleshoot this by using thelxc-attachcommand to connect to them from Promxox without SSH. - See this repository to do this with QEMU instead. Benefits of using QEMU include:
* More security since the compute resources aren't sharing kernel space with your server.
* Not at the mercy of the Proxmox kernel for compatibility with necessary Kubernetes kernel modules.
TODO
- Add better support for multi-node Proxmox clusters.
- Add support for VLAN Tags & IDs.
- Perform security audit and enhance if necessary.
- Rewrite
deploy_lxc_containers.ymlto deploy one instance and clone rather than four separate instances to reduce duration.
Problems
- There is a bug in either the
4.15.18Linux kernel or in thebr_netfiltermodule. Preventing the LXC strategy from being a viable solution due to pod networking never being able to work. More information can be found here: https://github.com/lxc/lxd/issues/5193#issuecomment-431872713A A cluster can still be provisioned without pod networking, for what it is worth.
- The
k8smodule does not support applying Kubernetes Deployments from URL. Instead of usingget_urlto download them first, and then apply them withk8s, I just useshellto run akubectl apply -f. Feature Request here.