k8s基于adm的安装流程(本地虚拟机测试成功)

首先,生产环境依然决定采用源码编译安装,也是官方推荐的方式。adm依然建议在本地环境学习测试使用!!!

开始:

#时间同步

ntpdate ntp1.aliyun.com

hwclock -w

#关闭防火墙

systemctl disable firewalld

systemctl stop firewalld

#关闭selinux

vim /etc/sysconfig/selinux

SELINUX=disable

vim /etc/selinux/config

SELINUX=disable

setenforce 0

#关闭swap

1、swapoff -a

2、vim /etc/fstat 注释swap这一行后保存退出,确认swap已经关闭,使用命令free -m

iptables -F

iptables -t nat -F

iptables -I FORWARD -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT

vim /etc/sysctl.conf 

net.ipv4.ip_forward=1

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

net.bridge.bridge-nf-call-arptables = 1

vm.swappiness=0

sysctl -p

#设置/etc/hosts

#修改源

1、把/etc/yum.repos.d下的所有文件都放在backup文件夹中

2、wget -O /etc/yum.repos.d/CentOS7-Aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、yum clean all && yum makecache

4、cat <<EOF > /etc/yum.repos.d/kubernetes.repo

[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

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

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

rpm --import yum-key.gpg

rpm --import rpm-package-key.gpg

5、cat <<EOF > /etc/yum.repos.d/docker.repo

[docker]

name=Docker CE Stable - $basearch

baseurl=https://download.docker.com/linux/centos/7/$basearch/stable

enabled=1

gpgcheck=1

gpgkey=https://download.docker.com/linux/centos/gpg

EOF

#安装docker

yum install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm

sudo yum install -y docker-ce-17.03.2.ce-1.el7.centos

#在 /etc/docker 目录下创建daemon.json文件,并且加入以下配置

{

  "storage-driver": "overlay2",

  "storage-opts": [

    "overlay2.override_kernel_check=true"

  ]

}

#启动docker

systemctl enable docker && systemctl start docker

#安装其他

yum install -y kubelet kubeadm kubectl

#查看需要的镜像,下载镜像,根据版本,如果需要翻墙,要改成墙外镜像的名字 通过tag

kubeadm config images list

#初始化master节点

kubeadm config images pull

kubeadm init \

  --node-name master \

  --kubernetes-version=v1.14.1 \

  --pod-network-cidr=10.244.0.0/16

然后显示下边的文案表示安装成功!

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 x.x.x.x:6443 --token pfrwff.xxxxxxxx \

    --discovery-token-ca-cert-hash sha256:xxxxxxxxx


#最后安装一个网络插件flannel

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容