美文网首页k8s那点事儿
Microk8s采坑记录

Microk8s采坑记录

作者: cjp1016 | 来源:发表于2019-04-17 22:39 被阅读0次

    Microk8s采坑记录

    In order to install MicroK8s make sure

    • port 8080 is not used and
    • if you have AppArmor enabled (check with sudo apparmor_status) you do not have any other dockerd installed. You can use the dockerd coming with MicroK8s.

    micork8s单机版

    建议采用1.13版本

    #安装最新版
    snap install microk8s --classic
    
    # 安装指定版本
    snap install microk8s --classic --channel=1.13/stable
    
    # 查看状态
    microk8s.status
    
    # 查看k8s服务
    microk8s.kubectl get nodes
    microk8s.kubectl get services
    # 别名依赖
    snap alias microk8s.kubectl kubectl
    snap unalias kubectl
    
    # k8s Addons
    microk8s.enable dns dashboard
    microk8s.disable dashboard dns
    
    # 停止和开启
    microk8s.stop
    microk8s.start
    
    # 移除microk8s
    microk8s.reset
    snap remove microk8s
    

    containerd 容器服务

    systemctl stop containerd 
    systemctl start containerd
    

    问题采坑解决方案

    1. kubectl get componentstatus解决方案
    > microk8s.kubectl get componentstatuses                                                          
    NAME                 STATUS      MESSAGE                                                                                           ERROR      
    etcd-0               Unhealthy   Get http://etcd.socket:2379/health: dial tcp: lookup etcd.socket on 127.0.0.53:53: no such host              
    controller-manager   Healthy     ok                                                                                                           
    scheduler            Healthy     ok         
    

    修改文件:

    # Update /var/snap/microk8s/current/args/etcd with:
    --advertise-client-urls=http://localhost:2379
    --listen-client-urls=http://localhost:2379
    
    # Update /var/snap/microk8s/current/args/kube-apiserver with:
    --etcd-servers='http://localhost:2379'
    
    # 重启服务,就好了
    sudo systemctl restart snap.microk8s.daemon-etcd
    sudo systemctl restart snap.microk8s.daemon-apiserver.service
    
    1. docker disappeared,v1.14.0 版本不存在
      microk8s.docker 命令不存在
    root@kube:~# microk8s.docker
    microk8s.docker: command not found
    root@kube:~# ls /snap/bin/  
    microk8s.config  microk8s.ctr  microk8s.disable  microk8s.enable  microk8s.inspect  microk8s.istioctl  microk8s.kubectl  microk8s.reset  microk8s.start  microk8s.status  microk8s.stop
    root@kube:~# cat /etc/issue
    Ubuntu 18.04.2 LTS \n \l
    
    

    原因是1.14版本移除了,可以采用1.13版本k8s

    Hi,

    Indeed in the 1.14 release contanerd replaced dockerd. We gave the heads up on this change in the on this topic https://discuss.kubernetes.io/t/containerd-and-security-updates-on-the-next-microk8s-release/4844and on the #microk8s channel at https://k8s.slack.com/ some time ago. For those who cannot do the transition dockerd is available from the 1.13 channel:

    # 切换1.13版本
    snap install microk8s --classic --channel=1.13/stable
    
    1. kubectl get pods --namespace kube-system 服务 ContainerCreating
    root@cjp-ubuntu-master:~# kubectl get pods --namespace kube-system
    NAME                                              READY   STATUS              RESTARTS   AGE
    heapster-v1.5.2-5c5498f57c-m4llc                  0/4     ContainerCreating   0          28h
    kube-dns-6bfbdd666c-bkqcf                         0/3     ContainerCreating   0          28h
    kubernetes-dashboard-6fd7f9c494-wt875             0/1     ContainerCreating   0          28h
    monitoring-influxdb-grafana-v4-78777c64c8-49dgf   0/2     ContainerCreating   0          28h
    

    排查运用命令:

    # 排查没有启动的原因
    kubectl describe pod heapster-v1.5.2-5c5498f57c-m4llc  --namespace kube-system
    

    原因是采用了contained,无法下载image镜像

    root@cjp-ubuntu-master:~# kubectl describe pod  heapster-v1.5.2-5c5498f57c-m4llc  --namespace kube-system
    Name:               heapster-v1.5.2-5c5498f57c-m4llc
    Namespace:          kube-system
    Priority:           2000000000
    PriorityClassName:  system-cluster-critical
    Node:               cjp-ubuntu-master/192.168.18.28
    Start Time:         Tue, 16 Apr 2019 17:58:47 +0800
    Labels:             k8s-app=heapster
                        pod-template-hash=5c5498f57c
                        version=v1.5.2
    Annotations:        scheduler.alpha.kubernetes.io/critical-pod: 
    Status:             Pending
    IP:                 
    Controlled By:      ReplicaSet/heapster-v1.5.2-5c5498f57c
    Containers:
      heapster:
        Container ID:  
        Image:         k8s.gcr.io/heapster-amd64:v1.5.2
        Image ID:      
        Port:          <none>
        Host Port:     <none>
        Command:
          /heapster
          --source=kubernetes.summary_api:''
          --sink=influxdb:http://monitoring-influxdb:8086
        State:          Waiting
          Reason:       ContainerCreating
        Ready:          False
        Restart Count:  0
        Liveness:       http-get http://:8082/healthz delay=180s timeout=5s period=10s #success=1 #failure=3
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from heapster-token-qjmwr (ro)
      eventer:
        Container ID:  
        Image:         k8s.gcr.io/heapster-amd64:v1.5.2
        Image ID:      
        Port:          <none>
        Host Port:     <none>
        Command:
          /eventer
          --source=kubernetes:''
          --sink=influxdb:http://monitoring-influxdb:8086
        State:          Waiting
          Reason:       ContainerCreating
        Ready:          False
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from heapster-token-qjmwr (ro)
      heapster-nanny:
        Container ID:  
        Image:         cdkbot/addon-resizer-amd64:1.8.1
        Image ID:      
        Port:          <none>
        Host Port:     <none>
        Command:
          /pod_nanny
          --config-dir=/etc/config
          --cpu=80m
          --extra-cpu=0.5m
          --memory=140Mi
          --extra-memory=4Mi
          --threshold=5
          --deployment=heapster-v1.5.2
          --container=heapster
          --poll-period=300000
          --estimator=exponential
        State:          Waiting
          Reason:       ContainerCreating
        Ready:          False
        Restart Count:  0
        Limits:
          cpu:     50m
          memory:  92360Ki
        Requests:
          cpu:     50m
          memory:  92360Ki
        Environment:
          MY_POD_NAME:       heapster-v1.5.2-5c5498f57c-m4llc (v1:metadata.name)
          MY_POD_NAMESPACE:  kube-system (v1:metadata.namespace)
        Mounts:
          /etc/config from heapster-config-volume (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from heapster-token-qjmwr (ro)
      eventer-nanny:
        Container ID:  
        Image:         cdkbot/addon-resizer-amd64:1.8.1
        Image ID:      
        Port:          <none>
        Host Port:     <none>
        Command:
          /pod_nanny
          --config-dir=/etc/config
          --cpu=100m
          --extra-cpu=0m
          --memory=190Mi
          --extra-memory=500Ki
          --threshold=5
          --deployment=heapster-v1.5.2
          --container=eventer
          --poll-period=300000
          --estimator=exponential
        State:          Waiting
          Reason:       ContainerCreating
        Ready:          False
        Restart Count:  0
        Limits:
          cpu:     50m
          memory:  92360Ki
        Requests:
          cpu:     50m
          memory:  92360Ki
        Environment:
          MY_POD_NAME:       heapster-v1.5.2-5c5498f57c-m4llc (v1:metadata.name)
          MY_POD_NAMESPACE:  kube-system (v1:metadata.namespace)
        Mounts:
          /etc/config from eventer-config-volume (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from heapster-token-qjmwr (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             False 
      ContainersReady   False 
      PodScheduled      True 
    Volumes:
      heapster-config-volume:
        Type:      ConfigMap (a volume populated by a ConfigMap)
        Name:      heapster-config
        Optional:  false
      eventer-config-volume:
        Type:      ConfigMap (a volume populated by a ConfigMap)
        Name:      eventer-config
        Optional:  false
      heapster-token-qjmwr:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  heapster-token-qjmwr
        Optional:    false
    QoS Class:       Burstable
    Node-Selectors:  <none>
    Tolerations:     CriticalAddonsOnly
                     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type     Reason                  Age                   From                        Message
      ----     ------                  ----                  ----                        -------
      Warning  FailedCreatePodSandBox  69m (x23 over 84m)    kubelet, cjp-ubuntu-master  Failed create pod sandbox: rpc error: code = Unknown desc = failed to get sandbox image "k8s.gcr.io/pause:3.1": failed to pull image "k8s.gcr.io/pause:3.1": failed to resolve image "k8s.gcr.io/pause:3.1": no available registry endpoint: failed to do request: Head https://k8s.gcr.io/v2/pause/manifests/3.1: dial tcp 74.125.203.82:443: i/o timeout
      Warning  FailedCreatePodSandBox  9m12s (x83 over 68m)  kubelet, cjp-ubuntu-master  Failed create pod sandbox: rpc error: code = Unknown desc = failed to get sandbox image "k8s.gcr.io/pause:3.1": failed to pull image "k8s.gcr.io/pause:3.1": failed to resolve image "k8s.gcr.io/pause:3.1": no available registry endpoint: failed to do request: Head https://k8s.gcr.io/v2/pause/manifests/3.1: dial tcp 108.177.125.82:443: i/o timeout
      Warning  FailedCreatePodSandBox  14s (x5 over 3m1s)    kubelet, cjp-ubuntu-master  Failed create pod sandbox: rpc error: code = Unknown desc = failed to get sandbox image "k8s.gcr.io/pause:3.1": failed to pull image "k8s.gcr.io/pause:3.1": failed to resolve image "k8s.gcr.io/pause:3.1": no available registry endpoint: failed to do request: Head https://k8s.gcr.io/v2/pause/manifests/3.1: dial tcp 108.177.125.82:443: i/o timeout
    

    参考网址
    Kubernetes 单机实验环境搭建 - microk8s
    docker系列5:k8s单机版[ microk8s ]

    相关文章

      网友评论

        本文标题:Microk8s采坑记录

        本文链接:https://www.haomeiwen.com/subject/izzowqtx.html