码迷,mamicode.com
首页 > Web开发 > 详细

Kubernetes环境部署

时间:2019-12-23 00:14:51      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:ice   disco   for   tran   EDA   using   hash   usr   curl   

简介

Kubernetes 是一个开源系统,用于容器化应用的自动部署、扩缩和管理。它将构成应用的容器按逻辑单位进行分组以便于管理和发现。
 
配置镜像源

Debian / Ubuntu

apt-get update && apt-get install -y apt-transport-https
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF  
apt-get update

CentOS / RHEL / Fedora

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
setenforce 0

以centos为例搭建环境

1.安装:按照顺序

yum install kubelet-1.13.12-0
yum install kubectl-1.13.12-0
yum install kubeadm-1.13.12-0


2.安装后执行如下命令,先查看需要的镜像文件:

kubeadm config images list
-----------------------------
k8s.gcr.io/kube-apiserver:v1.13.12
k8s.gcr.io/kube-controller-manager:v1.13.12
k8s.gcr.io/kube-scheduler:v1.13.12
k8s.gcr.io/kube-proxy:v1.13.12
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.2.24
k8s.gcr.io/coredns:1.2.6

3.导入并配置对应的镜像文件


docker load -i registry.aliyuncs.com.google_containers.kube-apiserver.tar
docker image ls
tag f07fae2c3e6a k8s.gcr.io/kube-apiserver:v1.13.12
docker load -i registry.aliyuncs.com.google_containers.kube-controller-manager.tar
docker image ls
docker tag 90fd4a237264 k8s.gcr.io/kube-controller-manager:v1.13.12
docker load -i registry.aliyuncs.com.google_containers.kube-scheduler.tar
docker image ls
docker tag 54f3185a42a5 k8s.gcr.io/kube-scheduler:v1.13.12
docker load -i registry.aliyuncs.com.google_containers.kube-proxy.tar
docker image ls
docker tag 4022daa30d3e k8s.gcr.io/kube-proxy:v1.13.12
docker load -i registry.aliyuncs.com.google_containers.pause.tar
docker image ls
docker tag da86e6ba6ca1 k8s.gcr.io/pause:3.1
docker load -i registry.aliyuncs.com.google_containers.etcd.tar
docker image ls
docker tag 3cab8e1b9802 k8s.gcr.io/etcd:3.2.24
docker load -i registry.aliyuncs.com.google_containers.coredns.tar
docker image ls
docker tag f59dcacceff4 k8s.gcr.io/coredns:1.2.6

4.导入并修改好镜像名后执行

kubeadm init --pod-network-cidr=10.244.0.0/16

5.若出现报错

技术图片

 

6.执行如下命令

 kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=swap

7.执行后若出现报错:

技术图片

 

 8.需要查看日志:

journalctl --no-page -xeu kubelet
--或者 journalctl
--no-page -xeu kubelet|grep swap

技术图片

 9.查看配置文件:

cd  /usr/lib/systemd/system/kubelet.service.d
[root@localhost kubelet.service.d]# ls
10-kubeadm.conf

10.找出配置文件中环境配置文件路径

EnvironmentFile=-/etc/sysconfig/kubelet

 

 11.修改环境配置文件:

KUBELET_EXTRA_ARGS="--fail-swap-on=false"

 

 12.重启kubeadm

kubeadm reset

 13.再次执行

kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=swap

 

 14.环境搭建成功

Your Kubernetes master 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/

You can now join any number of machines by running the following on each node
as root:

  kubeadm join 192.168.4.131:6443 --token ft7m0e.i9z5x43zbaa1yk55 --discovery-token-ca-cert-hash sha256:4b3a2b2a4a164ca270d4173169eda4ec707ad16653387e6960185dcb76832837

 

 

Kubernetes环境部署

标签:ice   disco   for   tran   EDA   using   hash   usr   curl   

原文地址:https://www.cnblogs.com/mingfan/p/12081699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!