diff options
author | David Runge <dave@sleepmap.de> | 2020-12-16 21:24:26 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2020-12-16 21:24:26 +0100 |
commit | 0543e3011817211445da32afe1eaa60ded44c673 (patch) | |
tree | 1ff4a268a70f0474a827b28ebbfe1de037138a97 /k8s_cluster/templates | |
download | terraform-master.tar.gz terraform-master.tar.bz2 terraform-master.tar.xz terraform-master.zip |
k8s_cluster/*:
Add a terraform-provider-libvirt based examples to semi-automatically
create a k8s cluster for testing.
Diffstat (limited to 'k8s_cluster/templates')
-rw-r--r-- | k8s_cluster/templates/cloud_init.cfg.tpl | 56 | ||||
-rw-r--r-- | k8s_cluster/templates/cloud_init_load_balancer.cfg.tpl | 62 |
2 files changed, 118 insertions, 0 deletions
diff --git a/k8s_cluster/templates/cloud_init.cfg.tpl b/k8s_cluster/templates/cloud_init.cfg.tpl new file mode 100644 index 0000000..6299f40 --- /dev/null +++ b/k8s_cluster/templates/cloud_init.cfg.tpl @@ -0,0 +1,56 @@ +#cloud-config + +users: + - name: arch + groups: + - wheel + - users + lock_passwd: false + passwd: $6$KHqF91TQzQNJECRV$/zMRa92BqMB5juUpKfIHbOpOdUPyNlLJTpymplTOP.uqoonD/AZzNRnA/XACZTuqyxAktuohSjXhyfskbRjbO1 + ssh_authorized_keys: + - ${ssh_public_key} + sudo: ALL=(ALL) NOPASSWD:ALL +packages: + - bash-completion + - cri-o + - kubeadm + - kubectl + - kubelet + - man + - man-pages + - qemu-guest-agent + - ripgrep + - tmux + - tree + - vim +write_files: + - content: | + 10.10.66.50 k8s + 10.10.66.100 worker0 + 10.10.66.101 worker1 + 10.10.66.200 controller0 + 10.10.66.201 controller1 + path: /etc/hosts + append: true + - content: | + # added by cloud-init + [crio] + storage_driver = "btrfs" + path: /etc/crio/crio.conf.d/10-btrfs.conf + - content: | + # added by cloud-init + [crio.network] + plugin_dirs = ["/usr/lib/cni/", "/opt/cni/"] + path: /etc/crio/crio.conf.d/10-cni_plugins.conf +runcmd: + - [ systemctl, mask, swap-swapfile.swap ] + - [ swapoff, -a ] + - [ rm, -rfv, /var/lib/containers ] + - [ btrfs, subvolume, create, /var/lib/kubelet ] + - [ btrfs, subvolume, create, /var/lib/containers/ ] + - [ sed, -e, '$a/dev/vda2 /var/lib/kubelet btrfs rw,relatime,compress=zstd:3,space_cache,ssd,subvol=var/lib/kubelet 0 0', -i, /etc/fstab] + - [ sed, -e, '$a/dev/vda2 /var/lib/containers btrfs rw,relatime,compress=zstd:3,space_cache,ssd,subvol=var/lib/containers 0 0', -i, /etc/fstab] + - [ mount, -a ] + - [ modprobe, overlay ] + - [ modprobe, br_netfilter] + - [ systemctl, enable, --now, qemu-guest-agent, crio, kubelet ] diff --git a/k8s_cluster/templates/cloud_init_load_balancer.cfg.tpl b/k8s_cluster/templates/cloud_init_load_balancer.cfg.tpl new file mode 100644 index 0000000..4d8ebae --- /dev/null +++ b/k8s_cluster/templates/cloud_init_load_balancer.cfg.tpl @@ -0,0 +1,62 @@ +#cloud-config + +users: + - name: arch + groups: + - wheel + - users + lock_passwd: false + passwd: $6$KHqF91TQzQNJECRV$/zMRa92BqMB5juUpKfIHbOpOdUPyNlLJTpymplTOP.uqoonD/AZzNRnA/XACZTuqyxAktuohSjXhyfskbRjbO1 + ssh_authorized_keys: + - ${ssh_public_key} + sudo: ALL=(ALL) NOPASSWD:ALL +packages: + - bash-completion + - man + - man-pages + - nginx + - qemu-guest-agent + - ripgrep + - tmux + - tree + - vim +write_files: + - content: | + 10.10.66.50 k8s + 10.10.66.100 worker0 + 10.10.66.101 worker1 + 10.10.66.200 controller0 + 10.10.66.201 controller1 + path: /etc/hosts + append: true + - content: | + worker_processes auto; + error_log /var/log/nginx/error.log; + events { + worker_connections 1024; + } + http { + include mime.types; + resolver 127.0.0.1 [::1]; + default_type application/octet-stream; + sendfile on; + types_hash_max_size 4096; + keepalive_requests 55; + keepalive_timeout 55; + } + include conf.d/k8s_load_balancer.conf; + path: /etc/nginx/nginx.conf + - content: | + stream { + upstream k8s_apiserver { + server controller0:6443; + server controller1:6443; + } + server { + listen 6443; + proxy_pass k8s_apiserver; + } + } + path: /etc/nginx/conf.d/k8s_load_balancer.conf +runcmd: + - [ systemctl, enable, --now, qemu-guest-agent, nginx ] |