目录:
云计算服务分类
云计算(服务)可以按照服务类型来分类,分为三种类型:
国内的云计算发展目前处于IAAS和PAAS阶段,对于IT运维人员来讲,第一工作要务:了解云计算平台概念、用途、云计算平台构建、维护、部署、排错、优化、添加资源池、弹性扩容、弹性缩容等
私有云面向企业内部的资源服务、租户服务的,企业内部租户可以根据需求去私有云资源池申请各个资源;
公有云面向互联网租户,互联网租户需要购买、采购、花费RMB去购买的资源;
将私有云和公有云同时存在,既可以提供私有云服务,也可以提供公有云的服务;
主要的实现技术框架有两种:
K8S是云计算资源的管理平台、管理框架,基于K8S云计算项目可以:云计算平台部署、各个资源管理、调度、生成资源池、创建虚拟机、删除虚拟机、重启虚拟机等,Docker虚拟化是K8S云计算项目中一个模块,是K8S用于管理创建虚拟机、删除虚拟机、镜像、容器的组件;
使用Kubernetes可以实现如下功能:
yum install kubernetes-master etcd flannel -y
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# 可加入定时任务后service crond restart
[root@localhost ~]# ntpdate pool.ntp.org
[root@localhost ~]# cd /etc/etcd/
[root@localhost etcd]# cp etcd.conf etcd.conf.bak
[root@localhost etcd]# sed -i '/^#/d' etcd.conf
etcd.conf 文件内容ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_NAME="default"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.197.10:2379"
[root@localhost etcd]# service etcd restart
kubernetes配置修改
5. 修改apiserver
[root@localhost etcd]# cd /etc/kubernetes/
[root@localhost kubernetes]# vim apiserver
# 示例中k8s和etcd在同一台主机上
# api监听地址
8 KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
# etcd服务所在的主机ip和端口
17 KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.197.10:2379"
[root@localhost kubernetes]# vim config
# apiserverip 和使用端口
22 KUBE_MASTER="--master=http://192.168.197.10:8080"
[root@localhost kubernetes]# service kube-apiserver start
Redirecting to /bin/systemctl start kube-apiserver.service
[root@localhost kubernetes]# service kube-controller-manager start
Redirecting to /bin/systemctl start kube-controller-manager.service
[root@localhost kubernetes]# service kube-scheduler start
Redirecting to /bin/systemctl start kube-scheduler.service
[root@localhost kubernetes]# ps -ef | grep -E "apiserver|controller|scheduler"
kube 15376 1 1 14:32 ? 00:00:00 /usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd-servers=http://192.168.197.10:2379 --insecure-bind-address=192.168.197.10 --allow-privileged=false --service-cluster-ip-range=10.254.0.0/16 --admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota
kube 15396 1 1 14:32 ? 00:00:00 /usr/bin/kube-controller-manager --logtostderr=true --v=0 --master=http://192.168.197.10:8080
kube 15417 1 0 14:33 ? 00:00:00 /usr/bin/kube-scheduler --logtostderr=true --v=0 --master=http://192.168.197.10:8080
root 15423 1074 0 14:34 pts/0 00:00:00 grep --color=auto -E apiserver|controller|scheduler
回到目录
[root@localhost ~]# yum install kubernetes-node docker flannel *rhsm* -y
[root@localhost ~]# cd /etc/kubernetes/
[root@localhost kubernetes]# vim config
22 KUBE_MASTER="--master=http://192.168.197.10:8080"
# 客户端监听地址
5 KUBELET_ADDRESS="--address=192.168.197.11"
# 客户端主机名
11 KUBELET_HOSTNAME="--hostname-override=192.168.197.11"
# k8s master API
14 KUBELET_API_SERVER="--api-servers=http://192.168.197.10:8080"
[root@localhost kubernetes]# service kube-proxy restart
Redirecting to /bin/systemctl restart kube-proxy.service
[root@localhost kubernetes]# service kubelet restart
Redirecting to /bin/systemctl restart kubelet.service
[root@localhost kubernetes]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@localhost kubernetes]# etcdctl member list
8e9e05c52164694d: name=default peerURLs=http://localhost:2380 clientURLs=http://192.168.197.10:2379 isLeader=true
[root@localhost kubernetes]# etcdctl cluster-health
member 8e9e05c52164694d is healthy: got healthy result from http://192.168.197.10:2379
cluster is healthy
[root@localhost kubernetes]# etcdctl get /atomic.io/network/config
Error: 100: Key not found (/atomic.io) [5290]
[root@localhost kubernetes]# etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'
{"Network":"172.17.0.0/16"}
[root@localhost kubernetes]# etcdctl get /atomic.io/network/config
{"Network":"172.17.0.0/16"}
[root@localhost kubernetes]# vim /etc/sysconfig/flanneld
# 指定etcd
4 FLANNEL_ETCD_ENDPOINTS="http://192.168.197.10:2379"
# 在启动服务
[root@localhost kubernetes]# service flanneld restart
Redirecting to /bin/systemctl restart flanneld.service
此时主机网卡出现flannel0
查看子网
[root@localhost kubernetes]# etcdctl ls /atomic.io/network/subnets
/atomic.io/network/subnets/172.17.28.0-24
/atomic.io/network/subnets/172.17.94.0-24
Node节点重启docker服务
[root@localhost kubernetes]# service docker restart
Redirecting to /bin/systemctl restart docker.service
注:如果网络不通,让iptables打开forward
[root@localhost kubernetes]# iptables -P FORWARD ACCEPT
[root@localhost kubernetes]# kubectl get nodes
NAME STATUS AGE
192.168.197.11 Ready 1h
回到目录