kubelet kubeadm kubectl install


 

.查看 Docker 使用的 cgroup driver:
root@ubuntu:/home/ubuntu# docker info | grep -i cgroup
 Cgroup Driver: cgroupfs
WARNING: No swap limit support
root@ubuntu:/home/ubuntu# 

 

 

 

 

root@ubuntu:/etc/apt# cat > /etc/sysctl.d/k8s.conf << EOF
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> EOF
root@ubuntu:/etc/apt# sysctl -p
root@ubuntu:/etc/apt# 

 

 

1. 关闭swap并关闭防火墙
首先,我们需要先关闭swap和防火墙,否则在安装Kubernetes时会导致不成功:

# 临时关闭
swapoff -a

# 编辑/etc/fstab,注释掉包含swap的那一行即可,重启后可永久关闭

ufw disable

 

阿里云

https://my.oschina.net/u/2306127/blog/3226348

https://www.cnblogs.com/g2thend/p/11616534.html

安装 kubeadm, kubelet and kubectl
# root(sudo -i)
apt-get update && apt-get install -y apt-transport-https
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl

 清华

https://mirrors.tuna.tsinghua.edu.cn/help/kubernetes/

 

 

装kubernetes的时候,需要安装kubelet, kubeadm等包,但k8s官网给的yum源是packages.cloud.google.com,国内访问不了,此时我们可以使用yum仓库镜像。

简单摸索了下,如下设置可用(centos)。注意不要开启check。

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.huaweicloud.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.huaweicloud.com/kubernetes/yum/doc/yum-key.gpg
        http://mirrors.huaweicloud.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
不过华为云跟kubernetes同步不太及时,例如现在是1.8.1了,但是华为云还是1.7.5。

如果你用的是ubuntu,也可以试试ustc的mirror,更新比较及时。

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list deb http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main
EOF

 参考 https://wiki.linuxchina.net/index.php/Install_and_Configure_Kubernetes_(k8s)_on_debian10

#国内版
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.huaweicloud.com/kubernetes/apt/ kubernetes-xenial main
EOF



apt  install gnupg  -y  
 curl -s https://mirrors.huaweicloud.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
#4、更新索引文件并安装kubernetes
sudo apt update
sudo apt install -y kubeadm kubelet kubectl 

 

 

root@ubuntu:/etc# kubelet --version
Kubernetes v1.18.5
root@ubuntu:/etc# 

 

 

root@ubuntu:/etc/apt# command -v kubeadm
/usr/bin/kubeadm
root@ubuntu:/etc/apt#

 

 

root@ubuntu:/etc/apt# kubeadm config images list
W1013 16:19:53.622125   27106 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
k8s.gcr.io/kube-apiserver:v1.19.2
k8s.gcr.io/kube-controller-manager:v1.19.2
k8s.gcr.io/kube-scheduler:v1.19.2
k8s.gcr.io/kube-proxy:v1.19.2
k8s.gcr.io/pause:3.2
k8s.gcr.io/etcd:3.4.13-0
k8s.gcr.io/coredns:1.7.0
root@ubuntu:/etc/apt# 

 

 

root@ubuntu:/etc/apt# kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.2", GitCommit:"f5743093fd1c663cb0cbc89748f730662345d44d", GitTreeState:"clean", BuildDate:"2020-09-16T13:41:02Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/arm64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
root@ubuntu:/etc/apt# netstat -lpn | grep 8080

 

 执行  kubeadm init

z

root@ubuntu:/etc/apt# kubeadm init
W1013 16:31:39.817318   30403 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[init] Using Kubernetes version: v1.19.2
[preflight] Running pre-flight checks
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR Swap]: running with swap on is not supported. Please disable swap
[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
root@ubuntu:/etc/apt#

 

 

root@ubuntu:/etc/apt# kubeadm init --cri-socket /run/containerd/containerd.sock --pod-network-cidr=10.244.0.0/16
W1013 16:54:51.338546   38143 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[init] Using Kubernetes version: v1.19.2
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR CRI]: container runtime is not running: output: time="2020-10-13T16:54:51+08:00" level=fatal msg="getting status of runtime failed: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
, error: exit status 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
root@ubuntu:/etc/apt#

 

Run mkdir -p /etc/containerd && containerd config default > /etc/containerd/config.toml and then restart containerd ( fyi, i just made this change in kind - https://github.com/kubernetes-sigs/kind/pull/425/files )

Then you can run the crictl like so (to test):
kubernetes-sigs/kind#425 (comment)

 

 

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

The kubelet is now restarting every few seconds, as it waits in a crashloop for kubeadm to tell it what to do.

Configure cgroup driver used by kubelet on control-plane node

When using Docker, kubeadm will automatically detect the cgroup driver for the kubelet and set it in the /var/lib/kubelet/config.yaml file during runtime.

If you are using a different CRI, you must pass your cgroupDriver value to kubeadm init, like so:

apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cgroupDriver: <value>

For further details, please read Using kubeadm init with a configuration file.

Please mind, that you only have to do that if the cgroup driver of your CRI is not cgroupfs, because that is the default value in the kubelet already.

Note: Since  --cgroup-driver flag has been deprecated by kubelet, if you have that in  /var/lib/kubelet/kubeadm-flags.env or  /etc/default/kubelet( /etc/sysconfig/kubelet for RPMs), please remove it and use the KubeletConfiguration instead (stored in  /var/lib/kubelet/config.yaml by default).

Restarting the kubelet is required:

systemctl daemon-reload
systemctl restart kubelet

The automatic detection of cgroup driver for other container runtimes like CRI-O and containerd is work in progress

3. 安装kubeadm、kubelet、kubectl

https://blog.csdn.net/liukuan73/article/details/83116271

 

root@ubuntu:/home/ubuntu# dpkg -l |  grep kube
hi  kubeadm                              1.14.2-00                              arm64        Kubernetes Cluster Bootstrapping Tool
hi  kubectl                              1.14.2-00                              arm64        Kubernetes Command Line Tool
hi  kubelet                              1.14.2-00                              arm64        Kubernetes Node Agent
ii  kubernetes-cni                       0.7.5-00                               arm64        Kubernetes CNI
root@ubuntu:/home/ubuntu#

 

 

root@ubuntu:/etc/apt# apt-get install -y kubelet=1.14.2-00 kubeadm=1.14.2-00 kubectl=1.14.2-00 -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 kubeadm : Depends: kubernetes-cni (= 0.7.5)
 kubelet : Depends: kubernetes-cni (= 0.7.5)
root@ubuntu:/etc/apt# apt-get install kubernetes-cni=0.7.5-00 ----最好是把旧的删除
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:

 

root@ubuntu:/etc/apt# apt-get install -y kubelet=1.14.2-00 kubeadm=1.14.2-00 kubectl=1.14.2-00 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  golang-1.10-go golang-1.10-src golang-src
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  kubeadm kubectl kubelet
0 upgraded, 3 newly installed, 0 to remove and 152 not upgraded.
Need to get 33.9 MB of archives.
After this operation, 201 MB of additional disk space will be used.
Get:1 https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main arm64 kubelet arm64 1.14.2-00 [19.1 MB]
Get:2 https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main arm64 kubectl arm64 1.14.2-00 [7,683 kB]
Get:3 https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main arm64 kubeadm arm64 1.14.2-00 [7,137 kB]
Fetched 33.9 MB in 3s (10.2 MB/s)
Selecting previously unselected package kubelet.
(Reading database ... 100325 files and directories currently installed.)
Preparing to unpack .../kubelet_1.14.2-00_arm64.deb ...
Unpacking kubelet (1.14.2-00) ...
Selecting previously unselected package kubectl.
Preparing to unpack .../kubectl_1.14.2-00_arm64.deb ...
Unpacking kubectl (1.14.2-00) ...
Selecting previously unselected package kubeadm.
Preparing to unpack .../kubeadm_1.14.2-00_arm64.deb ...
Unpacking kubeadm (1.14.2-00) ...
Setting up kubelet (1.14.2-00) ...
Created symlink /etc/systemd/system/multi-user.target.wants/kubelet.service → /lib/systemd/system/kubelet.service.
Setting up kubectl (1.14.2-00) ...
Setting up kubeadm (1.14.2-00) ...
root@ubuntu:/etc/apt# 

 

root@ubuntu:/etc/apt# apt-mark hold   kubelet=1.14.2-00 kubeadm=1.14.2-00 kubectl=1.14.2-00 
kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.
root@ubuntu:/etc/apt# systemctl enable kubelet && sudo systemctl start kubelet

 

 

 

#!/bin/bash
images=(kube-proxy:v1.14.2 kube-scheduler:v1.14.2 kube-controller-manager:v1.14.2 kube-apiserver:v1.14.2 etcd:3.2.24 pause:3.1 coredns:1.2.2)
for imageName in ${images[@]} ; do
          docker pull anjia0532/google-containers.$imageName
           docker tag anjia0532/google-containers.$imageName k8s.gcr.io/$imageName
           docker rmi anjia0532/google-containers.$imageName
 done

 

3.1 apt安装

3.1.1 创建kubernetes的repo

创建kubernetes的source文件:

sudo apt-get update && sudo apt-get install -y apt-transport-https curl

sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF'
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
EOF

sudo apt-get update

google地址被墙的情况下可以使用阿里云或者中科大的镜像站:

sudo apt-get update && sudo apt-get install -y apt-transport-https curl

sudo curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -

sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF'
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
EOF

sudo apt-get update

 

备注:

虽然我的ubuntu版本是18.04.1(bionic),但k8s的apt包目前还没支持到这么高,使用xenial。

3.1.2 安装kubeadm、kubelet、kubectl

1.查看可用软件版本:

$ apt-cache madison kubeadm
   kubeadm |  1.12.1-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages
   kubeadm |  1.12.0-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages
   kubeadm |  1.11.3-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages
   ......

2.安装指定版本:

$ sudo apt-get install -y kubelet=1.12.0-00 kubeadm=1.12.0-00 kubectl=1.12.0-00
$ sudo apt-mark hold kubelet=1.12.0-00 kubeadm=1.12.0-00 kubectl=1.12.0-00

3.设置开机自启动并运行kubelet:

sudo systemctl enable kubelet && sudo systemctl start kubelet
[kubelet-check] Initial timeout of 40s passed.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.

 

 

1.your configuration file uses an old API spec: "kubeadm.k8s.io/v1alpha2".

执行kubeadm init --config /etc/kubernetes/kubeadm-master.config --ignore-preflight-errors=all报错

apiVersion: kubeadm.k8s.io/v1alpha3
kind: MasterConfiguration

2.The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.

[root@localhost kubernetes]# vi /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --fail-swap-on=false"
[root@localhost kubernetes]# systemctl daemon-reload  
[root@localhost kubernetes]# systemctl restart kubelet

 

 

3./etc/kubernetes/manifests/kube-apiserver.yaml already exists

rm -rf /etc/kubernetes/manifests

 4.kubectl get pod状态为ErrImagePull && ImagePullBackOff  ErrImageNeverPull,请确保node上有相应的镜像,没有则在node机器上进行docker pull,且deployment中imagePullPolicy:IfNotPresent

/etc/kubernetes/manifests
root@ubuntu:/etc/kubernetes/manifests# ls
etcd.yaml            kube-controller-manager.yaml
kube-apiserver.yaml  kube-scheduler.yaml
root@ubuntu:/etc/kubernetes/manifests# cat kube-apiserver.yaml | grep ubuntu

 

 mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

 

 

root@ubuntu:~# /usr/bin/kubelet

I1013 21:50:18.614161   51136 server.go:417] Version: v1.14.2
I1013 21:50:18.614683   51136 plugins.go:103] No cloud provider specified.
W1013 21:50:18.614730   51136 server.go:556] standalone mode, no API client
W1013 21:50:18.907694   51136 server.go:474] No api server defined - no events will be sent to API server.
I1013 21:50:18.907732   51136 server.go:625] --cgroups-per-qos enabled, but --cgroup-root was not specified.  defaulting to /

 

 

 

安装基础组件

  1. 启用NET.BRIDGE.BRIDGE-NF-CALL-IPTABLES内核选项。

     

    sysctl -w net.bridge.bridge-nf-call-iptables=1

     

  2. 禁用交换分区。

     

    swapoff -a

    cp -p /etc/fstab /etc/fstab.bak$(date '+%Y%m%d%H%M%S')

    sed -i "s/\/dev\/mapper\/centos-swap/\#\/dev\/mapper\/centos-swap/g" /etc/fstab

     

  3. 安装K8s组件。

     

    yum install -y kubelet kubeadm kubectl kubernetes-cni

     

  4. 查看安装情况。

     

    rpm -qa | grep kubelet

    rpm -qa | grep kubeadm

    rpm -qa | grep kubectl

    rpm -qa | grep kubernetes-cni

     

  5. 设置iptables。

     

    echo "net.bridge.bridge-nf-call-iptables=1" > /etc/sysctl.d/k8s.conf

     

  6. 使能kubelet服务。

     

    systemctl enable kubelet

 

卸载K8s组件
注意:
下列步骤仅仅指导用户如何手动卸载K8s组件,请勿在正常的部署过程中执行。

清空K8s集群设置。
在卸载K8s组件前,先执行kubeadm reset命令,清空K8s集群设置。

卸载管理组件。
yum erase -y kubelet kubectl kubeadm kubernetes-cni

删除基础组件镜像。
基础组件通过Docker镜像部署,因此只需要强制删除对应镜像即可卸载。

docker rmi -f k8s.gcr.io/kube-apiserver:v1.15.1

docker rmi -f k8s.gcr.io/kube-controller-manager:v1.15.1

docker rmi -f k8s.gcr.io/kube-scheduler:v1.15.1

docker rmi -f k8s.gcr.io/kube-proxy:v1.15.1

docker rmi -f k8s.gcr.io/pause:3.1

docker rmi -f k8s.gcr.io/etcd:3.3.10

docker rmi -f k8s.gcr.io/coredns:1.3.1

 

 

root@ubuntu:/home/ubuntu# ps -elf | grep kube
0 S root      8550 28697  0  80   0 - 35475 futex_ 22:25 pts/4    00:00:00 kubeadm init --apiserver-advertise-address=10.10.16.82 --pod-network-cidr=172.16.0.0/16 --service-cidr=10.233.0.0/16 --kubernetes-version=v1.15.2
0 S root      9311  7563  0  80   0 -  1097 pipe_w 22:27 pts/5    00:00:00 grep --color=auto kube
root@ubuntu:/home/ubuntu#

 

kubeadm init 报错如下:

[kubelet-check] It seems like the kubelet isn't running or healthy.

[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10255/healthz' failed with error: Get http://localhost:10255/healthz: dial tcp 127.0.0.1:10255: getsockopt: connection refused.

解决办法:

Things were  solved by setting --fail-swap-on=false in the systemd script.

Just make the modification on the file /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --fail-swap-on=false"


安装成功后

 

root@ubuntu:~# ls /etc/kubernetes/
manifests
root@ubuntu:~# ls /etc/systemd/system/kubelet.service.d
10-kubeadm.conf
root@ubuntu:~# ls /etc/systemd/system/kubelet.service
ls: cannot access '/etc/systemd/system/kubelet.service': No such file or directory
root@ubuntu:~# ls /etc/systemd/system/kubelet.service

 

root@ubuntu:/home/ubuntu# cat  /etc/systemd/system/kubelet.service.d/10-kubeadm.conf 
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
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"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
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
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

 

 

kubeadm reset -f

rm -rf ~/.kube/
rm -rf /etc/kubernetes/
rm -rf /etc/systemd/system/kubelet.service.d
rm -rf /etc/systemd/system/kubelet.service

 

root@ubuntu:/home/ubuntu# ls /etc/systemd/system/kubelet.service.d/
10-kubeadm.conf
root@ubuntu:/home/ubuntu# kubectl get node
NAME     STATUS   ROLES    AGE    VERSION
ubuntu   Ready    master   8m1s   v1.18.1
root@ubuntu:/home/ubuntu# kubectl get pods
No resources found in default namespace.
 
root@ubuntu:/home/ubuntu# kubectl get pods --all-namespaces
NAMESPACE     NAME                             READY   STATUS    RESTARTS   AGE
kube-system   coredns-66bff467f8-bw6bv         1/1     Running   0          8m10s
kube-system   coredns-66bff467f8-tptcm         1/1     Running   0          8m10s
kube-system   etcd-ubuntu                      1/1     Running   0          8m20s
kube-system   kube-apiserver-ubuntu            1/1     Running   0          8m20s
kube-system   kube-controller-manager-ubuntu   1/1     Running   0          8m20s
kube-system   kube-flannel-ds-arm64-cn6gb      1/1     Running   0          2m49s
kube-system   kube-proxy-ffr44                 1/1     Running   0          8m10s
kube-system   kube-scheduler-ubuntu            1/1     Running   0          8m20s
root@ubuntu:/home/ubuntu#

总结:

 源

root@ubuntu:~# cat  /etc/apt/sources.list.d/kubernetes.list  
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
root@ubuntu:~#

 

 暂时不支持kata

 

 

kubeadm init --kubernetes-version=v1.18.1  --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.10.16.82  
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

 

加上

--image-repository registry.aliyuncs.com/google_containers有问题
kubeadm init --kubernetes-version=v1.18.1  --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.10.16.82  --image-repository registry.aliyuncs.com/google_containers

 

 

root@ubuntu:~# kubectl create -f kube-flannel.yml
podsecuritypolicy.policy/psp.flannel.unprivileged created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds-amd64 created
daemonset.apps/kube-flannel-ds-arm64 created
daemonset.apps/kube-flannel-ds-arm created
daemonset.apps/kube-flannel-ds-ppc64le created
daemonset.apps/kube-flannel-ds-s390x created
root@ubuntu:~# kubectl get pods --all-namespaces
NAMESPACE     NAME                             READY   STATUS    RESTARTS   AGE
kube-system   coredns-66bff467f8-dg454         1/1     Running   0          4m46s
kube-system   coredns-66bff467f8-mxrp4         1/1     Running   0          4m46s
kube-system   etcd-ubuntu                      1/1     Running   0          4m55s
kube-system   kube-apiserver-ubuntu            1/1     Running   0          4m55s
kube-system   kube-controller-manager-ubuntu   1/1     Running   0          4m55s
kube-system   kube-flannel-ds-arm64-mlw5f      1/1     Running   0 76s
kube-system   kube-proxy-ktzjc                 1/1     Running   0          4m46s
kube-system   kube-scheduler-ubuntu            1/1     Running   0          4m55s
root@ubuntu:~# 

 

root@ubuntu:~# kubectl  get cs
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok                  
controller-manager   Healthy   ok                  
etcd-0               Healthy   {"health":"true"}   
root@ubuntu:~# 

 

重置:

step1

systemctl stop kubelet
docker rm -f $(docker ps -aq)
kubeadm reset -f

rm -rf ~/.kube/
rm -rf /etc/kubernetes/
#rm -rf /etc/systemd/system/kubelet.service.d
#rm -rf /etc/systemd/system/kubelet.service

 

root@ubuntu:~# ip link del dev  flannel.1
root@ubuntu:~# ip link del dev  cni0

 

step2

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM