【Linux】【Services】【SaaS】kubernetes及其生态圈(马哥版)(1. kubeadm安装kubernetes)

1. 简介

2. 环境

2.1. OS:  CentOS Linux release 7.5.1804 (Core)

2.2. Ansible: 2.6.2-1.el7

2.3. docker:

2.4. kubernetes:

2.5. 

3. 准备

3.1. ansible,节点太多了,安装一个ansible统一执行命令吧

yum -y install ansible

  

看一下配置文件

扫描二维码关注公众号,回复: 2891437 查看本文章
~]# cat /etc/ansible/hosts
[all]
service ansible_host=10.210.55.220 hostname=centos-0
master1 ansible_host=10.210.55.221  hostname=centos-master-1
master2 ansible_host=10.210.55.222  hostname=centos-master-2
master3 ansible_host=10.210.55.223  hostname=centos-master-3
node1 ansible_host=10.210.55.226  hostname=centos-node-1
node2 ansible_host=10.210.55.227  hostname=centos-node-2
node3 ansible_host=10.210.55.228  hostname=centos-node-3
node4 ansible_host=10.210.55.229  hostname=centos-node-4

[master]
master1
master2
master3

[etcd]
master1
master2
master3

[worker]
node1
node2
node3
node4

  

看一下hosts文件

~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.210.55.220   centos-0
10.210.55.220   centos-0  centos-0.eric.com
10.210.55.221   centos-master-1  centos-master-1.eric.com
10.210.55.222   centos-master-2  centos-master-2.eric.com
10.210.55.223   centos-master-3  centos-master-3.eric.com
10.210.55.226   centos-node-1  centos-node-1.eric.com
10.210.55.227   centos-node-2  centos-node-2.eric.com
10.210.55.228   centos-node-3  centos-node-3.eric.com
10.210.55.229   centos-node-4  centos-node-4.eric.com

  

最后配置一下root账户SSH免密登录,试一下

~]# ansible all -m command -a hostname
service | SUCCESS | rc=0 >>
centos-0

node4 | SUCCESS | rc=0 >>
centos-node-4

node3 | SUCCESS | rc=0 >>
centos-node-3

node2 | SUCCESS | rc=0 >>
centos-node-2

node1 | SUCCESS | rc=0 >>
centos-node-1

master2 | SUCCESS | rc=0 >>
centos-master-2

master3 | SUCCESS | rc=0 >>
centos-master-3

master1 | SUCCESS | rc=0 >>
centos-master-1

  

3.2. 配置yum源,我直接使用的是阿里的源

rm -rf /etc/yum.repo.d/*

wget http://mirrors.aliyun.com/repo/Centos-7.repo

wget http://mirrors.aliyun.com/repo/epel-7.repo

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg

#kubernetes repo需要手写
]# cat kubernetes.repo
[kubernetes]
name = kubernetes@aliyun
baseurl = https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck = 1
gpgkey = https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
enabled = 1

#验证一下
]# yum repolist
]# yum makecache

  

猜你喜欢

转载自www.cnblogs.com/demonzk/p/9510386.html