欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

CentOS二进制安装Kubernetes

程序员文章站 2022-03-06 18:29:33
前言最近在私有云部署一套自动化运维平台;其中k8s是重头戏,这篇文章为大家分享一下二进制安装方式k8s架构图安装过程基本环境CentOS版本 7.9.2009Etcd 版本3.4.14Dockerk8s版本 1.17.16kube-apiserver服务安装下载并解压cd /softwget https://dl.k8s.io/v1.20.0/kubernetes-server-linux-amd64.tar.gztar -zxvf kubernete...

前言

最近在私有云部署一套自动化运维平台;

其中k8s是重头戏,这篇文章为大家分享一下二进制安装方式

k8s架构图

CentOS二进制安装Kubernetes

安装过程

  • 基本环境

    • CentOS版本 7.9.2009
    • Etcd 版本3.4.14
    • Docker
    • k8s版本 1.17.16
  • kube-apiserver服务安装

    • 下载并解压
cd /soft
wget https://dl.k8s.io/v1.20.0/kubernetes-server-linux-amd64.tar.gz
tar -zxvf kubernetes-server-linux-amd64.tar.gz
cd kubernetes
  • 创建启动配置文件
mkdir /soft/kubernetes/server/conf/
vim /soft/kubernetes/server/conf/apiserver
  
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_API_PORT="--port=8886"
KUBE_ETCD_SERVERS="--etcd-servers=http://10.9.0.46:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=169.169.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_LOG="--logtostderr=false --log-dir=/home/k8s-t/log/kubernets --v=2"
KUBE_API_ARGS=" "
  • 修改配置文件
vim /etc/systemd/system/kube-apiserver.service
  
[Unit]
Description=Kubernetes API Server
After=etcd.service
Wants=etcd.service
  
[Service]
EnvironmentFile=/soft/kubernetes/server/conf/apiserver
ExecStart=/soft/kubernetes/server/bin/kube-apiserver  \
          $KUBE_ETCD_SERVERS \
          $KUBE_API_ADDRESS \
          $KUBE_API_PORT \
          $KUBE_SERVICE_ADDRESSES \
          $KUBE_ADMISSION_CONTROL \
        $KUBE_API_LOG \
          $KUBE_API_ARGS 
Restart=on-failure
  Type=notify
  LimitNOFILE=65536
  
[Install]
WantedBy=multi-user.target
  • kube-controller-manger服务安装
  • 创建启动配置文件
vim /soft/kubernetes/server/conf/controller-manager

KUBE_MASTER="--master=http://10.9.0.46:8886"
KUBE_CONTROLLER_MANAGER_ARGS=" "
  • 修改配置文件
vim /etc/systemd/system/kube-controller-manager.service
  
[Unit]
Description=Kubernetes Scheduler
After=kube-apiserver.service 
Requires=kube-apiserver.service

[Service]
EnvironmentFile=-/soft/kubernetes/server/conf/controller-manager
ExecStart=/soft/kubernetes/server/bin/kube-controller-manager \
        $KUBE_MASTER \
        $KUBE_CONTROLLER_MANAGER_ARGS
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
  • kube-scheduler服务安装
  • 创建启动配置文件
vim /soft/kubernetes/server/conf/scheduler

KUBE_MASTER="--master=http://10.9.0.46:8886"
KUBE_SCHEDULER_ARGS="--logtostderr=true --log-dir=/home/k8s-t/log/kubernetes --v=2"
  • 创建服务配置文件
vim /etc/systemd/system/kube-scheduler.service

[Unit]
Description=Kubernetes Scheduler
After=kube-apiserver.service 
Requires=kube-apiserver.service

[Service]
User=root
EnvironmentFile=-/soft/kubernetes/server/conf/scheduler
ExecStart=/soft/kubernetes/server/bin/kube-scheduler \
        $KUBE_MASTER \
        $KUBE_SCHEDULER_ARGS
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target 
  • 将各个组件启动
systemctl daemon-reload
systemctl enable kube-apiserver.service
systemctl start kube-apiserver.service

systemctl enable kube-controller-manager.service
systemctl start kube-controller-manager.service

systemctl enable kube-scheduler.service
systemctl start kube-scheduler.service

总结

  • k8s改变了项目运维的方式,使得发布变得十分简单的同时降低了项目风险;

  • 多动手多实践;

本文地址:https://blog.csdn.net/u012829124/article/details/112056142