美文网首页
安装Minikube

安装Minikube

作者: hongdada | 来源:发表于2018-09-30 11:23 被阅读0次

    在容器编排工具中安装配置最复杂的就是Kubernetes,想要运行一个简单的容器集群环境,对于没有使用过Kubernetes的人来说,需要花费一定的时间去理解各组件的概念和功能,再做大量的安装配置工作才能运行一个kubernetes集群。

    从Kubernetes 1.3开始提供了一个叫Minikube的强大测试工具,可以在任意主机上运行单节点的小型集群,这个工具默认安装和配置了一个Linux VM,Docker和Kubernetes的相关组件,并且提供Dashboard。目前支持在Linux, OS X及Windows上安装,今天我们介绍的是在OS X上如何安装Minitube。

    Minitube项目地址:https://github.com/kubernetes/minikube

    Kubectl安装

    如果可以访问外网:

    curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
    

    或者指定版本:

    curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.2/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
    

    更好的方法是指定yum源:

    国外:
    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    EOF
    yum install -y kubectl
    
    国内阿里:
    cat >> /etc/yum.repos.d/kubernetes.repo <<EOF
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=0
    EOF
    
    查看kubectl版本:
    [root@localhost /]# kubectl version
    Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
    The connection to the server localhost:8080 was refused - did you specify the right host or port?
    

    minikube安装

    [hongdada@localhost /]$ sudo curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v0.24.1/minikube-linux-amd64 && chattr -ai minikube && chmod +x minikube && sudo mv minikube /usr/local/bin/
    [hongdada@localhost bin]$ minikube version
    minikube version: v0.24.1
    

    好吧,用hongdada账户操作遇到的权限问题太多,我下面切换到root账户

    启动

    默认启动使用的是 VirtualBox 驱动,使用 --vm-driver 参数可以指定其它驱动。
    minikube start --registry-mirror=https://registry.docker-cn.com  --vm-driver=none
    

    安装中遇到的问题:

    错误信息:

        [ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables 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=...`
    : running command: sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-kube-dns-amd64:1.14.8 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-kube-dns-amd64:1.14.8 k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.8 && sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1 && sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.8 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.8 k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.8 && sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.8 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.8 k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.8 && 
    sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data-minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI  &&
    sudo /usr/bin/kubeadm alpha phase addon kube-dns
    

    解决方法:

    https://blog.csdn.net/xypds2010/article/details/52212323

    在CentOS中
    vim /etc/sysctl.conf
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    net.bridge.bridge-nf-call-arptables = 1

    重启。

    启动:

    Unfortunately, an error has occurred:
        timed out waiting for the condition
    
    This error is likely caused by:
        - The kubelet is not running
        - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
        - Either there is no internet connection, or imagePullPolicy is set to "Never",
          so the kubelet cannot pull or find the following control plane images:
            - registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64:v1.10.0
            - registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64:v1.10.0
            - registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64:v1.10.0
            - registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64:3.1.12 (only if no external etcd endpoints are configured)
    
    If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
        - 'systemctl status kubelet'
        - 'journalctl -xeu kubelet'
    couldn't initialize a Kubernetes cluster
    : running command: sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-kube-dns-amd64:1.14.8 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-kube-dns-amd64:1.14.8 k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.8 && sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1 && sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.8 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.8 k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.8 && sudo docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.8 && sudo docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.8 k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.8 && 
    sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data-minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI  &&
    sudo /usr/bin/kubeadm alpha phase addon kube-dns 
    

    还是有问题,明显是docker镜像没有拉下来

    解决方法:

    好吧,我还是搞定不了,妈蛋的,一堆坑。

    使用kubectl低版本1.5.2,可以安装,但是dashboard还是有问题,估计都是镜像拉取问题。

    操作:

    [root@localhost hongdada]# minikube status
    minikube: Running
    cluster: Running
    kubectl: Correctly Configured: pointing to minikube-vm at 18.16.202.33
    [root@localhost hongdada]# minikube dashboard
    Could not find finalized endpoint being pointed to by kubernetes-dashboard: Error validating service: Error getting service kubernetes-dashboard: services "kubernetes-dashboard" not found
    

    结果只实现了部分,应该是没有虚拟机的原因。

    参考:
    https://ehlxr.me/2018/01/12/kubernetes-minikube-installation/
    https://www.hi-linux.com/posts/14955.html
    https://yq.aliyun.com/articles/221687
    https://blog.csdn.net/huwh_/article/details/81506240
    https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl
    http://www.mdslq.cn/archives/5e6f338.html
    https://zxc0328.github.io/2017/10/26/k8s-setup-1-7/
    https://gitee.com/Rachird/kubernetes

    相关文章

      网友评论

          本文标题:安装Minikube

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