`
m635674608
  • 浏览: 5090913 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

CentOS7上部署Kubernetes

 
阅读更多

<div class="iteye-blog-content-contain" style="font-size: 14px"></div>

 

Kubernetes架构

Kubernetes的整体架构如下:

 NewImage

Master为主控节点,上面运行apiserver,scheduler,controller-manager等组件。Minion相当于工作节点,上面运行kubelet,proxy,cAdvisor以及最重要的docker等组件。下面来实际部署一下这套集群管理工具。

环境

yy1  10.193.6.35

yy2  10.193.6.36

yy1作为master,yy2作为minion。

 

# cat /etc/centos-release

CentOS Linux release 7.0.1406 (Core)

 

安装kubernetes

# curl https://copr.fedoraproject.org/coprs/eparis/kubernetes-epel-7/repo/epel-7/eparis-kubernetes-epel-7-epel-7.repo -o /etc/yum.repos.d/eparis-kubernetes-epel-7-epel-7.repo

# yum install kubernetes -y

 

配置yy1

复制代码
# cat /etc/kubernetes/apiserver

###

# kubernetes system config

#

# The following values are used to configure the kubernetes-apiserver

#

 

# The address on the local server to listen to.

KUBE_API_ADDRESS="10.193.6.35"

 

# The port on the local server to listen on.

KUBE_API_PORT="8080"

 

# How the replication controller and scheduler find the apiserver

KUBE_MASTER="10.193.6.35:8080"

 

# Comma seperated list of minions

MINION_ADDRESSES="10.193.6.36"

 

# Port minions listen on

MINION_PORT="10250"

 

# cat /etc/kubernetes/config

###

# kubernetes system config

#

# The following values are used to configure various aspects of all

# kubernetes services, including

#

#   kubernetes-apiserver.service

#   kubernetes-controller-manager.service

#   kubernetes-kubelet.service

#   kubernetes-proxy.service

 

# Comma seperated list of nodes in the etcd cluster

KUBE_ETCD_SERVERS="http://10.193.6.35:4001"

 

# logging to stderr means we get it in the systemd journal

KUBE_LOGTOSTDERR="true"

 

# journal message level, 0 is debug

KUBE_LOG_LEVEL=0

 

# Should this cluster be allowed to run privleged docker containers

KUBE_ALLOW_PRIV="true"
复制代码

 

 

启动yy1上相关服务

master上需要运行etcd,kube-apiserver,kube-controller-manager,kube-scheduler这4个进程。

复制代码
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do

    systemctl restart $SERVICES

    systemctl enable $SERVICES

    systemctl status $SERVICES

done
复制代码

 

 

配置yy2

复制代码
 1 # cat /etc/kubernetes/kubelet
 2 
 3 ###
 4 
 5 # kubernetes kublet (minion) config
 6 
 7  
 8 
 9 # The address for the info server to serve on
10 
11 MINION_ADDRESS="10.193.6.36"
12 
13  
14 
15 # The port for the info server to serve on
16 
17 MINION_PORT="10250"
18 
19  
20 
21 # You may leave this blank to use the actual hostname
22 
23 MINION_HOSTNAME="10.193.6.36"
24 
25  
26 
27 # cat /etc/kubernetes/config  
28 
29 ###
30 
31 # kubernetes system config
32 
33 #
34 
35 # The following values are used to configure various aspects of all
36 
37 # kubernetes services, including
38 
39 #
40 
41 #   kubernetes-apiserver.service
42 
43 #   kubernetes-controller-manager.service
44 
45 #   kubernetes-kubelet.service
46 
47 #   kubernetes-proxy.service
48 
49  
50 
51 # Comma seperated list of nodes in the etcd cluster
52 
53 KUBE_ETCD_SERVERS="http://10.193.6.35:4001"
54 
55  
56 
57 # logging to stderr means we get it in the systemd journal
58 
59 KUBE_LOGTOSTDERR="true"
60 
61  
62 
63 # journal message level, 0 is debug
64 
65 KUBE_LOG_LEVEL=0
66 
67  
68 
69 # Should this cluster be allowed to run privleged docker containers
70 
71 KUBE_ALLOW_PRIV="true"
复制代码

 

 

修改yy2 kubelet的配置

CentOS7上没有docker.socket服务,注释掉kubelet中对docker.socket的依赖。

/usr/lib/systemd/system/kubelet.service

复制代码
 1  [Unit]
 2 
 3 Description=Kubernetes Kubelet
 4 
 5 #After=docker.socket cadvisor.service
 6 
 7 After=cadvisor.service
 8 
 9 #Requires=docker.socket cadvisor.service
10 
11 Requires=cadvisor.service
复制代码

 

 

启动yy2上的相关服务

minion上需要运行kube-proxy,kubelet以及docker。

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

 

创建pod描述文件

创建一个apache的pod描述文件。

复制代码
# cat apache.json

{

  "id": "apache",

  "desiredState": {

    "manifest": {

      "version": "v1beta1",

      "id": "apache-1",

      "containers": [{

        "name": "master",

        "image": "fedora/apache",

        "ports": [{

          "containerPort": 80,

          "hostPort": 80

        }]

      }]

    }

  },

  "labels": {

    "name": "apache"

  }

}
复制代码

 

 

创建pod

通过客户端工具kubecfg提交任务给apiserver,由scheduler选择一个minion部署容。

复制代码
[root@yy1 ~]# kubecfg -c apache.json create pods

I0925 06:43:26.768122 09313 request.go:292] Waiting for completion of /operations/1

ID                  Image(s)            Host                Labels              Status

----------          ----------          ----------          ----------          ----------

apache              fedora/apache       /                   name=apache         Waiting

 

[root@yy1 ~]# kubecfg list pods 

ID                  Image(s)            Host                Labels              Status

----------          ----------          ----------          ----------          ----------

apache              fedora/apache       10.193.6.36/        name=apache         Waiting
复制代码

 

 

apache服务会自动部署到机器yy2,yy2上的docker会自动下载image,然后启动apache服务。顺利的话,过一会儿,apache服务就会在yy2上起来。

复制代码
[root@yy1 ~]# kubecfg list pods  

ID                  Image(s)            Host                Labels              Status

----------          ----------          ----------          ----------          ----------

apache              fedora/apache       10.193.6.36/        name=apache         Running
复制代码

 

 NewImage

可以尝试访问一下,

 NewImage

 

主要参考

https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/fedora/fedora_manual_config.md

 

http://www.cnblogs.com/hustcat/p/3993712.html

分享到:
评论

相关推荐

    CentOS 7 使用 Calico 网络插件部署Kubernetes 集群

    总之,通过在CentOS 7上使用Calico网络插件部署Kubernetes集群,我们可以构建一个高效、安全的容器化环境,满足现代云原生应用的复杂需求。无论是对于开发、测试还是生产环境,这都是一个值得考虑的方案。

    使用Kubeadm在CentOS7.2上部署Kubernetes集群的方法

    本文参考kubernetes官网文章Installing Kubernetes on Linux with kubeadm在CentOS7.2使用Kubeadm部署Kuebernetes集群,解决了一些在按照该文档部署时遇到的问题。 操作系统版本 # cat /etc/redhat-release CentOS...

    kubernetes1.28部署(Centos7)

    在CentOS 7上部署Kubernetes集群时,选择合适的flannel后端对于保证网络通信效率至关重要。 除此之外,网络插件的正确部署还需要考虑网络安全、跨网络边界的数据交换以及网络策略的实现。在企业级部署中,可能还...

    linux-centos7一键部署deployKubernetesv1131脚本

    在CentOS7上部署Kubernetes,能够充分利用其强大的系统管理工具和对最新技术的支持。 **四、一键部署脚本** “deploy_Kubernetes:v1.13.1”脚本是实现自动化部署的关键。这个脚本通常包含了安装必要的依赖、配置...

    基于CentOS 7的Kubernetes安装全过程(含附件)

    基于CentOS 7的Kubernetes安装全过程(含附件) 目录如下: 第一部分:Nginx on Kubernetes应用部署 3 一、环境准备 3 1.1软硬件环境 3 1.2 网络拓扑 4 二、Kubenetes及相关组件部署 6 2.1 Docker容器及私有仓库部署...

    CentOS 使用二进制部署 Kubernetes 1.13集群.docx

    本文档主要介绍了如何在 CentOS 系统上使用二进制方式部署 Kubernetes 1.13 集群。Kubernetes(简称 K8s)是一个开源的容器管理系统,能够自动化容器编排、部署和扩展。在选择部署方式时,文章建议避免使用像 ...

    CentOS 7.9 最小化安装 kubernetes(k8s)1.25.3(免费下载)

    在本教程中,我们将深入探讨如何在CentOS 7.9最小化安装环境中部署Kubernetes(简称k8s)版本1.25.3。Kubernetes是一个开源的容器编排系统,用于自动化容器化应用程序的部署、扩展和管理。CentOS作为一款稳定的Linux...

    Kubernetes1.6集群部署完全指南——二进制文件部署开启TLS基于CentOS7

    本指南旨在详细介绍如何在 CentOS 7 系统上通过二进制文件部署的方式搭建一个启用 TLS 的 Kubernetes 1.6 集群。TLS(Transport Layer Security)是一种安全协议,用于加密应用程序数据,确保网络通信的安全性。在 ...

    CentOS7下快速部署kubernetes1.15高可用集群-kubeadm篇.pdf

    kubernetes官方给我提供了一个简易的集群部署工具Kubeadm,目的就是 让我们能快速的部署一个可用的生产环境集群。今天我就和大家一起来体验一 下

    deploy-kubernetes-one-button:使用kubeadm一键在centos7上部署k8s 1.11.1

    使用Kubeadm在centos 7上部署kubernetes 1.11.1首先: 如果要在Mac上执行代码,则需要安装gnu-sed来替换系统中的sed brew install gnu-sed --with-default-names # Add /usr/local/bin/ to you PATH # reopen your ...

    基于centos7.9系统使用docker安装部署Prometheus+Grafana方式实现对Li

    本文将详细介绍如何在CentOS 7.9系统上利用Docker容器技术,部署和配置Prometheus和Grafana的完整流程。 首先,CentOS 7.9作为当前稳定版本的Linux发行版,为搭建监控系统提供了坚实的操作系统基础。Docker的使用则...

    centos8 kubernetes 安装步骤以及相关注意点

    centos8 使用 kubeadm 安装 详细步骤以及常用tool 机器使用阿里云服务器 包括一些常见问题的解决方案

    CentOS7实战Kubernetes部署

    上一节我们阐述了Kubernetes的系统架构,让大家对Kubernetes有一定的初步了解,但是就如何使用Kubernetes,也许大家还不知如何下手。本文作者将带领大家如何在本地部署、配置Kubernetes集群网络环境以及通过实例演示...

Global site tag (gtag.js) - Google Analytics