refactor: replace docker stack with k3s/containerd
This commit is contained in:
parent
7dd4c118c8
commit
2fccdd0283
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
- name: Deploy raspberry config
|
- name: Deploy raspberry config
|
||||||
template:
|
template:
|
||||||
src: config.txt
|
src: "{{ item }}"
|
||||||
dest: /boot/config.txt
|
dest: /boot/{{ item }}
|
||||||
|
with_items:
|
||||||
|
- cmdline.txt
|
||||||
|
- config.txt
|
||||||
notify: reboot
|
notify: reboot
|
||||||
|
|
||||||
- name: Set pi user in groups
|
- name: Set pi user in groups
|
||||||
|
1
ansible/roles/base/templates/cmdline.txt
Executable file
1
ansible/roles/base/templates/cmdline.txt
Executable file
@ -0,0 +1 @@
|
|||||||
|
console=serial0,115200 console=tty1 root=PARTUUID=424e930f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
|
3
ansible/roles/k3s/defaults/main.yml
Normal file
3
ansible/roles/k3s/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
k3s_version: v1.19.15%2Bk3s2
|
||||||
|
k3s_url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-{{ arch | default('armhf') }}
|
7
ansible/roles/k3s/handlers/main.yml
Normal file
7
ansible/roles/k3s/handlers/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: restart k3s
|
||||||
|
systemd:
|
||||||
|
name: k3s
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
state: restarted
|
18
ansible/roles/k3s/tasks/containerd.yml
Normal file
18
ansible/roles/k3s/tasks/containerd.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
- name: Add apt key
|
||||||
|
apt_key:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
|
||||||
|
- name: Add docker-ce repository
|
||||||
|
apt_repository:
|
||||||
|
repo: deb [arch={{ arch | default('armhf') }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
|
||||||
|
state: present
|
||||||
|
filename: 'docker'
|
||||||
|
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Install containerd.io
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- containerd.io
|
||||||
|
state: present
|
20
ansible/roles/k3s/tasks/k3s.yml
Normal file
20
ansible/roles/k3s/tasks/k3s.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
- name: Download k3s binary
|
||||||
|
get_url:
|
||||||
|
url: "{{ k3s_url}}"
|
||||||
|
dest: "/usr/local/bin/k3s"
|
||||||
|
mode: 0755
|
||||||
|
force: yes
|
||||||
|
|
||||||
|
- name: Copy systemd script
|
||||||
|
template:
|
||||||
|
src: k3s.service.j2
|
||||||
|
dest: /etc/systemd/system/k3s.service
|
||||||
|
notify: restart k3s
|
||||||
|
|
||||||
|
- name: Ensure k3s service is started
|
||||||
|
systemd:
|
||||||
|
name: k3s
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
state: started
|
3
ansible/roles/k3s/tasks/main.yaml
Normal file
3
ansible/roles/k3s/tasks/main.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- include_tasks: containerd.yml
|
||||||
|
- include_tasks: k3s.yml
|
29
ansible/roles/k3s/templates/k3s.service.j2
Normal file
29
ansible/roles/k3s/templates/k3s.service.j2
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Lightweight Kubernetes
|
||||||
|
Documentation=https://k3s.io
|
||||||
|
Wants=network-online.target,containerd
|
||||||
|
After=network-online.target,containerd
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
EnvironmentFile=-/etc/default/%N
|
||||||
|
EnvironmentFile=-/etc/sysconfig/%N
|
||||||
|
EnvironmentFile=-/etc/k3s/conf.env
|
||||||
|
KillMode=process
|
||||||
|
Delegate=yes
|
||||||
|
# Having non-zero Limit*s causes performance problems due to accounting overhead
|
||||||
|
# in the kernel. We recommend using cgroups to do container-local accounting.
|
||||||
|
LimitNOFILE=1048576
|
||||||
|
LimitNPROC=infinity
|
||||||
|
LimitCORE=infinity
|
||||||
|
TasksMax=infinity
|
||||||
|
TimeoutStartSec=0
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5s
|
||||||
|
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
|
||||||
|
ExecStartPre=-/sbin/modprobe br_netfilter
|
||||||
|
ExecStartPre=-/sbin/modprobe overlay
|
||||||
|
ExecStart=/usr/local/bin/k3s server
|
@ -9,7 +9,7 @@
|
|||||||
become: yes
|
become: yes
|
||||||
roles:
|
roles:
|
||||||
- { role: rabbitmq, tags: [rabbitmq] }
|
- { role: rabbitmq, tags: [rabbitmq] }
|
||||||
- { role: docker, tags: [docker] }
|
- { role: k3s, tags: [k3s] }
|
||||||
- { role: microservices, tags: [microservices, ms] }
|
- { role: microservices, tags: [microservices, ms] }
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user