标签:compute erp 其他 spro 有序 上线 limits des seconds
dashboard.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# Keep the name in sync with image version and
# gce/coreos/kube-manifests/addons/dashboard counterparts
name: kubernetes-dashboard-latest
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
version: latest
kubernetes.io/cluster-service: "true"
spec:
nodeName: k8s-node1 ##注意,我这个是在node1上有镜像了
containers:
- name: kubernetes-dashboard
image: 10.0.0.11:5000/kubernetes-dashboard-amd64:v1.4.1
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
memory: 50Mi
requests:
cpu: 100m
memory: 50Mi
ports:
- containerPort: 9090
args:
- --apiserver-host=http://10.0.0.11:8080
livenessProbe:
httpGet:
path: /
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
dashboard-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: kubernetes-dashboard
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
spec:
selector:
k8s-app: kubernetes-dashboard
ports:
- port: 80
targetPort: 9090
界面的其他资源类型
daemonset 监控用, 会在所有节点都创建一个pod
petset 宠物应用 不能随便删,有数据 pod名有序 1.5改名为 stateful 有状态应用
rs,rc 畜生应用 随便删,无数据 pod名无序 srareless 无状态应用
job:备份job 一次性任务,每天就上线一次 备份
其他
服务和自动发现
svc:四层
ingress:七层
daemonset 类型资源的pod
和普通的类型其实类似 只是不能有副本数
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: nginx
spec:
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: 10.0.0.11:5000/nginx:1.13
ports:
- containerPort: 80
resources:
limits:
cpu: 100m
requests:
cpu: 100m
apiserver的反向代理
在使用svc的时候 type: NodePort 是通过地址转换来的 默认不写的情况下 使用的是cluster IP 这个类型是通过proxy反向的代理实现的
*修改url里的namespace和svc名字即可访问
反向代理访问
http://10.0.0.11:8080/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/
http://10.0.0.11:8080/api/v1/proxy/
namespaces/kube-system/ namespace名字
services/kubernetes-dashboard/ svc名
nodeport访问
就是svc映射
kubectl get all --all-namespace 查看所有namespace下的资源
cadvisor:采集数据 zabbix-agent
influxdb : 存储数据 mysql
grafana:画图
heapster: 分析数据 zabbix-server
1.导入镜像,并添加tag
[root@k8s-node1 ~]# ll
total 1564548
-rw-r--r-- 1 root root 275096576 Mar 2 17:33 docker_heapster_grafana.tar.gz
-rw-r--r-- 1 root root 260942336 Mar 2 17:35 docker_heapster_influxdb.tar.gz
-rw-r--r-- 1 root root 991839232 Mar 2 17:38 docker_heapster.tar.gz
-rw-r--r-- 1 root root 74210304 Feb 27 15:44 docker_k8s_dns.tar.gz
[root@k8s-node1 ~]# for n in $(ls) ;do docker load -i $n ; done
2.添加nodename后启动即可,此时在dashboard界面可以看到cpu负载等信息
说明:
influxdb和grafana起在了一个pod 所以他们的标签选择是一样的,,通过不同端口来访问服务就行
阿里云弹性伸缩 —》监控获得的数据 --》判断是否扩 缩容
创建一个deploy用于实验
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
minReadySeconds: 30
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: 10.0.0.11:5000/nginx:1.13
ports:
- containerPort: 80
resources:
limits:
cpu: 100m
requests:
cpu: 100m
添加弹性伸缩规则:--max 最大的pod数量 --min 最小的pod数量 --cpu的使用率
kubectl autoscale deploy nginx-deployment --max=8 --min=1 --cpu-percent=10
k8s弹性伸缩:HPA:horizontal-pod-autoscaler
阿里云弹性伸缩:ess
自动创建规则后会发现 pod只有一个了 因为负载太低了,没人访问
[root@k8s-master delop]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-2807576163-6q27j 1/1 Running 0 17m
[root@k8s-master delop]# kubectl describe hpa nginx
Name: nginx
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Mon, 02 Mar 2020 22:28:20 +0800
Reference: Deployment/nginx
Target CPU utilization: 5%
Current CPU utilization: 0%
Min replicas: 1
Max replicas: 10
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
3m 3m 3 {horizontal-pod-autoscaler } Normal DesiredReplicasComputed Computed the desired num of replicas: 0 (avgCPUutil: 0, current replicas: 3)
3m 3m 1 {horizontal-pod-autoscaler } Normal SuccessfulRescale New size: 1; reason: All metrics below target
3m 2s 8 {horizontal-pod-autoscaler } Normal DesiredReplicasComputed Computed the desired num of replicas: 0 (avgCPUutil: 0, current replicas: 1)
阿帕奇的压测组件
yum -y install httpd-tools
进行压力测试
ab -n 3000000 -c 30 http://10.0.0.12:30414/
进行300w次 每次30个请求
会发先pod从1个扩展为4个,停止压测后,一段时间降为1
标签:compute erp 其他 spro 有序 上线 limits des seconds
原文地址:https://www.cnblogs.com/hsgoose/p/12818452.html