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

Kubernates集群入门(1) 防火墙脚本velocityVBScriptLinq 

程序员文章站 2023-12-21 15:45:22
...
阅读原文:http://click.aliyun.com/m/22408/
摘要: 一、K8s安装准备 1.至少两台主机,一台作为master,一台作为node。两台主机需要关闭防火墙。 #centos6 service stop firewalld && service disable firewalld #centos7 systemctl stop iptables && systemctl disable iptables; 2.

一、K8s安装准备

1.至少两台主机,一台作为master,一台作为node。两台主机需要关闭防火墙。

#centos6
service stop firewalld  && service disable firewalld
#centos7
systemctl stop iptables && systemctl disable iptables;
2.两台机器需要各自编辑/etc/hosts文件,互相添加hostname,然后相互ping通,以下为例

echo "192.168.18.128 centos-master
192.168.18.130 centos-minion
" >> /etc/hosts
二、K8s的安装

1.两台主机都需要安装docker,kubernetes,如有docker版本冲突需要卸载重新安装docker.

yum -y install docker kubernetes
2.master节点需要安装etcd数据库服务,etcd作为kubernetes的数据库

yum -y install etcd
3.每个节点修改kubernetes配置文件

vim /etc/kubernetes/config

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://centos-master:8080"
KUBE_ETCD_SERVERS="--etcd_servers=http://centos-master:4001"

4.master节点上,配置api服务给node

vim /etc/kubernetes/apiserver

# The address on the local server to listen to.
KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_API_PORT="--port=8080"
# Comma separated list of nodes in the etcd cluster
#KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"

5.master节点上编写启动相关kubernetes服务的脚本

vim k8s-up.sh

#!/bin/bash

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

查看服务状态的脚本

vim k8s-stat.sh

#!/bin/bash

for SERVICES in etcd kube-apiserver kube-controllermanager
kube-scheduler; do
systemctl status $SERVICES
done
6.node节点修改/etc/kubernetes/kubelet,配置与master的连接

###
# kubernetes kubelet (minion) config
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname_override=centos-minion"
KUBELET_API_SERVER="--api_servers=http://centos-master:8080“
# Add your own!
KUBELET_ARGS=""
7.node节点编写启动和查看服务脚本

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

for SERVICES in kube-proxy kubelet docker; do
systemctl status $SERVICES
done
8.node节点查看是否成功注册到master节点,如果没关闭防火墙会报错

tail -f /var/log/messages |grep kube
9.master节点查看刚才注册的节点,节点status为ready为正常

kubectl get nodes
10.kubectl是master端的交互工具,可以通过子命令查看节点等信息

kubectl get nodes #获取节点列表

kubectl cluster-info #查看节点信息
----
**下一节演示一个简单的kubernetes实例,master节点通过yaml文件,让node节点自动pull镜像并运行。**
阅读原文:http://click.aliyun.com/m/22408/

上一篇:

下一篇: