如何将树莓派作为k8s的node部署laravel

背景

有一台服务器

已安装

  • k8s master
  • openxxx server

在家里有一台树莓派
已安装

  • k8s client
  • openxxx client

想实现的功能

想把树莓派设为k8s 的一个子节点,现在已经将树莓派通过openvpn加入到master中

root@iZbp12672j5u4tyarzzjk2Z:~# kubectl get nodes -o wide
NAME          STATUS   ROLES                  AGE    VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION     CONTAINER-RUNTIME
node          Ready    control-plane,master   12m    v1.22.4   172.16.171.223   <none>        Ubuntu 20.04.2 LTS               5.4.0-90-generic   docker://20.10.11
raspberrypi   Ready    <none>                 9m9s   v1.22.4   10.8.0.5         <none>        Raspbian GNU/Linux 10 (buster)   5.10.63-v7l+       docker://18.9.1

STATUS 已经是ready状态,说明树莓派节点加入成功

遇到的问题

发布一个pod,在maste节点可以正常工作。

假如master不作为子节点,只有树莓派作为子节点。pod创建不成功,查看报错信息

root@iZbp12672j5u4tyarzzjk2Z:~# kubectl describe pod flaskapp-1-56894f6895-2dn4q
Name:           flaskapp-1-56894f6895-2dn4q
Namespace:      default
Priority:       0
Node:           raspberrypi/10.8.0.5
Start Time:     Fri, 26 Nov 2021 17:56:11 +0800
Labels:         name=flaskapp-1
                pod-template-hash=56894f6895
Annotations:    <none>
Status:         Pending
IP:
IPs:            <none>
Controlled By:  ReplicaSet/flaskapp-1-56894f6895
Containers:
  flaskapp-1:
    Container ID:
    Image:          jcdemo/flaskapp
    Image ID:
    Port:           5000/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-8t6bs (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-api-access-8t6bs:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason                  Age                 From               Message
  ----     ------                  ----                ----               -------
  Warning  FailedScheduling        15m (x2 over 16m)   default-scheduler  0/1 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate.
  Normal   Scheduled               14m                 default-scheduler  Successfully assigned default/flaskapp-1-56894f6895-2dn4q to raspberrypi
  Warning  FailedCreatePodSandBox  13m                 kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "cf294e1199710e29ec3e5aac138d619bfde0427759cbc09c24cf0201d0a94709" network for pod "flaskapp-1-56894f6895-2dn4q": networkPlugin cni failed to set up pod "flaskapp-1-56894f6895-2dn4q_default" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": dial tcp 10.96.0.1:443: i/o timeout, failed to clean up sandbox container "cf294e1199710e29ec3e5aac138d619bfde0427759cbc09c24cf0201d0a94709" network for pod "flaskapp-1-56894f6895-2dn4q": networkPlugin cni failed to teardown pod "flaskapp-1-56894f6895-2dn4q_default" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": dial tcp 10.96.0.1:443: i/o timeout]
  Normal   SandboxChanged          49s (x26 over 13m)  kubelet            Pod sandbox changed, it will be killed and re-created.

主要信息

Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "cf294e1199710e29ec3e5aac138d619bfde0427759cbc09c24cf0201d0a94709" network for pod "flaskapp-1-56894f6895-2dn4q": networkPlugin cni failed to set up pod "flaskapp-1-56894f6895-2dn4q_default" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": dial tcp 10.96.0.1:443: i/o timeout, failed to clean up sandbox container "cf294e1199710e29ec3e5aac138d619bfde0427759cbc09c24cf0201d0a94709" network for pod "flaskapp-1-56894f6895-2dn4q": networkPlugin cni failed to teardown pod "flaskapp-1-56894f6895-2dn4q_default" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": dial tcp 10.96.0.1:443: i/o timeout

很可能是k8s 和本地的网络不通

但不知道该往哪个方向排查或者这一方案是否可行?

Make everything simple instead of making difficulties as simple as possible
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 1

看节点列表,两个内网ip都不是同一个网段的,可能是这里有问题

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!