kubeadm을 초기화할 수 없나요?

kubeadm을 초기화할 수 없나요?

kubeadm을 초기화하는 동안 오류가 발생했습니다.

$: -sudo kubeadm init

 [init] Using Kubernetes version: v1.25.0
[preflight] Running pre-flight checks
        [WARNING SystemVerification]: missing optional cgroups: blkio
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

내가 확인했다여기그리고여기단계를 따랐지만 해결할 수 없습니다.

해결하려면 FIRST:

sudo rm /etc/containerd/config.toml
sudo systemctl restart containerd
kubeadm init

두 번째: config.toml 파일을 편집하고 변경했습니다. systemd_cgroup = true

그런 다음 시도했습니다.

sudo kubeadm init --v=5



I0824 10:32:04.093515   27017 initconfiguration.go:116] detected and using CRI socket: unix:///var/run/containerd/containerd.sock
I0824 10:32:04.093872   27017 interface.go:432] Looking for default routes with IPv4 addresses
I0824 10:32:04.093890   27017 interface.go:437] Default route transits interface "eth0"
I0824 10:32:04.094018   27017 interface.go:209] Interface eth0 is up
I0824 10:32:04.094084   27017 interface.go:257] Interface "eth0" has 2 addresses :[172.31.37.138/20 fe80::69:d1ff:fea7:79ae/64].
I0824 10:32:04.094113   27017 interface.go:224] Checking addr  172.31.37.138/20.
I0824 10:32:04.094131   27017 interface.go:231] IP found 172.31.37.138
I0824 10:32:04.094147   27017 interface.go:263] Found valid IPv4 address 172.31.37.138 for interface "eth0".
I0824 10:32:04.094162   27017 interface.go:443] Found active IP 172.31.37.138
I0824 10:32:04.094197   27017 kubelet.go:196] the value of KubeletConfiguration.cgroupDriver is empty; setting it to "systemd"
I0824 10:32:04.098681   27017 version.go:187] fetching Kubernetes version from URL: https://dl.k8s.io/release/stable-1.txt
[init] Using Kubernetes version: v1.25.0
[preflight] Running pre-flight checks
I0824 10:32:04.770260   27017 checks.go:568] validating Kubernetes and kubeadm version
I0824 10:32:04.770328   27017 checks.go:168] validating if the firewall is enabled and active
I0824 10:32:04.779958   27017 checks.go:203] validating availability of port 6443
I0824 10:32:04.780157   27017 checks.go:203] validating availability of port 10259
I0824 10:32:04.780197   27017 checks.go:203] validating availability of port 10257
I0824 10:32:04.780232   27017 checks.go:280] validating the existence of file /etc/kubernetes/manifests/kube-apiserver.yaml
I0824 10:32:04.780251   27017 checks.go:280] validating the existence of file /etc/kubernetes/manifests/kube-controller-manager.yaml
I0824 10:32:04.780265   27017 checks.go:280] validating the existence of file /etc/kubernetes/manifests/kube-scheduler.yaml
I0824 10:32:04.780278   27017 checks.go:280] validating the existence of file /etc/kubernetes/manifests/etcd.yaml
I0824 10:32:04.780293   27017 checks.go:430] validating if the connectivity type is via proxy or direct
I0824 10:32:04.780317   27017 checks.go:469] validating http connectivity to first IP address in the CIDR
I0824 10:32:04.780341   27017 checks.go:469] validating http connectivity to first IP address in the CIDR
I0824 10:32:04.780353   27017 checks.go:104] validating the container runtime
I0824 10:32:04.794206   27017 checks.go:329] validating the contents of file /proc/sys/net/bridge/bridge-nf-call-iptables
I0824 10:32:04.794285   27017 checks.go:329] validating the contents of file /proc/sys/net/ipv4/ip_forward
I0824 10:32:04.794384   27017 checks.go:644] validating whether swap is enabled or not
I0824 10:32:04.794436   27017 checks.go:370] validating the presence of executable crictl
I0824 10:32:04.794466   27017 checks.go:370] validating the presence of executable conntrack
I0824 10:32:04.794486   27017 checks.go:370] validating the presence of executable ip
I0824 10:32:04.794506   27017 checks.go:370] validating the presence of executable iptables
I0824 10:32:04.794530   27017 checks.go:370] validating the presence of executable mount
I0824 10:32:04.794552   27017 checks.go:370] validating the presence of executable nsenter
I0824 10:32:04.794571   27017 checks.go:370] validating the presence of executable ebtables
I0824 10:32:04.794591   27017 checks.go:370] validating the presence of executable ethtool
I0824 10:32:04.794608   27017 checks.go:370] validating the presence of executable socat
I0824 10:32:04.794629   27017 checks.go:370] validating the presence of executable tc
I0824 10:32:04.794646   27017 checks.go:370] validating the presence of executable touch
I0824 10:32:04.794666   27017 checks.go:516] running all checks
        [WARNING SystemVerification]: missing optional cgroups: blkio
I0824 10:32:04.808265   27017 checks.go:401] checking whether the given node name is valid and reachable using net.LookupHost
I0824 10:32:04.808291   27017 checks.go:610] validating kubelet version
I0824 10:32:04.871023   27017 checks.go:130] validating if the "kubelet" service is enabled and active
I0824 10:32:04.906852   27017 checks.go:203] validating availability of port 10250
I0824 10:32:04.907135   27017 checks.go:203] validating availability of port 2379
I0824 10:32:04.907346   27017 checks.go:203] validating availability of port 2380
I0824 10:32:04.907542   27017 checks.go:243] validating the existence and emptiness of directory /var/lib/etcd
[preflight] Some fatal errors occurred:
        [ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
error execution phase preflight
k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow.(*Runner).Run.func1
        cmd/kubeadm/app/cmd/phases/workflow/runner.go:235
k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow.(*Runner).visitAll
        cmd/kubeadm/app/cmd/phases/workflow/runner.go:421
k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow.(*Runner).Run
        cmd/kubeadm/app/cmd/phases/workflow/runner.go:207
k8s.io/kubernetes/cmd/kubeadm/app/cmd.newCmdInit.func1
        cmd/kubeadm/app/cmd/init.go:154
github.com/spf13/cobra.(*Command).execute
        vendor/github.com/spf13/cobra/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
        vendor/github.com/spf13/cobra/command.go:974
github.com/spf13/cobra.(*Command).Execute
        vendor/github.com/spf13/cobra/command.go:902
k8s.io/kubernetes/cmd/kubeadm/app.Run
        cmd/kubeadm/app/kubeadm.go:50
main.main
        cmd/kubeadm/kubeadm.go:25
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1594

오류 메시지 받기:

service kubelet status



kubelet.service - kubelet: The Kubernetes Node Agent
     Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/kubelet.service.d
             └─10-kubeadm.conf
     Active: activating (auto-restart) (Result: exit-code) since Wed 2022-08-24 14:56:42 UTC; 6s ago
       Docs: https://kubernetes.io/docs/home/
    Process: 2561 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE)
   Main PID: 2561 (code=exited, status=1/FAILURE)

답변1

Kubernetes가 IPv4 전달을 수행할 수 있는지 확인해야 합니다. 이는 을 사용 iptables하고 를 사용하지 않는다고 가정합니다 ipvs. 다음 스크립트를 실행하여 브리지를 추가합니다(IPv4, IPv6 및 IP 전달용).

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

또한 다음과 같이 스왑을 끄고 오버레이 네트워크와 브리지 넷필터를 켜도록 합니다.

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# immediately turn off swap - until reboot
sudo swapoff -a
# turn off swap after restart
sudo sed -i 's|^/swap.img|#/swap.img|g' /etc/fstab

# reboot sysctl
sudo sysctl --system

답변2

# nano /etc/containerd/config.toml 열기

댓글 달기 #disabled_plugins = ["cri"]

그런 다음 sudo systemctl restart Containerd를 수행하십시오.

그런 다음 kubeadm init를 실행하십시오.

관련 정보