fix: deployments errors

This commit is contained in:
AngeD 2023-06-06 10:48:45 +02:00
parent 11ed2bcab0
commit d4453e4dbb
5 changed files with 46 additions and 40 deletions

View File

@ -5,9 +5,8 @@
vars: vars:
arch: "amd64" arch: "amd64"
os: "Debian_11" os: "{{ ansible_distribution }}_{{ ansible_distribution_major_version }}"
k8s_version: "1.27" k8s_version: "1.25"
k_version: "{{ k8s_version }}.2"
tasks: tasks:
- name: Copy conf - name: Copy conf
@ -20,53 +19,67 @@
update_cache: true update_cache: true
cache_valid_time: 604800 # 60s * 60m * 24h * 7d cache_valid_time: 604800 # 60s * 60m * 24h * 7d
upgrade: full upgrade: full
autoremove: true
purge: true
- name: Install deps - name: Install deps
apt: apt:
name: name:
- conntrack
- gpg - gpg
- vim - vim
- name: Add libcontainers repo key (CRI-O) - name: Add libcontainers public key (CRI-O)
apt_key: apt_key:
url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/Release.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/trusted.gpg.d/libcontainers-archive-keyring.gpg
- name: Add libcontainers-crio repo key (CRI-O) - name: Add libcontainers-crio public key (CRI-O)
apt_key: apt_key:
url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/Release.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/trusted.gpg.d/libcontainers-crio-archive-keyring.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
- name: Add libcontainers repo (CRI-O) - name: Add libcontainers repo (CRI-O)
apt_repository: 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 }}/ /" 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.list filename: devel:kubic:libcontainers:stable
- name: Add libcontainers-crio repo (CRI-O) - name: Add libcontainers-crio repo (CRI-O)
apt_repository: 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 }}/ /" 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 }}.list" filename: "devel:kubic:libcontainers:stable:cri-o:{{ k8s_version }}"
- name: Install cri-o - 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"
filename: kubernetes
- name: Install k8s
apt: apt:
name: name:
- cri-o - cri-o
- cri-o-runc - cri-o-runc
- kubeadm={{ k8s_version}}*
- kubectl={{ k8s_version}}*
- kubelet={{ k8s_version}}*
update_cache: true update_cache: true
- name: Hold k8s pkg
shell: apt-mark hold cri-o cri-o-runc kubeadm kubectl kubelet
- name: Install crictl
unarchive:
remote_src: yes
src: "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{ k8s_version }}.0/crictl-v{{ k8s_version }}.0-linux-{{ arch }}.tar.gz"
dest: /usr/local/bin/
mode: 755
- name: Install kubectl - name: Enable crio service
get_url: service:
url: "https://dl.k8s.io/release/v{{ k_version }}/bin/linux/{{ arch }}/kubectl" name: crio.service
dest: /usr/local/bin/kubectl enabled: true
mode: 755 - name: Enable kubelet service
- name: Install kubeadm
get_url:
url: "https://dl.k8s.io/release/v{{ k_version}}/bin/linux/{{ arch }}/kubeadm"
dest: /usr/local/bin/kubeadm
mode: 755
- name: Install kubelet
get_url:
url: "https://dl.k8s.io/release/v{{ k_version }}/bin/linux/{{ arch }}/kubelet"
dest: /usr/local/bin/kubelet
mode: 755
- name: Start kubelet service
service: service:
name: kubelet.service name: kubelet.service
enabled: true enabled: true
state: started - name: Reboot
reboot:

View File

@ -0,0 +1,2 @@
overlay
br_netfilter

View File

@ -0,0 +1,3 @@
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1

View File

@ -1,14 +0,0 @@
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/home/
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/usr/local/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target

View File

@ -1,3 +1,4 @@
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service] [Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
@ -6,4 +7,5 @@ EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/default/kubelet EnvironmentFile=-/etc/default/kubelet
ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS