kubenetes(k8s)集群部署使用

k8s中文社区:

www.kubernetes.org.cn

k8s中文文档:

http://docs.kubernetes.org.cn

https://www.kubernetes.org.cn/k8s

k8s下载地址:

https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.8.md#downloads-for-v188

 

一.前提环境准备

1.关闭防火墙:

systemctl stop firewalld

systemctl disable firewalld

2.关闭selinux:

setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config 

3.关闭swap分区:

swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab

4.添加k8s集群主机host映射

vim /etc/hosts

192.168.30.23 k8s-master 
192.168.30.24 k8s-node1 
192.168.70.52 k8s-node2

5.将桥接的IPv4流量传递到iptables的链

cat > /etc/sysctl.d/k8s.conf << EOF 
net.bridge.bridge-nf-call-ip6tables = 1 
net.bridge.bridge-nf-call-iptables = 1 
EOF    

sysctl --system

 

二.所有节点安装Docker/kubeadm/kubelet

1.安装docker

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo 
yum -y install docker-ce-18.06.1.ce-3.el7 
systemctl enable docker 
systemctl start docker 
docker --version 
docker info

kubenetes(k8s)集群部署使用

2.添加阿里云YUM软件源

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=1 
repo_gpgcheck=1 
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg 
https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg 
EOF

3.安装kubeadm,kubelet和kubectl

yum install -y kubelet-1.13.3 kubeadm-1.13.3 kubectl-1.13.3

##可能出现报错:

kubenetes(k8s)集群部署使用

##解决:修改kubrenetes.repo

cat>>/etc/yum.repos.d/kubrenetes.repo<<EOF

[kubernetes]

name=Kubernetes Repo

baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/

gpgcheck=0

gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg

EOF

##再次安装即可

yum install -y kubelet-1.13.3 kubeadm-1.13.3 kubectl-1.13.3 kubernetes-cni-0.6.0 ipvsadm

##启动kubelet

systemctl enable kubelet

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

上一篇:XML Parser Error on line 1: 前言中不允许有内容, Mybatis 生成代码


下一篇:K8S 核心组件 kubelet 与 kube-proxy 分析