XXX系统部署总结

1.涉及技术及中间件

OpenResty

docker容器

k8s容器编排

keepalived

haproxy

mongodb

minio

ELK

openresty(基于 [Nginx](http://openresty.org/cn/nginx.html) 与 Lua 的高性能 Web 平台)

redis

nginx
2.安装方式

#所有k8s集群节点均安装基础组件docker容器

#k8s集群三主多从部署,三主通过keepalived、haproxy做高可用,从节点通过连接keepalived的虚拟ip跟主节点通讯

#redis三主三从集群部署在三台服务器

#mongodb一主一从一仲裁部署在三台服务器上

#nginx部署两台服务器
3.Docker
Docker的启动与停止
启动docker:sudo systemctl start docker
停止docker:sudo systemctl stop docker

重启docker:sudo systemctl restart docker

查看docker状态:sudo systemctl status docker

开机启动:sudo systemctl enable docker

查看docker概要信息:docker info

查看docker帮助文档:docker --help

\#删除exited状态的容器

##sudo docker rm $(sudo docker ps -qf status=exited)

#容器创建时指定docker重启通过参数--restart=always容器自动启动docker run --restart=always 如果创建时未指定 --restart=always ,可通过update 命令docker update --restart=always xxx

3、 批量操作容器

docker 启动所有的容器
docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)

docker 关闭所有的容器
docker stop $(docker ps -a | awk '{ print $1}' | tail -n +2)

docker 删除所有的容器
docker rm $(docker ps -a | awk '{ print $1}' | tail -n +2)

#删除所有镜像~~~~sudo docker rmi $(docker images -q)

kubectl

source <(kubectl completion bash) #命令补全
启动-停止-重启-状态

master

systemctl daemon-reload
systemctl start kube-apiserver
systemctl start kube-controller-manager
systemctl start kube-scheduler
etcd

systemctl start etcd
systemctl stop etcd
systemctl restart etcd
client

systemctl start kube-proxy -l
systemctl start docker -l
systemctl start kubelet -l
status

systemctl status etcd
systemctl status kube-apiserver -l
systemctl status kube-controller-manager -l
systemctl status kube-scheduler
systemctl status kube-proxy -l
systemctl status docker -l
systemctl status kubelet -l
常用命令

kubectl get pods
kubectl get rc
kubectl get service
kubectl get componentstatuses
kubectl get endpoints
kubectl cluster-info
kubectl create -f redis-master-controller.yaml
kubectl delete -f redis-master-controller.yaml
kubectl delete pod nginx-772ai
kubectl logs -f pods/heapster-xxxxx -n kube-system 
#查看日志
kubectl scale rc redis-slave --replicas=3 
#修改RC的副本数量,来实现Pod的动态缩放
etcdctl cluster-health 
#检查网络集群健康状态
etcdctl --endpoints=https://192.168.71.221:2379 cluster-health 
#带有安全认证检查网络集群健康状态
etcdctl member list
etcdctl set /k8s/network/config '{ "Network": "10.1.0.0/16" }'
etcdctl get /k8s/network/config
基础进阶

kubectl get services kubernetes-dashboard -n kube-system 
#查看所有service
kubectl get deployment kubernetes-dashboard -n kube-system 
#查看所有发布
kubectl get pods --all-namespaces 
#查看所有pod
kubectl get pods -o wide --all-namespaces #查看所有pod的IP及节点
kubectl get pods -n kube-system | grep dashboard
kubectl describe service/kubernetes-dashboard --namespace="kube-system"
kubectl describe pods/kubernetes-dashboard-349859023-g6q8c --namespace="kube-system" 
#指定类型查看
kubectl describe pod nginx-772ai 
#查看pod详细信息
kubectl scale rc nginx --replicas=5 
# 动态伸缩
kubectl scale deployment redis-slave --replicas=5 
#动态伸缩
kubectl scale --replicas=2 -f redis-slave-deployment.yaml 
#动态伸缩
kubectl exec -it redis-master-1033017107-q47hh /bin/bash 
#进入容器
kubectl label nodes node1 zone=north 
#增加节点lable值 spec.nodeSelector: zone: north #指定pod在哪个节点
kubectl get nodes -lzone 
#获取zone的节点
kubectl label pod redis-master-1033017107-q47hh role=master 
#增加lable值 [key]=[value]
kubectl label pod redis-master-1033017107-q47hh role- 
#删除lable值
kubectl label pod redis-master-1033017107-q47hh role=backend --overwrite 
#修改lable值
kubectl rolling-update redis-master -f redis-master-controller-v2.yaml 
#配置文件滚动升级
kubectl rolling-update redis-master --image=redis-master:2.0 
#命令升级
kubectl rolling-update redis-master --image=redis-master:1.0 --rollback 
#pod版本回滚
 

你可能感兴趣的:(系统架构)