公众号关注 「SY技术小站」
设为「星标」,每天带你分享技术与生活!
介绍
在之前的文章我介绍了下 Custom Metric 怎么实现自动扩容的。k8s基于自定义指标实现自动扩容
实际上Kubernetes定义了三种不同的监控数据接口,分别是Resource Metric
,Custom Metric
以及External Metric
。
一般来说Resource Metric
是通过metrics-server采集;
Custom Metric
是通过prometheus来实现自定义扩容。
External Metric
就是针对云场景的了,比方说通过获取slb最大连接数来实现自动扩容。
下面我来说下具体怎么实现的。
部署
安装alibaba-cloud-metrics-adapter,以下是yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: alibaba-cloud-metrics-adapter
name: alibaba-cloud-metrics-adapter
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: alibaba-cloud-metrics-adapter
template:
metadata:
labels:
app: alibaba-cloud-metrics-adapter
name: alibaba-cloud-metrics-adapter
spec:
serviceAccountName: admin
containers:
- name: alibaba-cloud-metrics-adapter
image: registry.cn-beijing.aliyuncs.com/acs/alibaba-cloud-metrics-adapter-amd64:v0.2.0-alpha-e8f8c17f
imagePullPolicy: IfNotPresent
ports:
- containerPort: 443
name: https
- containerPort: 8080
name: http
volumeMounts:
- mountPath: /tmp
name: temp-vol
- name: tz-config
mountPath: /etc/localtime
readOnly: true
volumes:
- name: temp-vol
emptyDir: {}
- name: tz-config
hostPath:
path: /etc/localtime
---
apiVersion: v1
kind: Service
metadata:
name: alibaba-cloud-met