李明
|
Tectonic
PS:遗憾的是:Tectonic已经sandbox下架了,我在网上找了一份直接传到github了,自己下载吧。直接通过vagantfile的方式搭建。
vagrant up
shell vagrant的方式安装k8s集群
Vagrant.configure(2) do |config| # 设置dev虚机环境(下面还要写dev.vm,好扯淡) config.vm.define "dev" do |dev| # 设置虚拟机的Box dev.vm.box = "centos7" # 设置虚拟机的主机名 dev.vm.hostname = "dev" # 设置虚拟机的IP dev.vm.network "private_network", ip: "192.168.0.2" # VirtaulBox相关配置 dev.vm.provider "virtualbox" do |vb| # 设置虚拟机的内存大小 vb.memory = 512 # 设置虚拟机的CPU个数 vb.cpus = 1 end # 挂载失败了,mount: unknown filesystem type 'vboxsf' # config.vm.synced_folder ".", "/home/vagrant/deployk8s" # 使用默认挂载 # 使用shell脚本进行软件安装和配置 dev.vm.provision "shell", path: "dev.sh" end # ssh配置 config.ssh.username = "vagrant" config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" config.ssh.insert_key = false end
# vagrant box add centos7 path_to_your_centos7 # 例如: vagrant box add centos7 centos7.box
vagrant up dev
cd vagrant-cluster vagrant up master1 vagrant up master2 vagrant up master3 vagrant up node1 vagrant up node2 vagrant up node3 # 可以直接vagrant up来启动所有机器
vagrant ssh dev #这一步的目的是把压缩包直接放在vagrant共享目录下解压, #结果在最后报软连接错误,直接放入虚拟机的自身目录就不会爆这个错误这个很重要 cp -r deployk8s-master deployk8s cd deployk8s
scp -i ~/.vagrant.d/insecure_private_key \ ~/.vagrant.d/insecure_private_key \ vagrant@192.168.0.2:~/.ssh/id_rsa #这个id_rsa的权限是644,需要改为600,在dev机中执行: chmod 600 ~/.ssh/id_rsa
vagrant ssh dev #这一步的目的是把压缩包直接放在vagrant共享目录下解压, #结果在最后报软连接错误,直接放入虚拟机的自身目录就不会爆这个错误这个很重要 cp -r deployk8s-master deployk8s cd deployk8s
# 下载cfssl curl -O https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 curl -O https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 curl -O https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 # 下载keepalived v2.0.6 curl -O http://www.keepalived.org/software/keepalived-2.0.6.tar.gz # 下载etcd v3.3.8 curl -O https://github.com/coreos/etcd/releases/download/v3.3.8/etcd-v3.3.8-linux-amd64.tar.gz # 下载flannel v0.10.0 curl -O https://github.com/coreos/flannel/releases/download/v0.10.0/flannel-v0.10.0-linux-amd64.tar.gz # 下载kubernetes v1.11.0 curl -O https://dl.k8s.io/v1.11.0/kubernetes-server-linux-amd64.tar.gz 最后就开始执行脚本进行部署吧。
./deployk8s.sh 2>&1 | tee deployk8s.log
https://vagrantcloud.com/centos/boxes/7/versions/1804.02/providers/virtualbox.box https://dl.k8s.io/v1.11.0/kubernetes-server-linux-amd64.tar.gz https://github.com/coreos/etcd/releases/download/v3.3.8/etcd-v3.3.8-linux-amd64.tar.gz https://github.com/coreos/flannel/releases/download/v0.10.0/flannel-v0.10.0-linux-amd64.tar.gz https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 http://www.keepalived.org/software/keepalived-2.0.6.tar.gz https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 #下载后还放到No.10的deployk8s-master下就可以了。
PS:这种方式感觉很受用,感谢 xujintao 的技术指导和他的github的思路引导成功部署的 https://github.com/xujintao/deployk8s的一键部署! |
2018-10-19 07:47:51