zoukankan      html  css  js  c++  java
  • Mac OS用vmvare安装多节点kubernetes

    参考网址 https://kubernetes.io/docs/setup/

    1、安装vmvare

    2、下载ubuntu镜像(可以不要界面,可以下载server版大约900M,否则下载desktop版大约1.9G),我下载的是18.04.2版本,

    因为server版配置静态ip没找到文件,所以换成了desktop版本。

    3、安装第一个ubuntu系统,起名叫master,设置静态ip172.16.151.145,过程如下:

    重新安装vim解决不识别上下按键的问题:

     ubuntu预装的是vim tiny版本,而需要的是vim full版本。执行下面的语句安装vim full版本:

      $sudo apt-get remove vim-common

      $sudo apt-get install vim

    设置主机名master(修改名字后要重启才能生效)

    vi /etc/hostname

    设置root用户:

    sudo passwd root

    设置root自动登陆

    sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
    
    内容替换如下:
    
    autologin-user=root
    
    user-session=ubuntu
    
    greeter-show-manual-login=true
    
    
    
    sudo gedit /root/.profile
    
    将mesg n替换成tty -s && mesg n
    
    重启ubuntu后以root自动登陆

     

    设置静态ip:

    vmvare的网络设置为nat模式

    修改/etc/network/interfaces,如果是desktop版,可以通过网络设置界面修改。修改完后需要重启网络链接。

    开启ssh服务:

    sudo apt-get install openssh-server

    打开密码登陆:登录目标机器 修改 /etc/ssh/sshd_config文件中 PermitRootLogin without-password 改为 PermitRootLogin yes 

    确认sshserver是否启动了:ps -ef |grep ssh

     

     

    3、安装docker和k8s (使用李念辉写的脚本)

    git clone https://github.com/linianhui/code.git

    安装docker使用

    https://github.com/linianhui/code/blob/master/docker/docker-in-ubuntu.md

    安装k8s使用

    https://github.com/linianhui/code/blob/master/shell/ubuntu.k8s.0.pre-setting.sh

    https://github.com/linianhui/code/blob/master/shell/ubuntu.k8s.1.kubeadm.install.sh

    https://github.com/linianhui/code/blob/master/shell/ubuntu.k8s.2.kubeadm.pull-images.sh

    4、关闭虚拟机,复制虚拟机文件,重新生成mac地址,设置名字为node1,设置静态ip172.16.151.147,

    5、启动master虚拟机,初始化master节点,

    执行 

    kubeadm init --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.9.10.154 --node-name=master

     输出如下:

    Your Kubernetes control-plane has initialized successfully!
    
    To start using your cluster, you need to run the following as a regular user:
    
      mkdir -p $HOME/.kube
    
      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    
      sudo chown $(id -u):$(id -g) $HOME/.kube/config
    You should now deploy a pod network to the cluster. Run
    "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/

    Then you can join any number of worker nodes by running the following on each as root: kubeadm join 172.16.151.146:6443 --token bggbum.mj3ogzhnm1wz07mj --discovery-token-ca-cert-hash sha256:8f02f83357a965b5db5c5c70bc1dec4c57d507ebae8c50b0d2efef4c32f5d106

    先在master里执行下面语句,如果是root用户,可执行(export KUBECONFIG=/etc/kubernetes/kubelet.conf),如果是其他用户,执行下面语句

    mkdir -p $HOME/.kube

      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

      sudo chown $(id -u):$(id -g) $HOME/.kube/config

     执行:

    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/62e44c867a2846fefb68bd5f178daf4da3095ccb/Documentation/kube-flannel.yml

    多节点安装遇到了权限的错误,暂时放弃。

    Error from server (Forbidden): namespaces is forbidden: User "system:node:master" cannot list resource "namespaces" in API group "" at the cluster scope

    再用上面的语句在node1里执行,把node1加入master

    详情可参考 https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

     

    过程种遇到的问题:

    1、找不到端口列表,需要把https://github.com/linianhui/code/blob/master/shell/ubuntu.k8s.0.pre-setting.sh再执行一遍

    2、运行kubectl get services报509错误,需要执行一下 export KUBECONFIG=/etc/kubernetes/kubelet.conf

  • 相关阅读:
    C#获取当前路径
    惠普辞退4000员工,今后如何走
    提升你的编码技能,你不知道的免费在线编码资源(上)
    iPhone 5在美销量有望破5000万,Facebook手机何去何从?
    Python获取命令行参数
    C#递归获取文件目录
    Pixel’d:共创美好的像素艺术
    PayPal走向现实支付,消费者们会来买帐吗?
    兼容性测试、手工测试、自动化测试及探索性测试
    冒烟测试 smoking test
  • 原文地址:https://www.cnblogs.com/lakeslove/p/10894382.html
Copyright © 2011-2022 走看看