CentOS7安装Kubernetes

安装Kubernetes时候需要一台机器作为管理机器,1台或者多台机器作为集群中的节点。

系统信息:

Hosts:

请将IP地址换成自己环境的地址.

centos-master = 192.168.164.130
centos-minion-1 = 192.168.164.131
centos-minion-2 = 192.168.164.132
centos-minion-3 = 192.168.164.133

安装准备

*. 在所有的centos-{master,minion-n}上创建文件 /etc/yum.repos.d/virt7-docker-common-release.repo,同时输入以下内容.

[virt7-docker-common-release]
name=virt7-docker-common-release
baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
gpgcheck=0

*. 在所有的机器上centos-{master,minion-n},安装Kubernetes, etcd flannel

yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel

*. 在所有的机器上centos-{master,minion-n}添加hosts信息。将下列信息添加到/etc/hosts

echo "192.168.164.130 centos-master
192.168.164.131 centos-minion-1
192.168.164.132 centos-minion-2
192.168.164.133 centos-minion-3" >> /etc/hosts

*. 编辑所有机器的/etc/kubernetes/config文件。

# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false" # How the replication controller and scheduler find the kube-apiserver
KUBE_MASTER="--master=http://centos-master:8080"

*. 关闭selinux与防火墙

#关闭selinux
将文件的/etc/sysconfig/selinux
SELINUX=enable
改成
SELINUX=disabled
#关闭防火墙
setenforce 0
systemctl disable iptables-services firewalld
systemctl stop iptables-services firewalld

Master服务器上的操作,修改kubernetes服务器配置文件

修改etcd配置文件 /etc/etcd/etcd.conf

# [member]
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" #[cluster]
ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"

修改kubernetes服务器配置文件/etc/kubernetes/apiserver

# The address on the local server to listen to.
KUBE_API_ADDRESS="--address=0.0.0.0" # The port on the local server to listen on.
KUBE_API_PORT="--port=8080" # Port kubelets listen on
KUBELET_PORT="--kubelet-port=10250" # Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://centos-master:2379" # Address range to use for services
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # Add your own!
KUBE_API_ARGS=""

启动ectd同时设置一下,使网络地址足够使用。

systemctl start etcd
etcdctl mkdir /kube-centos/network
etcdctl mk /kube-centos/network/config "{ \"Network\": \"172.30.0.0/16\", \"SubnetLen\": 24, \"Backend\": { \"Type\": \"vxlan\" } }"

修改flannel 配置文件/etc/sysconfig/flanneld

# Flanneld configuration options

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://centos-master:2379" # etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/kube-centos/network" # Any additional options that you want to pass
#FLANNEL_OPTIONS=""

启动服务

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

Minion服务器上的操作,修改kubernetesde kubelet配置文件

配置 kubelet 。启动 kubeletproxy

修改配置文件/etc/kubernetes/kubelet

# The address for the info server to serve on
KUBELET_ADDRESS="--address=0.0.0.0" # The port for the info server to serve on
KUBELET_PORT="--port=10250" # You may leave this blank to use the actual hostname
# Check the node number!
KUBELET_HOSTNAME="--hostname-override=centos-minion-n" # Location of the api-server
KUBELET_API_SERVER="--api-servers=http://centos-master:8080" # Add your own!
KUBELET_ARGS=""

修改flannel 的配置文件。/etc/sysconfig/flanneld

# Flanneld configuration options

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://centos-master:2379" # etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/kube-centos/network" # Any additional options that you want to pass
#FLANNEL_OPTIONS=""

启动所有节点上的相关服务

for SERVICES in kube-proxy kubelet flanneld docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

设置kubectl

kubectl config set-cluster default-cluster --server=http://centos-master:8080
kubectl config set-context default-context --cluster=default-cluster --user=default-admin
kubectl config use-context default-context

安装完成

可以测试一下是否能看到所有节点

# kubectl get nodes
NAME STATUS AGE
centos-minion-1 Ready 5m
centos-minion-2 Ready 5m
centos-minion-3 Ready 1m

CentOS7安装Kubernetes的更多相关文章

  1. centos7安装kubernetes 1.1

    原文地址:http://foxhound.blog.51cto.com/1167932/1717105 前提:centos7 已经update yum update -y 一.创建yum源 maste ...

  2. Centos7安装Kubernetes k8s v1.16.0 国内环境

    一. 为什么是k8s v1.16.0? 最新版的v1.16.2试过了,一直无法安装完成,安装到kubeadm init那一步执行后,报了很多错,如:node xxx not found等.centos ...

  3. centos7安装kubernetes k8s 1.18

    可以参考其他网友的阿里云搭建k8s高可用集群(1.17.3) https://www.cnblogs.com/gmmy/p/12372805.html 准备四台centos7虚拟机,用来安装k8s集群 ...

  4. centos7安装kubernetes k8s 1.16

    #初始化服务器 echo 'export LC_ALL="en_US.UTF-8"' >> /etc/profile source /etc/profile #!/bi ...

  5. CentOS7 安装kubernetes

    2台机器,1台为Master,1台为Node 修改Host Master为dmaster,Node为dslave 安装K8s and Etcd 在Master机器上安装 yum install etc ...

  6. 使用kubeadm 安装 kubernetes 1.12.0

    目录 简介: 架构说明: 系统配置: 1.1 关闭防火墙 1.2 禁用SELinux 1.3 关闭系统Swap 1.4 安装docker 使用kubeadm部署Kubernetes: 2.1 安装ku ...

  7. 使用kubeadm 安装 kubernetes 1.15.1

    简介: Kubernetes作为Google开源的容器运行平台,受到了大家的热捧.搭建一套完整的kubernetes平台,也成为试用这套平台必须迈过的坎儿.kubernetes1.5版本以及之前,安装 ...

  8. Centos7上安装Kubernetes集群部署docker

    一.安装前准备1.操作系统详情需要三台主机,都最小化安装 centos7.3,并update到最新 [root@master ~]# (Core) 角色 主机名 IPMaster master 192 ...

  9. centos7.3 kubernetes/k8s 1.10 离线安装 --已验证

    本文介绍在centos7.3使用kubeadm快速离线安装kubernetes 1.10. 采用单master,单node(可以多node),占用资源较少,方便在笔记本或学习环境快速部署,不适用于生产 ...

随机推荐

  1. C语言里全局变量管理

    C语言里信息封装比較弱,仅仅有静态变量的文件作用域. 假设不加约束.非常easy造成全局变量满天飞. 假设定义一个全局结构体.把全局变量都放到这个GlobleVariate里,应该好管一些,至少比裸奔 ...

  2. Handler类和Handler,Loop,MessageQueue的工作原理

    原文地址:http://blog.csdn.net/xiyangyang8/article/details/50754771 Handler类的作用主要有两种: 1.在新启动的线程中发送消息. 2.在 ...

  3. iOS 图像处理 - 图像拼接

    解决这个问题:将两个图像拼接在一起 前提:须要加入Framework:CoreGraphics.framework 源代码: - (UIImage *) combine:(UIImage*)leftI ...

  4. Android重力感应器Sensor编程

    添加当重力变化时的处理函数在创建监听器时调用的函数 doSomething(x, y, z) 是自己定义的方法.当手机倾斜方向改变时,监听器会调用该方法.我们要做的,就是填充该方法,用于在重力发生变化 ...

  5. 我在Suse 11 Sp3上使用anaconda安装TensorFlow的过程记录

    我在Suse 11 Sp3上使用anaconda安装TensorFlow的过程记录 准备安装包: gcc48 glibc--SP4-DVD-x86_64-GM-DVD1.iso tensorflow_ ...

  6. 【POJ 1964】 City Game

    [题目链接] http://poj.org/problem?id=1964 [算法] 记f[i]表示第i行最多向上延伸的行数 然后,对于每一行,我们用单调栈计算出这一行向上延伸的最大矩形面积,取最大值 ...

  7. 操作系统-虚拟机-百科:VM

    ylbtech-操作系统-虚拟机-百科:VM 虚拟机(Virtual Machine)指通过软件模拟的具有完整硬件系统功能的.运行在一个完全隔离环境中的完整计算机系统. 虚拟系统通过生成现有操作系统的 ...

  8. NOIP 2015 DAY2

    跳石头 题目背景 一年一度的“跳石头”比赛又要开始了! 题目描述 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石.组委会已经选择好了两块岩石作为比赛起点和终点.在起点和终点之间,有 N 块 ...

  9. Docker容器的使用和连接

    在上一篇文章<Docker从安装部署到Hello World>介绍了如何在CentOS7上安装Docker.这篇文章主要介绍一下Docker容器的使用和连接. vDocker 容器使用 1 ...

  10. Windows7下caffe-ssd-microsoft下编译

    整个编译可谓漫长 编译了两天 网上教程也很多 但是也很杂 遇到各种错误 总归是编完了 1.下载Windows版本的Caffe-SSD源码 下载链接:https://github.com/conner9 ...