feat: debian12 + k8s1.26 + flannel + kctx

This commit is contained in:
AngeD 2023-07-13 19:05:51 +02:00
parent cb026997d6
commit 404a66b115
4 changed files with 60 additions and 13 deletions

1
get_kube_conf.sh Normal file
View File

@ -0,0 +1 @@
ssh debian@vps-sbg-10.maby.dev sudo cat /etc/kubernetes/admin.conf > f.conf

3
hosts
View File

@ -1 +1,2 @@
debian@37.187.67.96
debian@vps-sbg-10.maby.dev
debian@vps-gra-10.maby.dev

View File

@ -4,9 +4,13 @@
hosts: all
vars:
arch: "amd64"
os: "{{ ansible_distribution }}_{{ ansible_distribution_major_version }}"
k8s_version: "1.25"
arch: amd64
os: Debian_12
codename: bookworm
k8s_version: 1.26
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
tasks:
- name: Copy conf
@ -14,45 +18,70 @@
src: rootfs/
dest: /
- name: Add {{ codename }} repo
copy:
dest: /etc/apt/sources.list
content: |
deb http://deb.debian.org/debian {{ codename }} main
deb-src http://deb.debian.org/debian {{ codename }} main
deb http://deb.debian.org/debian-security/ {{ codename }}-security main
deb-src http://deb.debian.org/debian-security/ {{ codename }}-security main
deb http://deb.debian.org/debian {{ codename }}-updates main
deb-src http://deb.debian.org/debian {{ codename }}-updates main
deb http://deb.debian.org/debian {{ codename }}-backports main
deb-src http://deb.debian.org/debian {{ codename }}-backports main
- name: Upgrade
apt:
update_cache: true
cache_valid_time: 604800 # 60s * 60m * 24h * 7d
upgrade: full
upgrade: dist
autoremove: true
purge: true
- name: Reboot?
stat:
path: /var/run/reboot-required
register: doreboot
- name: Reboot
reboot:
when: doreboot.stat.exists
- name: Install deps
apt:
name:
- conntrack
- gpg
- kubectx
- vim
- name: Add libcontainers public key (CRI-O)
apt_key:
url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/Release.key"
keyring: /etc/apt/trusted.gpg.d/libcontainers-archive-keyring.gpg
keyring: /etc/apt/keyrings/libcontainers.gpg
- name: Add libcontainers-crio public key (CRI-O)
apt_key:
url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/Release.key"
keyring: /etc/apt/trusted.gpg.d/libcontainers-crio-archive-keyring.gpg
keyring: /etc/apt/keyrings/libcontainers-crio.gpg
- name: Add k8s public key
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
keyring: /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg
keyring: /etc/apt/keyrings/kubernetes.gpg
- name: Add libcontainers repo (CRI-O)
apt_repository:
repo: "deb [signed-by=/etc/apt/trusted.gpg.d/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/ /"
filename: devel:kubic:libcontainers:stable
repo: "deb [signed-by=/etc/apt/keyrings/libcontainers.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/ /"
filename: libcontainers
- name: Add libcontainers-crio repo (CRI-O)
apt_repository:
repo: "deb [signed-by=/etc/apt/trusted.gpg.d/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/ /"
filename: "devel:kubic:libcontainers:stable:cri-o:{{ k8s_version }}"
repo: "deb [signed-by=/etc/apt/keyrings/libcontainers-crio.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/ /"
filename: libcontainers-crio
- name: Add k8s repo
apt_repository:
repo: "deb [signed-by=/etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main"
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes.gpg] https://apt.kubernetes.io/ kubernetes-xenial main"
filename: kubernetes
- name: Install k8s
@ -64,6 +93,7 @@
- kubectl={{ k8s_version}}*
- kubelet={{ k8s_version}}*
update_cache: true
allow_change_held_packages: true
- name: Hold k8s pkg
shell: apt-mark hold cri-o cri-o-runc kubeadm kubectl kubelet
- name: Install crictl
@ -77,5 +107,16 @@
service:
name: crio.service
enabled: true
- name: Remove conflicting CRI-O network config
file:
path: /etc/cni/net.d/100-crio-bridge.conf
state: absent
- name: Reboot
reboot:
#- name: Init k8s
# shell: kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU
#- name: Apply flannel (network)
# shell: kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
#- name:
# shell: kubectl taint node --all node-role.kubernetes.io/control-plane:NoSchedule-

View File

@ -0,0 +1,4 @@
{
"name": "crio",
"type": "flannel"
}