您当前的位置:钢材 > 型钢 > 市场分析

弹性伸缩模式有哪几类,弹性伸缩服务将根据预设规则自动调整伸缩组内的

来源:头条 作者: chanong
分享到
关注德勤钢铁网在线:
  • 扫描二维码

    关注√

    德勤钢铁网微信

在线咨询:
  • 扫描或点击关注德勤钢铁网在线客服

git clone https://github.com/fluid-cloudnative/fluid.gitcd Fluid/chartskubectl create ns Fluid-systemhelm install Fluid Fluid3. 部署或配置Prometheus。在这里,Prometheus 收集AlluxioRuntime 的缓存引擎公开的指标。簇

$ cd Fluid$ kubectl apply -f Integration/prometheus/prometheus.yaml 如果集群中有prometheus,可以将以下配置写入prometheus 配置文件:

scrape_configs: - job_name:'alluxio运行时'metrics_path: /metrics/prometheus kubernetes_sd_configs: - role:端点relabel_configs: - source_labels: [__meta_kubernetes_service_label_monitor] regex: alluxio_run time_metrics操作33 3 60 保留- source_labels: [__meta_kubernetes_endpoint_port_name] regex: Web 操作: 保留- source_labels: [__meta_kubernetes_namespace] target_label: 命名空间替换: Pro 验证表示metheus安装成功

$ kubectl get ep -n kube-system prometheus-svcNAME 端点AGEprometheus-svc 10.76.0.2:9090 6m49s$ kubectl get svc -n kube-system prometheus-svcNAME TYPECLUSTER-IP 外部IP 端口AGEprometheus-svc NodePort 1 72.16.135.24 90 90:32114/TCP 2m7s 如果您想可视化监控指标,可以安装Grafana并查看监控数据,具体操作说明请参考文档。

5. 部署metrics服务器,检查你的集群是否包含metrics-server,运行kubectl top node,如果正确的输出显示内存和CPU,则说明你的集群metrics服务器配置正确。

Kubectl TOP NODENAME CPU(核心) CPU% 内存(字节) 内存% 192.168.1.204 93M 2% 1455MI 10% 192.168.1.205 125M 3% 1925MI 13% 192.168.1.206 96m

kubectl create -f Integration/metrics-server6.custom-metrics-api 部署组件要根据自定义指标进行扩展,需要两个组件。第一个组件从您的应用程序收集指标并将其存储在Prometheus 时间序列数据库中。第二个组件使用收集的指标扩展了Kubernetes 自定义指标API k8s-prometheus-adapter。第一个组件部署在第三步,第二个组件部署在:如果配置了custom-metrics-api,则将dataset相关的配置添加到adapter的configmap配置中。

apiVersion: v1kind: ConfigMapmetadata: name:adapter-config namespace:monitoringdata: config.yaml: | Rules: - seriesQuery: '{__name__=~'Cluster_(CapacityTotal|已使用容量)',fluid_runtime!='',instance!='',job='allux io 运行时',命名空间!='',pod!=''}' seriesFilters: - is: ^Cluster_(CapacityTotal|已用容量)$ resources: 覆盖: 命名空间: 资源: 命名空间pod: 资源: pods Fluid_runtime: 资源: 数据集名称:matches: '^( . *)'as:'capacity_used_rate'metricsQuery: ceil( Cluster_CapacityUsed{.LabelMatchers}*100/(Cluster_CapacityTotal{.LabelMatchers})) 否则手动运行以下命令

kubectl create -fintegration/custom-metrics-api/namespace.yamlkubectlcreate-fintegration/custom-metrics-api注意:custom-metrics-api连接的是集群中的Prometheous访问地址,因此将prometheous URL更改为请像这样更换它。您实际使用的是普罗米修斯地址。

检查您的自定义指标

$ kubectl get --raw '/apis/custom.metrics.k8s.io/v1beta1' | jq{ 'kind': 'APIResourceList', 'apiVersion': 'v1', 'groupVersion': 'custom.metrics.k8s. io/v1beta1', 'resources': [ { 'name': 'pods/capacity_used_rate', 'singularName': '', 'namespaced': true, 'kind': 'MetricValueList', 'verbs': [ 'get' ] }, { 'name': 'datasets.data.fluid.io/capacity_used_rate', 'singularName': '', 'namespaced': true, 'kind': 'MetricValueList', 'verbs': [ 'get' ] }, { 'name': 'namespaces/capacity_used_rate', 'singularName': '', 'namespaced': false, 'kind': 'MetricValueList', 'verbs': [ 'get' ] } ]} 7. 使用测试数据集

$ catdataset.yamlapiVersion: data.fluid.io/v1alpha1kind: Datasetmetadata: name: spakspec: mounts: - mountPoint: https://mirrors.bit.edu.cn/apache/spark/name: Spark---apiVersion: data.fluid.io/v1 al pha1kind33 360 AlluxioRuntime元数据:名称: Spark Spec:副本: 1-tier store: level: -mediudtype: mem path:/dev/shmquota: 1gi high:'0.99'low:'0.7'Properties: alluxio.user.streaming.data.timeout: 300seceof $ kubectl create kubectl 创建kubectl .data.flu id .io/spark 创建了8。检查该数据集是否可用。可以看到该数据集中的数据总量为2.71GiB。目前Fluid提供的缓存节点数量为1个,最大可提供的缓存容量为。 1GiB。目前数据量无法满足完整数据缓存的需求。

$ kubectl get datasetNAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGEspark 2.71GiB 0.00B 1.00GiB 0.0% Bound 7m38s9. 数据集可用后,检查是否可以从custom-metrics-api 获取监控指标。

kubectl get --raw '/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/datasets.data.fluid.io/*/capacity_used_rate' | jq{ 'kind': 'MetricValueList', 'apiVersion': 'custom.metrics.k8s.io/v1beta1', '元数据': { 'selfLink': '/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/datasets.data.fluid.io/%2A/Capacity_used_rate' }, 'items': [ { '描述对象': { '类型': '数据集', '命名空间': '默认', '名称': 'Spark', 'apiVersion': 'data.fluid .io/v1alpha1' }, 'metricName': 'capacity_used_rate', 'timestamp': '2021-04-04T07:24:52Z', 'value': '0' } ]}10、创建HPA任务

$ cat hpa.yamlapiVersion: autoscaling/v2beta2kind: HorizontalPodAutoscalermetadata: name: spakspec:scaleTargetRef: apiVersion: data.fluid.io/v1alpha1 kind: AlluxioRuntime name: Spark minReplicas3336 0 1 maxReplica s33 360 4 Metrics: - Type: 对象object: metric: name:Capacity_used_rate descriptionObject: apiVersion: data.fluid.io/v1alpha1 kind: 数据集名称: Spark target: type: Value value: '90'behavior:scaleUp:policy: - type: Pods value: 2 periodSeconds: 600scaleDown: selectPolicy: DisabledEOF 首先,让我们解释一下示例配置。这里有两个主要部分。一是伸缩规则。另一件事是膨胀和收缩的敏感性:

规则:触发扩容行为的条件为Dataset对象中缓存数据量为总缓存容量的90%,扩容对象为AlluxioRuntime,最小副本数为1,最大副本数为2. 4;Dataset和AlluxioRuntime对象必须位于同一命名空间中。策略:从K8s 1.18版本开始,可以针对扩缩场景分别设置稳定时间和一次性扩缩步长比例。例如,本例中扩容周期为10分钟(periodSeconds),扩容过程中新增两个副本。当然,这不能超过maxReplicas 限制。膨胀完成后的冷却时间(stabilizationWindowSeconds)为20。分钟,可以直接终止减持策略。 11. 检查HPA 配置。缓存区域的当前数据速率为0。远低于会导致扩张的条件

$ kubectl get hpaNAME REFERENCETARGETS MINPODS MAXPODS REPLICAS AGEspark AlluxioRuntime/spark 0/90 1 4 1 33s$ kubectl description hpaName: sparNamespace: defaultLabels: Annotations: CreationTimestamp: Wed, 07 Apr 2021 17 33 3 6036:39 +0800Reference: AlluxioRuntime/sparkMetrics:(当前/目标)数据集“capacity_used_rate” Spark(目标值) : 0/90 最小副本数: 1 最大副本数: 4 操作: 扩展: 稳定窗口: 0 秒策略选择: 最大策略: -Type : Pod 值: 2 周期: 0 600 秒规模向下: 选择策略: 禁用策略: - 类型: 百分比: 100 持续时间: 15 秒AlluxioRuntime Pod : 1 当前/1desiredConditions: 类型状态原因消息---- ------ ------ --- -- -- AbleToScale True ScaleDownStabilized 最近的建议高于当前建议,应用最近的最高建议ScalingActive True ValidMetricHPA Found 已成功根据数据集指标计算副本计数Capacity_used_rate ScalingLimited False DesiredWithinRange 所需的数量在可接受的范围内Events: 12. 创建数据预热任务

$ cat dataload.yamlapiVersion: data.fluid.io/v1alpha1kind: DataLoadmetadata: name: spakspec: dataset: name: spar namespace:defaultEOF$ kubectl create -f dataload.yaml$ kubectl get dataloadNAME DATASET PHASEAGE DURATIONspark spar 运行1 5s Un 13.此时,缓存的数据已接近Fluid可以提供的缓存容量(1GiB)还可以触发灵活的扩展条件。

$ kubectl get datasetNAME UFS TOTAL SIZE CACHEDCACHE CAPACITY CACHED PERCENTAGE PHASE AGEspark 2.71GiB 1020.92MiB 1.00GiB 36.8% Bound 5m15s 从HPA 监控中我们可以看到Alluxio Runtime 扩容已经开始,扩容步长为2 。

$ kubectl get hpaNAME REFERENCETARGETS MINPODS MAXPODS REPLICAS AGEspark AlluxioRuntime/spark 100/90 1 4 2 4m20s$ kubectl 描述hpaName: sparNamespace: defaultLabels: Annotations: CreationTimestamp: 202 年4 月7 日星期三1 17 :56:31 +0800Reference: AlluxioRuntime/sparkMetrics:(当前/目标)数据集/Spark'capacity_used_rate ' (目标值): 100/90Min 副本数: 1Max 副本数: 4Behavior: 纵向扩展: 稳定窗口: 0 秒选择策略: 最大策略: - 类型: Pods 值: 2 周期: 600 秒缩减: 选择策略: 已禁用策略: - 类型: 百分比值: 100 持续时间: 15 秒AlluxioRuntime Pod : 当前2/所需3 : 类型Status ReasonMessage ---- ------ ------------- AbleToScale True SucceededRescale HPA 控制器能够更新目标规模为3 ScalingActive True ValidMetricFound HPA 能够成功更新从数据集度量计算副本数量Capacity_used_rate ScalingLimited False DesiredWithinRange 所需数量在可接受范围内Events: 类型原因消息年龄- --- ----- - ---- ---- ------- 正常成功Rescale 21s Horizontal-pod-autoscaler new size: 2;reason: 数据集指标Capacity_used_rate 超过target 。正常成功Rescale 6shhorizontal-pod-autoscaler 新size: 3;reason: 数据集指标Capacity_used_rate 超过target14。等待一定时间后,判断缓存空间不足。数据集容量从1 GiB 增加到1 GiB。 3 GiB,数据缓存基本完成

$ kubectl get datasetNAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGEspark 2.71GiB 2.59GiB 3.00GiB 95.6% Bound 12m 同时观察HPA状态,目前Dataset对应的运行时副本数量为3,为未使用,缓存空间占用百分比Capacity_used_rate为85%,不会触发进一步的缓存扩容。

$ kubectl get hpaNAME REFERENCETARGETS MIPODS MAXPODS REPLICAS AGEspark AlluxioRuntime/spark 85/90 1 4 3 11m16. 清理环境

kubectl delete hpa Spark kubectl delete dataset Spark 概述Fluid 结合了Prometheous、Kubernetes HPA 和自定义指标,提供了基于缓存空间占用情况触发自动弹性伸缩以及按需使用缓存功能的功能,使之成为可能。这样可以让用户更灵活地使用分布式缓存,提高数据访问加速能力,未来还包括定时伸缩能力,可以更可靠地扩展和收缩容量,我们计划提供。作者| 车阳流体社区提交人作者| 谢远东流体社区提交人本文为阿里云原创内容,未经许可不得转载。

责任编辑:德勤钢铁网 标签:

热门搜索

相关文章

广告
德勤钢铁网 |市场分析

弹性伸缩模式有哪几类,弹性伸缩服务将根据预设规则自动调整伸缩组内的

chanong

|

git clone https://github.com/fluid-cloudnative/fluid.gitcd Fluid/chartskubectl create ns Fluid-systemhelm install Fluid Fluid3. 部署或配置Prometheus。在这里,Prometheus 收集AlluxioRuntime 的缓存引擎公开的指标。簇

$ cd Fluid$ kubectl apply -f Integration/prometheus/prometheus.yaml 如果集群中有prometheus,可以将以下配置写入prometheus 配置文件:

scrape_configs: - job_name:'alluxio运行时'metrics_path: /metrics/prometheus kubernetes_sd_configs: - role:端点relabel_configs: - source_labels: [__meta_kubernetes_service_label_monitor] regex: alluxio_run time_metrics操作33 3 60 保留- source_labels: [__meta_kubernetes_endpoint_port_name] regex: Web 操作: 保留- source_labels: [__meta_kubernetes_namespace] target_label: 命名空间替换: Pro 验证表示metheus安装成功

$ kubectl get ep -n kube-system prometheus-svcNAME 端点AGEprometheus-svc 10.76.0.2:9090 6m49s$ kubectl get svc -n kube-system prometheus-svcNAME TYPECLUSTER-IP 外部IP 端口AGEprometheus-svc NodePort 1 72.16.135.24 90 90:32114/TCP 2m7s 如果您想可视化监控指标,可以安装Grafana并查看监控数据,具体操作说明请参考文档。

5. 部署metrics服务器,检查你的集群是否包含metrics-server,运行kubectl top node,如果正确的输出显示内存和CPU,则说明你的集群metrics服务器配置正确。

Kubectl TOP NODENAME CPU(核心) CPU% 内存(字节) 内存% 192.168.1.204 93M 2% 1455MI 10% 192.168.1.205 125M 3% 1925MI 13% 192.168.1.206 96m

kubectl create -f Integration/metrics-server6.custom-metrics-api 部署组件要根据自定义指标进行扩展,需要两个组件。第一个组件从您的应用程序收集指标并将其存储在Prometheus 时间序列数据库中。第二个组件使用收集的指标扩展了Kubernetes 自定义指标API k8s-prometheus-adapter。第一个组件部署在第三步,第二个组件部署在:如果配置了custom-metrics-api,则将dataset相关的配置添加到adapter的configmap配置中。

apiVersion: v1kind: ConfigMapmetadata: name:adapter-config namespace:monitoringdata: config.yaml: | Rules: - seriesQuery: '{__name__=~'Cluster_(CapacityTotal|已使用容量)',fluid_runtime!='',instance!='',job='allux io 运行时',命名空间!='',pod!=''}' seriesFilters: - is: ^Cluster_(CapacityTotal|已用容量)$ resources: 覆盖: 命名空间: 资源: 命名空间pod: 资源: pods Fluid_runtime: 资源: 数据集名称:matches: '^( . *)'as:'capacity_used_rate'metricsQuery: ceil( Cluster_CapacityUsed{.LabelMatchers}*100/(Cluster_CapacityTotal{.LabelMatchers})) 否则手动运行以下命令

kubectl create -fintegration/custom-metrics-api/namespace.yamlkubectlcreate-fintegration/custom-metrics-api注意:custom-metrics-api连接的是集群中的Prometheous访问地址,因此将prometheous URL更改为请像这样更换它。您实际使用的是普罗米修斯地址。

检查您的自定义指标

$ kubectl get --raw '/apis/custom.metrics.k8s.io/v1beta1' | jq{ 'kind': 'APIResourceList', 'apiVersion': 'v1', 'groupVersion': 'custom.metrics.k8s. io/v1beta1', 'resources': [ { 'name': 'pods/capacity_used_rate', 'singularName': '', 'namespaced': true, 'kind': 'MetricValueList', 'verbs': [ 'get' ] }, { 'name': 'datasets.data.fluid.io/capacity_used_rate', 'singularName': '', 'namespaced': true, 'kind': 'MetricValueList', 'verbs': [ 'get' ] }, { 'name': 'namespaces/capacity_used_rate', 'singularName': '', 'namespaced': false, 'kind': 'MetricValueList', 'verbs': [ 'get' ] } ]} 7. 使用测试数据集

$ catdataset.yamlapiVersion: data.fluid.io/v1alpha1kind: Datasetmetadata: name: spakspec: mounts: - mountPoint: https://mirrors.bit.edu.cn/apache/spark/name: Spark---apiVersion: data.fluid.io/v1 al pha1kind33 360 AlluxioRuntime元数据:名称: Spark Spec:副本: 1-tier store: level: -mediudtype: mem path:/dev/shmquota: 1gi high:'0.99'low:'0.7'Properties: alluxio.user.streaming.data.timeout: 300seceof $ kubectl create kubectl 创建kubectl .data.flu id .io/spark 创建了8。检查该数据集是否可用。可以看到该数据集中的数据总量为2.71GiB。目前Fluid提供的缓存节点数量为1个,最大可提供的缓存容量为。 1GiB。目前数据量无法满足完整数据缓存的需求。

$ kubectl get datasetNAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGEspark 2.71GiB 0.00B 1.00GiB 0.0% Bound 7m38s9. 数据集可用后,检查是否可以从custom-metrics-api 获取监控指标。

kubectl get --raw '/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/datasets.data.fluid.io/*/capacity_used_rate' | jq{ 'kind': 'MetricValueList', 'apiVersion': 'custom.metrics.k8s.io/v1beta1', '元数据': { 'selfLink': '/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/datasets.data.fluid.io/%2A/Capacity_used_rate' }, 'items': [ { '描述对象': { '类型': '数据集', '命名空间': '默认', '名称': 'Spark', 'apiVersion': 'data.fluid .io/v1alpha1' }, 'metricName': 'capacity_used_rate', 'timestamp': '2021-04-04T07:24:52Z', 'value': '0' } ]}10、创建HPA任务

$ cat hpa.yamlapiVersion: autoscaling/v2beta2kind: HorizontalPodAutoscalermetadata: name: spakspec:scaleTargetRef: apiVersion: data.fluid.io/v1alpha1 kind: AlluxioRuntime name: Spark minReplicas3336 0 1 maxReplica s33 360 4 Metrics: - Type: 对象object: metric: name:Capacity_used_rate descriptionObject: apiVersion: data.fluid.io/v1alpha1 kind: 数据集名称: Spark target: type: Value value: '90'behavior:scaleUp:policy: - type: Pods value: 2 periodSeconds: 600scaleDown: selectPolicy: DisabledEOF 首先,让我们解释一下示例配置。这里有两个主要部分。一是伸缩规则。另一件事是膨胀和收缩的敏感性:

规则:触发扩容行为的条件为Dataset对象中缓存数据量为总缓存容量的90%,扩容对象为AlluxioRuntime,最小副本数为1,最大副本数为2. 4;Dataset和AlluxioRuntime对象必须位于同一命名空间中。策略:从K8s 1.18版本开始,可以针对扩缩场景分别设置稳定时间和一次性扩缩步长比例。例如,本例中扩容周期为10分钟(periodSeconds),扩容过程中新增两个副本。当然,这不能超过maxReplicas 限制。膨胀完成后的冷却时间(stabilizationWindowSeconds)为20。分钟,可以直接终止减持策略。 11. 检查HPA 配置。缓存区域的当前数据速率为0。远低于会导致扩张的条件

$ kubectl get hpaNAME REFERENCETARGETS MINPODS MAXPODS REPLICAS AGEspark AlluxioRuntime/spark 0/90 1 4 1 33s$ kubectl description hpaName: sparNamespace: defaultLabels: Annotations: CreationTimestamp: Wed, 07 Apr 2021 17 33 3 6036:39 +0800Reference: AlluxioRuntime/sparkMetrics:(当前/目标)数据集“capacity_used_rate” Spark(目标值) : 0/90 最小副本数: 1 最大副本数: 4 操作: 扩展: 稳定窗口: 0 秒策略选择: 最大策略: -Type : Pod 值: 2 周期: 0 600 秒规模向下: 选择策略: 禁用策略: - 类型: 百分比: 100 持续时间: 15 秒AlluxioRuntime Pod : 1 当前/1desiredConditions: 类型状态原因消息---- ------ ------ --- -- -- AbleToScale True ScaleDownStabilized 最近的建议高于当前建议,应用最近的最高建议ScalingActive True ValidMetricHPA Found 已成功根据数据集指标计算副本计数Capacity_used_rate ScalingLimited False DesiredWithinRange 所需的数量在可接受的范围内Events: 12. 创建数据预热任务

$ cat dataload.yamlapiVersion: data.fluid.io/v1alpha1kind: DataLoadmetadata: name: spakspec: dataset: name: spar namespace:defaultEOF$ kubectl create -f dataload.yaml$ kubectl get dataloadNAME DATASET PHASEAGE DURATIONspark spar 运行1 5s Un 13.此时,缓存的数据已接近Fluid可以提供的缓存容量(1GiB)还可以触发灵活的扩展条件。

$ kubectl get datasetNAME UFS TOTAL SIZE CACHEDCACHE CAPACITY CACHED PERCENTAGE PHASE AGEspark 2.71GiB 1020.92MiB 1.00GiB 36.8% Bound 5m15s 从HPA 监控中我们可以看到Alluxio Runtime 扩容已经开始,扩容步长为2 。

$ kubectl get hpaNAME REFERENCETARGETS MINPODS MAXPODS REPLICAS AGEspark AlluxioRuntime/spark 100/90 1 4 2 4m20s$ kubectl 描述hpaName: sparNamespace: defaultLabels: Annotations: CreationTimestamp: 202 年4 月7 日星期三1 17 :56:31 +0800Reference: AlluxioRuntime/sparkMetrics:(当前/目标)数据集/Spark'capacity_used_rate ' (目标值): 100/90Min 副本数: 1Max 副本数: 4Behavior: 纵向扩展: 稳定窗口: 0 秒选择策略: 最大策略: - 类型: Pods 值: 2 周期: 600 秒缩减: 选择策略: 已禁用策略: - 类型: 百分比值: 100 持续时间: 15 秒AlluxioRuntime Pod : 当前2/所需3 : 类型Status ReasonMessage ---- ------ ------------- AbleToScale True SucceededRescale HPA 控制器能够更新目标规模为3 ScalingActive True ValidMetricFound HPA 能够成功更新从数据集度量计算副本数量Capacity_used_rate ScalingLimited False DesiredWithinRange 所需数量在可接受范围内Events: 类型原因消息年龄- --- ----- - ---- ---- ------- 正常成功Rescale 21s Horizontal-pod-autoscaler new size: 2;reason: 数据集指标Capacity_used_rate 超过target 。正常成功Rescale 6shhorizontal-pod-autoscaler 新size: 3;reason: 数据集指标Capacity_used_rate 超过target14。等待一定时间后,判断缓存空间不足。数据集容量从1 GiB 增加到1 GiB。 3 GiB,数据缓存基本完成

$ kubectl get datasetNAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGEspark 2.71GiB 2.59GiB 3.00GiB 95.6% Bound 12m 同时观察HPA状态,目前Dataset对应的运行时副本数量为3,为未使用,缓存空间占用百分比Capacity_used_rate为85%,不会触发进一步的缓存扩容。

$ kubectl get hpaNAME REFERENCETARGETS MIPODS MAXPODS REPLICAS AGEspark AlluxioRuntime/spark 85/90 1 4 3 11m16. 清理环境

kubectl delete hpa Spark kubectl delete dataset Spark 概述Fluid 结合了Prometheous、Kubernetes HPA 和自定义指标,提供了基于缓存空间占用情况触发自动弹性伸缩以及按需使用缓存功能的功能,使之成为可能。这样可以让用户更灵活地使用分布式缓存,提高数据访问加速能力,未来还包括定时伸缩能力,可以更可靠地扩展和收缩容量,我们计划提供。作者| 车阳流体社区提交人作者| 谢远东流体社区提交人本文为阿里云原创内容,未经许可不得转载。


市场分析