K8s一键安装

安装案例:

系统:Centos
可以多台Master(Master不能低于3台)多台Node
此案例使用三台Master两台Node,用户名root,密码均为123456

master	192.168.20.183
master	192.168.20.96
master	192.168.20.171
node	192.168.20.172
node    192.168.20.54
安装Master集群

下载项目:

git clone https://github.com/zdwork/k8s-install.git
cd k8s-install

修改 conf/master-install.conf
内容如下:

#!/bin/bash
#User-defined information
export node=3 #集群数量
export node_ip="192.168.20.183 192.168.20.96 192.168.20.171" #服务器的ip,以空格分割
export node_name="master-01 master-02 master-03" #主机名 自定义,以空格分割
export node_pass="123456 123456 123456" #每台服务器的root密码,以空格分割
export apiserver_vip="192.168.20.240"#高可用IP 注意此ip要没有被占用
export apiserver_vip_port="4443"
export flaneld_interface="ens33" #你的网卡
export vip_interface="ens33" #你的网卡
export haproxy_name="admin"
export haproxy_pass="123456"
export haproxy_status_port="8000"

安装:

./install.sh

脚本执行完后会打打印出如下信息:

 ---------------- etcd --------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:03:46 CST; 1h 44min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:03:47 CST; 1h 44min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:04:07 CST; 1h 43min ago
 ---------------- kube-apiserver -----------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:07:07 CST; 1h 40min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:07:20 CST; 1h 40min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:07:32 CST; 1h 40min ago
 ---------------- kube-scheduler ------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:08:26 CST; 1h 39min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:08:26 CST; 1h 39min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:08:26 CST; 1h 39min ago
 ---------------- kube-controller_manager ----------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:07:59 CST; 1h 40min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:09:08 CST; 1h 38min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:08:02 CST; 1h 40min ago
 ---------------- keepalived ------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:06:31 CST; 1h 41min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:06:33 CST; 1h 41min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:06:34 CST; 1h 41min ago
 ---------------- haproxy ---------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:05:03 CST; 1h 43min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:05:20 CST; 1h 42min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:05:34 CST; 1h 42min ago
 ---------------- flanneld --------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:04:39 CST; 1h 43min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:04:41 CST; 1h 43min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:04:43 CST; 1h 43min ago
 ################ Current cluster state ####################
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok                  
controller-manager   Healthy   ok                  
etcd-1               Healthy   {"health":"true"}   
etcd-2               Healthy   {"health":"true"}   
etcd-0               Healthy   {"health":"true"}   
安装Node

修改 conf/node-install.conf
内容如下:

#!/bin/bash

#User-defined information
export node=2
export node_ip="192.168.20.172 192.168.20.54"
export node_name="node-1 node-2"
export node_pass="123456 123456"
export flaneld_interface="ens33"

安装:

./install.sh

脚本执行完后会打打印出如下信息:

---------------- flanneld --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:34 CST; 26s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:28:37 CST; 25s ago
 ---------------- docker --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:38 CST; 24s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:28:42 CST; 21s ago
 ---------------- kubelet --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:52 CST; 11s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:28:54 CST; 10s ago
 ---------------- kube-proxy --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:59 CST; 5s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:29:00 CST; 5s ago

测试:

[root@localhost k8s-install]# bash
[root@master-01 k8s-install]# source /etc/profile
[root@master-01 k8s-install]# kubectl get nodes
NAME      STATUS    ROLES     AGE       VERSION
node-1    Ready     <none>    35s       v1.10.4
node-2    Ready     <none>    34s       v1.10.4
[root@master-01 k8s-install]#

转载于:https://www.cnblogs.com/cy0917/p/10212566.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Ubuntu 22上安装K8s可以使用一键脚本来简化整个过程。以下是安装K8s一键脚本步骤: 1. 首先,您需要确保已经安装了Ubuntu Server 22. 如果尚未完成,请先安装操作系统。 2. 打开终端,使用root用户或具有sudo权限的用户登录。 3. 下载K8s一键安装脚本。您可以在GitHub上找到不同版本的脚本。例如,可以在https://github.com/kubesphere/install-kubeadm-ansible上找到一个常用的一键安装脚本。使用wget命令下载脚本。 ``` wget https://raw.githubusercontent.com/kubesphere/install-kubeadm-ansible/v0.3.0/install-kubeadm-ansible.sh ``` 4. 使用chmod命令将脚本设置为可执行权限。 ``` chmod +x install-kubeadm-ansible.sh ``` 5. 运行脚本。 ``` ./install-kubeadm-ansible.sh ``` 6. 脚本将开始执行并下载所需的依赖项和工具。 7. 一旦完成,您将被提示输入Master节点和Worker节点的IP地址和主机名。 8. 在脚本运行过程中,您将被要求提供一些配置选项,例如K8s版本,网络插件和其他参数。根据您的需求进行选择。 9. 脚本将继续运行,并自动配置K8s集群。 10. 安装完成后,您可以使用kubectl命令来管理K8s集群。 请注意,这只是一个基本的一键安装脚本示例。根据您的特定要求和环境配置,您可能需要使用不同的一键脚本或自行编写脚本。确保在执行脚本之前备份重要数据,并确保您已经理解和熟悉了脚本的作用和可能的影响。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值