From 404a66b11504c8e7251920b42b74ff67b844b286 Mon Sep 17 00:00:00 2001 From: AngeD Date: Thu, 13 Jul 2023 19:05:51 +0200 Subject: [PATCH] feat: debian12 + k8s1.26 + flannel + kctx --- get_kube_conf.sh | 1 + hosts | 3 +- playbook.yaml | 65 +++++++++++++++++++++++++------ rootfs/etc/cni/net.d/10-crio.conf | 4 ++ 4 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 get_kube_conf.sh create mode 100644 rootfs/etc/cni/net.d/10-crio.conf diff --git a/get_kube_conf.sh b/get_kube_conf.sh new file mode 100644 index 0000000..5417ef0 --- /dev/null +++ b/get_kube_conf.sh @@ -0,0 +1 @@ +ssh debian@vps-sbg-10.maby.dev sudo cat /etc/kubernetes/admin.conf > f.conf diff --git a/hosts b/hosts index dac5e83..2bcc045 100644 --- a/hosts +++ b/hosts @@ -1 +1,2 @@ -debian@37.187.67.96 +debian@vps-sbg-10.maby.dev +debian@vps-gra-10.maby.dev diff --git a/playbook.yaml b/playbook.yaml index 68486b6..0829ff2 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -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- diff --git a/rootfs/etc/cni/net.d/10-crio.conf b/rootfs/etc/cni/net.d/10-crio.conf new file mode 100644 index 0000000..8c0c866 --- /dev/null +++ b/rootfs/etc/cni/net.d/10-crio.conf @@ -0,0 +1,4 @@ +{ + "name": "crio", + "type": "flannel" +}