内容来源:https://study.163.com/course/courseMain.htm?courseId=1209568805
安装所需资源
软路由:https://pan.baidu.com/s/1On6h4IReUdzn6kOXImQHJg 提取码:vkcu
kubernetes资源:https://pan.baidu.com/s/1r0zQxn58c4XxI8s0Qv8w7g 提取码:l4xf
安装教程汪洋老师讲的都比较详细,安装文档上面资源文档中也有,此处就不写了。
安装虚拟机的时候 CPU 最好设置 大于等于 4核 内存如果不够设置小点应该也是没影响的,我这边设置的是2G
遇到的问题
由于无法 kexue上网(翻墙),在最后一步部署网络的时候会无法下载 flannel-v0.12.0-amd64 docker镜像 会出现以下问题:
[root@k8s-master01 flannel]# 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@k8s-master01 flannel]# [root@k8s-master01 flannel]# [root@k8s-master01 flannel]# kubectl get pod -n kube-system NAME READY STATUS RESTARTS AGE coredns-5c98db65d4-2hfsb 0/1 Pending 0 3h42m coredns-5c98db65d4-xwpht 0/1 Pending 0 3h42m etcd-k8s-master01 1/1 Running 0 3h42m kube-apiserver-k8s-master01 1/1 Running 0 3h42m kube-controller-manager-k8s-master01 1/1 Running 0 3h41m kube-flannel-ds-amd64-7bcll 0/1 Init:0/1 0 10s kube-proxy-dd9pl 1/1 Running 0 3h42m kube-scheduler-k8s-master01 1/1 Running 0 3h41m
使用命令 kubectl describe pod kube-flannel-ds-amd64-7bcll -n kube-system 查看问题描述:
[root@k8s-master01 flannel]# kubectl describe pod kube-flannel-ds-amd64-7bcll -n kube-system Name: kube-flannel-ds-amd64-7bcll Namespace: kube-system Priority: 0 Node: k8s-master01/192.168.66.10 Start Time: Fri, 27 Mar 2020 00:31:28 +0800 Labels: app=flannel controller-revision-hash=6855c75b9 pod-template-generation=1 tier=node Annotations: <none> Status: Pending IP: 192.168.66.10 Controlled By: DaemonSet/kube-flannel-ds-amd64 Init Containers: install-cni: Container ID: Image: quay.io/coreos/flannel:v0.12.0-amd64 Image ID: Port: <none> Host Port: <none> Command: cp Args: -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conflist State: Waiting Reason: PodInitializing Ready: False Restart Count: 0 Environment: <none> Mounts: /etc/cni/net.d from cni (rw) /etc/kube-flannel/ from flannel-cfg (rw) /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-rztlx (ro) Containers: kube-flannel: Container ID: Image: quay.io/coreos/flannel:v0.12.0-amd64 Image ID: Port: <none> Host Port: <none> Command: /opt/bin/flanneld Args: --ip-masq --kube-subnet-mgr State: Waiting Reason: PodInitializing Ready: False Restart Count: 0 Limits: cpu: 100m memory: 50Mi Requests: cpu: 100m memory: 50Mi Environment: POD_NAME: kube-flannel-ds-amd64-7bcll (v1:metadata.name) POD_NAMESPACE: kube-system (v1:metadata.namespace) Mounts: /etc/kube-flannel/ from flannel-cfg (rw) /run/flannel from run (rw) /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-rztlx (ro) Conditions: Type Status Initialized False Ready False ContainersReady False PodScheduled True Volumes: run: Type: HostPath (bare host directory volume) Path: /run/flannel HostPathType: cni: Type: HostPath (bare host directory volume) Path: /etc/cni/net.d HostPathType: flannel-cfg: Type: ConfigMap (a volume populated by a ConfigMap) Name: kube-flannel-cfg Optional: false flannel-token-rztlx: Type: Secret (a volume populated by a Secret) SecretName: flannel-token-rztlx Optional: false QoS Class: Guaranteed Node-Selectors: <none> Tolerations: :NoSchedule node.kubernetes.io/disk-pressure:NoSchedule node.kubernetes.io/memory-pressure:NoSchedule node.kubernetes.io/network-unavailable:NoSchedule node.kubernetes.io/not-ready:NoExecute node.kubernetes.io/pid-pressure:NoSchedule node.kubernetes.io/unreachable:NoExecute node.kubernetes.io/unschedulable:NoSchedule Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 51s default-scheduler Successfully assigned kube-system/kube-flannel-ds-amd64-7bcll to k8s-master01 Normal Pulling 50s kubelet, k8s-master01 Pulling image "quay.io/coreos/flannel:v0.12.0-amd64"
解决办法
由于我无法 kexue上网(翻墙),于是通过公司公网服务先将此镜像拉取下来,然后再导出来,最后再将导出的镜像导入到自己的内网服务中
#拉取镜像 docker pull quay.io/coreos/flannel:v0.12.0-amd64 #导出镜像 docker image save -o flannel-v0.12.0-amd64.tar quay.io/coreos/flannel:v0.12.0-amd64 #将导出的镜像下载,然后上传到自己的内网服务 .... #将镜像导入到docker docker load -i flannel-v0.12.0-amd64.tar
如果没有公网服务上面资源包中也提供了次镜像,名为:flannel-v0.12.0-amd64.tar
以上执行完成之后 删除先前创建的 kube-flannel 然后从新创建就好了
#查看没有运行成功的 kube-flannel-ds-amd64-7bcll 是否存在 kubectl get pod -n kube-system #删除 kube-flannel-ds-amd64-7bcll kubectl delete -f kube-flannel.yml #重新创建 kube-flannel-ds-amd64-7bcll kubectl create -f kube-flannel.yml #再次执行 kubectl get pod -n kube-system #查看 node 状态 kubectl get node
如果初始化的时候默认加载的内核不是4.4可以查看一下教程:
https://www.cnblogs.com/Wolf-Dreams/p/10947799.html
来源:https://www.cnblogs.com/gyli20170901/p/12576511.html