参考网址 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/-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: --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





Mac OS用vmvare安装多节点kubernetes的更多相关文章

  1. Mac OS用minikube安装单节点kubernetes

    参考 https://kubernetes.io/docs/tasks/tools/install-minikube/ https://github.com/linianhui/code/blob/m ...

  2. 在Mac OS环境下安装MySQL服务

    在Mac OS环境下安装MySQL服务 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 我之前介绍过window环境下安装mysql服务,以及在Linux环境下安装mysql服务,今 ...

  3. Mac OS X 上安装 ASP.NET 5

    在Mac OS X Yosemite 10.10.3 中搭建第一个 ASP.NET 5 Web 项目 终于有时间在 Mac 上安装一下 ASP.NET 5,网上有许多教程,但是多数的时间比较早了,版本 ...

  4. 虚拟机安装Mac OS X ----- VM12安装Mac OS X

    Windows下虚拟机安装Mac OS X -– VM12安装Mac OS X 10.11 随着Iphone在国内大行其道,越来越多的开发者涌入iOS开发大军 中,但都苦于没有苹果机,本文即将介绍WI ...

  5. Windows下虚拟机安装Mac OS X ----- VM12安装Mac OS X 10.11

    Windows下虚拟机安装Mac OS X -– VM12安装Mac OS X 10.11 随着Iphone在国内大行其道,越来越多的开发者涌入iOS开发大军 中,但都苦于没有苹果机,本文即将介绍WI ...

  6. Mac OS X Server 安装与应用

    Mac OS X Server 安装与应用 Mac OS X Server是苹果电脑公司新一代服务器软件.专为OS X和iOS设备.Mac OS X提供服务,现在支持Mavericks,能够轻松共享文 ...

  7. 在Mac OS X下安装Android Studio

    在Mac OS X下安装Android Studio只需要几步. 1. 下载Android Studio安装包(.dmg). 2. 打开Terminal输入java -version命令查看是否已安装 ...

  8. [Sqlite] --> Sqlite于Windows、Linux 和 Mac OS X 在安装过程

    一个:于 Windows 安装 SQLite  1,下载 请訪问SQLite下载页面http://www.sqlite.org/download.html.从Windows 区下载预编译的二进制文件. ...

  9. Linux必备 -- 如何在Mac OS 使用VMware 安装Linux

    Linux简介 Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户.多任务.支持多线程和多CPU的操作系统.它能运行主要的UNIX工具软件.应用程序和网络协 ...

随机推荐

  1. oracle表空间,分区表,以及索引的总结

    表空间: Oracle的UNDOTBS01.DBF文件太大的解决办法 1..禁止undo tablespace自动增长 alter   database   datafile   'full_path ...

  2. 13-数组的API方法遍历

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  3. BZOJ 3270 博物馆 ——概率DP 高斯消元

    用$F(i,j)$表示A在i,B在j的概率. 然后很容易列出转移方程. 然后可以高斯消元了! 被一个问题困扰了很久,为什么起始点的概率要加上1. (因为其他博客上都是直接写成-1,雾) 考虑初始状态是 ...

  4. OpenJ_Bailian3375

    Farmer John has decided to reward his cows for their hard work by taking them on a tour of the big c ...

  5. cf575A Fibonotci

    Fibonotci sequence is an integer recursive sequence defined by the recurrence relation Fn = sn - 1·F ...

  6. Python入门--5--列表

    python没有数组 蛋是有列表 列表里面可以有:整数,浮点数,字符串,对象 没有数组,没有数组,没有数组,不重要的也说三遍!! 一.创建列表 x = ['abc','sas','www']     ...

  7. NSArray,NSMutableArray的一些常用方法

    不可变数组 ——NSArray 常用的初始化一个数组:       NSArray *array1 = [[NSArray alloc] init];       NSArray *array2 = ...

  8. Activity 切换动画

    1,在AndroidManifest.xml中的Activity的声明上加入android:theme="@style/Anim_fade" <activity androi ...

  9. 初学Android,BroadcastReceiver之发送接收广播

    BroadcastReceiver用于监听系统全局广播消息,由于BroadcastReceiver是一种全局的监听器,因此它可以非常方便地实现系统中不同组件之间通信 启动它需要两步 1.创建需要启动的 ...

  10. jqeury设置元素屏幕居中

    jQuery.fn.center = function () { this.css(“position”,”absolute”); this.css(“top”, ( $(window).height ...