- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在修改使用 HorizontalPodAutoscaler (HPA) 自动缩放的部署。此部署是管道的一部分,在该管道中,工作人员从 pubsub 订阅中读取消息,执行一些工作并发布到下一个主题。现在我使用 configmap 来定义部署的管道(configmap 包含输入订阅和输出主题)。 HPA 根据输入订阅上的消息数自动缩放。如果可能,我希望能够从 configmap 中提取 HPA 的订阅名称?有没有办法做到这一点?
示例 HPA:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: my-deployment-hpa
namespace: default
labels:
name: my-deployment-hpa
spec:
minReplicas: 1
maxReplicas: 10
metrics:
- external:
metricName: pubsub.googleapis.com|subscription|num_undelivered_messages
metricSelector:
matchLabels:
resource.labels.subscription_id: "$INPUT_SUBSCRIPTION"
targetAverageValue: "2"
type: External
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-deployment
当前来自 HPA 的值
$INPUT_SUBSCRIPTION
理想情况下可以来自配置映射。
最佳答案
将此答案发布为社区 wiki 以获得更好的可见性,并在评论中提供了答案。
回答帖子中的问题:
I would like to be able to pull the subscription name for the HPA from a configmap if possible? Is there a way to do this?
HPA
使用的指标。与
ConfigMap
:
Unfortunately, you cannot.. but you can using prometheus-adapter + HPA . Check this tuto: itnext.io/...
configMap
中提取所需的指标名称并使用模板替换和应用新的
HPA
.
configMap
像:
apiVersion: v1
kind: ConfigMap
metadata:
name: example
data:
metric_name: "new_awesome_metric" # <-
not_needed: "only for example"
和以下脚本:
#!/bin/bash
# variables
hpa_file_name="hpa.yaml"
configmap_name="example"
string_to_replace="PLACEHOLDER"
# extract the metric name used in a configmap
new_metric=$(kubectl get configmap $configmap_name -o json | jq '.data.metric_name')
# use the template to replace the $string_to_replace with your $new_metric and apply it
sed "s/$string_to_replace/$new_metric/g" $hpa_file_name | kubectl apply -f -
This script will need to have a
hpa.yaml
with the template to apply it as resource (example from question could be used with a change:
resource.labels.subscription_id: PLACEHOLDER
Cloud.google.com: Kubernetes Engine: Tutorials: Autoscaling-metrics: PubSub
关于kubernetes - 是否可以从 configmap 为 HorizontalPodAutoscaler 设置外部指标的名称? GKE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62851002/
我有标准 GKE 集群,并且希望将所有正在运行的服务迁移到新的 Autopilot 集群。我研究了官方文档,但没有找到任何如何执行此迁移的信息 最佳答案 目前,此操作无法将 Standard GKE
我最近设置了一个 GKE 自动驾驶仪,但意识到它不支持 cert-manager 所依赖的 webhook。我们必须向 GKE 自动驾驶集群添加/管理 SSL 证书的其他选项是什么? 最佳答案 截至
我在 K8s 1.14.10 上创建了两个单独的 GKE 集群。 VPN access to in-house network not working after GKE cluster upgrad
我注意到我们的 gke 集群系统 pod (gke-metrics-agent) 内存不足。我试图编辑 daemonset yaml 文件以将内存请求增加到 200Mi 并将内存限制增加到 200Mi
我有多个在 GKE 上运行的 kubernetes 集群(假设是 clusterA 和 clusterB) 我想在其中一个集群中运行的应用程序中从 client-go 访问这两个集群(例如,从在 cl
如何将已有的GKE集群改成GKE私有(private)集群?我是否能够根据防火墙规则从 Internet 连接到 Kubectl API,或者我应该有一个堡垒主机吗?我不想实现 Cloud Nat 或
我目前正在运行一个区域性 GKE 集群,并希望迁移到一个新的区域性集群。旧集群有一个带有公共(public) IP 的入口对象,使用谷歌托管证书来终止 HTTPS。 我的迁移计划是: 创建新的区域集群
我们有一个 GKE 集群: 版本为 1.6.13-gke.0 的主节点 2 个版本为 1.6.11-gke.0 的节点池 我们已激活 Stackdriver Monitoring 和 Logging。
从昨天开始,我在 K8s 上遇到了一个奇怪的错误(使用 GKE) 我有一个运行 1 个 pod 的部署。我删除了部署,它用于终止 pod 和使用它的副本集。 但是现在,如果我删除部署,副本集不会被删除
我正在使用 Google 容器引擎。现在我想要在我的集群中使用自动缩放功能。根据文档 GKE 自动调节程序 在 测试版 .我还可以在 中启用自动缩放实例组即管理集群节点。 集群自动缩放器添加/删除节点
我想在Google容器引擎中运行nexus3。 我创建了一个永久磁盘,并配置了以下部署文件: apiVersion: apps/v1beta1 kind: Deployment metadata:
我正在寻找从 kubernetes 中的 pod 捕获日志以用于两个用例: 实时 -> 我正在使用 kubectl logs ---现在 非实时 -> 使用 stackdriver用管道传送到 big
我已经在Google云中创建了具有以下规范的节点端口服务...我创建了防火墙规则,以允许端口'30100'的流量从0.0.0.0/0开始,我已经验证了堆栈驱动程序日志,并且在发生流量时我使用curl或
我注意到我在GKE上部署的服务有些奇怪,我想了解... 当我启动kubectl get services时,我可以看到我的服务EXTRNAL-IP。假设35.189.192.88。那就是我用来访问我的
我最近在优化集群 (GKE) 利用率,两天前我注意到我的节点没有扩大或缩小。自动缩放配置映射处于初始化模式: kubectl describe -n kube-system configmap clu
目前,我可以从GoogleCloudPlatform管理控制台屏幕上获取各种信息,但是将来我希望使用API来获取信息。 获得的信息如下。 Kubernetes Engine>Clusters>Cl
我正在尝试在 GKE 上设置我的应用程序并使用内部负载均衡器进行公共(public)访问。我能够毫无问题地部署集群/负载均衡器服务,但是当我尝试访问负载均衡器的外部 IP 地址时,我得到连接被拒绝,我
默认情况下,可从同一集群访问ClusterIP类型的Kubernetes服务。是否可以将GKE中的服务配置为可从同一VPC访问?例如,同一VPC中的GCE VM可以访问GKE中的服务,但我不想将其公开
GKE 使用 kubenet用于在 VPC 中设置容器接口(interface)和配置路由的网络插件,以便容器可以在不同主机上相互访问。 维基百科定义了一个 overlay作为建立在另一个网络之上的计
首先对于我的问题,我需要谈谈我的环境: Google 基本设置:1x f1-micro 实例,3 个节点 Kubernetes 设置:nginx-ingress-controller、cert-man
我是一名优秀的程序员,十分优秀!