K8s集群安装--最新版 Kubernetes 1.14.1

前言

网上有很多关于k8s安装的文章,但是我参照一些文章安装时碰到了不少坑。今天终于安装好了,故将一些关键点写下来与大家共享。

我安装是基于ss客户端的,鉴于ss有些敏感,故不做说明。

环境说明

Centos

cat /etc/redhat-release

CentOS Linux release 7.6.1810 (Core)

Docker

ss客户端+privoxy

hostname ip 环境说明
k8master 192.168.2.38 笔记本电脑 8G i3-5005U
node3 192.168.2.23 exsi下 2G E3-1226 v3

代理设置

~/.bash_profile # 当前用户

/etc/profile # 系统级

在最后加入

export proxy="http://192.168.2.38:8118"
export http_proxy=$proxy
export https_proxy=$proxy
export ftp_proxy=$proxy
export no_proxy="localhost, 127.0.0.1, ::1"
source /etc/profile # 使生效

/etc/yum.conf

在最后加入

# Proxy
proxy=http://192.168.2.38:8118/

也可

echo "proxy=http://192.168.2.38:8118/" >> /etc/yum.conf

/etc/wgetrc

在最后加入

#  Proxy
http_proxy=http://192.168.2.38:8118/
ftp_proxy=http://192.168.2.38:8118/

docker安装

参考文章

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

docker 设置代理

参考文章

mkdir -p /etc/systemd/system/docker.service.d

nano /etc/systemd/system/docker.service.d/http-proxy.conf

# 添加
[Service]
Environment="HTTP_PROXY=http://192.168.2.38:8118/" "HTTPS_PROXY=http://192.168.2.38:8118/"

更新配置

systemctl daemon-reload

重启服务

systemctl restart docker

k8s安装

参照链接1

参照链接2

关闭swap

执行swapoff临时关闭swap。

swapoff -a

重启后会失效,若要永久关闭,可以编辑/etc/fstab文件,将其中swap分区一行注释掉

nano /etc/fstab

#/dev/mapper/centos-swap swap                    swap    defaults        0 0

添加yum仓库

nano /etc/yum.repos.d/kubernetes.repo

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*

关闭firewalld

systemctl stop firewalld

systemctl disable firewalld

关闭SELinux

setenforce 0

sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

修改sysctl内核参数

nano /etc/sysctl.d/k8s.conf

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0

sysctl --system

安装kubeadm, kubelet and kubectl

yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

systemctl enable --now kubelet

拉取镜像

说明:执行kubeadm需配置docker代理才能访问gcr.io

kubeadm config images pull

安装pod网络插件

yum insatll flanneld

初始化集群master

kubeadm init --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 192.168.2.38:6443 --token vxoj3n.5tiw4y9c4chppagz \
--discovery-token-ca-cert-hash sha256:f844a1934f1ed2399468f7037bb8605c112eab89bcdf5a4dea9cbd89e6906261

记录并保存屏幕文字,后续worker节点将用到。

执行以下命令配置kubectl,作为普通用户管理集群并在集群上工作

mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

获取pods列表

kubectl get pods --all-namespaces

查看集群的健康状态

kubectl get cs

worker节点加入

操作同master节点,直到初始化集群master这一步(worker节点不用初始化)

kubeadm join 192.168.2.38:6443 --token vxoj3n.5tiw4y9c4chppagz \
--discovery-token-ca-cert-hash sha256:f844a1934f1ed2399468f7037bb8605c112eab89bcdf5a4dea9cbd89e6906261

然后等待几分钟

部署dashboard

注意项

获取登录dashboard的token

kubectl -n kube-system describe $(kubectl -n kube-system get secret -n kube-system -o name |grep namespace)|grep token

kubernetes nodes notready的处理

systemctl restart docker

K8s集群安装--最新版 Kubernetes 1.14.1的更多相关文章

  1. [转帖]K8s集群安装--最新版 Kubernetes 1.14.1

    K8s集群安装--最新版 Kubernetes 1.14.1 http://www.cnblogs.com/jieky/p/10679998.html 原作者写的比较简单 大略流程和跳转的多一些 改天 ...

  2. K8S集群安装部署

    K8S集群安装部署   参考地址:https://www.cnblogs.com/xkops/p/6169034.html 1. 确保系统已经安装epel-release源 # yum -y inst ...

  3. Kubernetes(k8s)集群安装

    一:简介 二:基础环境安装 1.系统环境 os Role ip Memory Centos 7 master01 192.168.25.30 4G Centos 7 node01 192.168.25 ...

  4. CentOS7 部署K8S集群,最新版1.17.3-0

    小白在网上找了很多关于k8s集群部署的文档,但是版本老旧,到处踩坑,终于部署成功,记录下过程. 一.准备工作 虚拟机:VMware® Workstation 15 Pro Xhell 6:Xshell ...

  5. K8s集群安装和检查(经验分享)

    一.组件方式检查 1. Master节点: root>> kubectl get cs 2. Node 节点: 无  二.服务方式检查 1. Master 节点: root>> ...

  6. Kudu的集群安装(1.6.0-cdh5.14.0)

    kudu的架构体系 下图显示了一个具有三个 master 和多个 tablet server 的 Kudu 集群,每个服务器都支持多个 tablet.它说明了如何使用 Raft 共识来允许 maste ...

  7. install kubernetes cluster k8s集群安装

    一,安装docker-ce 17.031,下载rpm包 Wget -P /tmp https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/ ...

  8. 基于 K8S 集群安装部署 istio-1.2.4

    使用云平台可以为组织提供丰富的好处.然而,不可否认的是,采用云可能会给 DevOps 团队带来压力.开发人员必须使用微服务以满足应用的可移植性,同时运营商管理了极其庞大的混合和多云部署.Istio 允 ...

  9. K8s 集群安装(一)

    01,集群环境 三个节点   master node1 node2 IP 192.168.0.81 192.168.0.82 192.168.0.83 环境 centos 7 centos 7 cen ...

随机推荐

  1. Eclipse 异常关闭

    缺失 Java Builder 造成运行main方法,找不到主类, 系统没有自动编译 在.project 文件中添加 <buildSpec> <buildCommand> &l ...

  2. Spring3.0+Hibernate+Atomikos集成构建JTA的分布式事务--解决多数据源跨库事务

    一.概念 分布式事务分布式事务是指事务的参与者.支持事务的服务器.资源服务器以及事务管理器分别位于不同的分布式系统的不同节点之上.简言之,同时操作多个数据库保持事务的统一,达到跨库事务的效果. JTA ...

  3. 文件 md5 查看 命令

    Windows命令查看文件MD5   certutil -hashfile yourfilename.ext MD5 certutil -hashfile yourfilename.ext SHA1 ...

  4. easyui图标大全

    .icon-blank{ background:url('icons/blank.gif') no-repeat; } .icon-add{ background:url('icons/edit_ad ...

  5. tp5写日志

  6. js改变触发

    onchange="doEmpty($(this))"

  7. SourceTree 3.0.8 跳过登陆注册

    3.0.8普通用户版account.json跳过登陆注册方法已失效,请安装企业版 https://www.sourcetreeapp.com/enterprise 企业版默认安装在 %programf ...

  8. SDN网络工具

    TcpDump 根据使用者的定义对网络上的数据包进行截获的包分析工具. http://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html ...

  9. windows7配置git 免密码登录git服务器

    1.在桌面右击“Git Bash Here ” 2.输入:cd ~/.ssh/ 3.输入你的git服务器的用户 git config --global user.name "xx" ...

  10. 设计模式17:Iterator 迭代器模式(行为型模式)

    Iterator 迭代器模式(行为型模式) 动机(Motivation) 在软件构建过程中,集合对象内部结构常常变化各异.但对于这些集合对象,我们希望在不暴露其内部结构的同时,可以让外部客户代码可以透 ...