- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
按照 google 为在 Google Kubernetes Engine 中部署 HPA 所做的指南:https://cloud.google.com/kubernetes-engine/docs/tutorials/autoscaling-metrics
并添加正确的权限,因为我在本指南中使用了 Workload Identity:https://github.com/GoogleCloudPlatform/k8s-stackdriver/tree/master/custom-metrics-stackdriver-adapter
并且还添加了这里评论的防火墙规则:https://github.com/kubernetes-sigs/prometheus-adapter/issues/134
我被困在 HPA 向我返回此错误的地方:
kubectl describe hpa -n test-namespace
Name: my-hpa
Namespace: test-namespace
Labels: <none>
Annotations: <none>
CreationTimestamp: Tue, 13 Apr 2021 12:47:56 +0200
Reference: StatefulSet/my-set
Metrics: ( current / target )
"my-metric" on pods: <unknown> / 1
Min replicas: 1
Max replicas: 60
StatefulSet pods: 1 current / 0 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetPodsMetric the HPA was unable to compute the replica count: unable to get metric my-metric: no metrics returned from custom metrics API
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedGetPodsMetric 8m26s (x40 over 18m) horizontal-pod-autoscaler unable to get metric my-metric: no metrics returned from custom metrics API
Warning FailedComputeMetricsReplicas 3m26s (x53 over 18m) horizontal-pod-autoscaler failed to compute desired number of replicas based on listed metrics for StatefulSet/test-namespace/my-set: invalid metrics (1 invalid out of 1), first error is: failed to get pods metric value: unable to get metric my-metric: no metrics returned from custom metrics API
但 apiservices 是真实的,
kubectl get apiservices
NAME SERVICE AVAILABLE AGE
...
v1beta1.custom.metrics.k8s.io custom-metrics/custom-metrics-stackdriver-adapter True 24h
v1beta1.external.metrics.k8s.io custom-metrics/custom-metrics-stackdriver-adapter True 24h
v1beta2.custom.metrics.k8s.io custom-metrics/custom-metrics-stackdriver-adapter True 24h
...
当我尝试检索指标数据时,它返回正常,
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta2/namespaces/test-namespace/pods/*/my-metric" | jq .
{
"kind": "MetricValueList",
"apiVersion": "custom.metrics.k8s.io/v1beta2",
"metadata": {
"selfLink": "/apis/custom.metrics.k8s.io/v1beta2/namespaces/test-namespace/pods/%2A/my-metric"
},
"items": [
{
"describedObject": {
"kind": "Pod",
"namespace": "test-namespace",
"name": "my-metrics-api-XXXX",
"apiVersion": "/__internal"
},
"metric": {
"name": "my-metric",
"selector": null
},
"timestamp": "2021-04-13T11:15:30Z",
"value": "5"
}
]
}
但是堆栈驱动程序给了我这个错误:
2021-04-13T11:01:30.432634Z apiserver was unable to write a JSON response: http2: stream closed
2021-04-13T11:01:30.432679Z apiserver received an error that is not an metav1.Status: &errors.errorString{s:"http2: stream closed"}
我不得不像这样配置谷歌提供的适配器:
apiVersion: v1
kind: Namespace
metadata:
name: custom-metrics
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: custom-metrics:system:auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: custom-metrics-auth-reader
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: custom-metrics-resource-reader
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- kind: ServiceAccount
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
labels:
run: custom-metrics-stackdriver-adapter
k8s-app: custom-metrics-stackdriver-adapter
spec:
replicas: 1
selector:
matchLabels:
run: custom-metrics-stackdriver-adapter
k8s-app: custom-metrics-stackdriver-adapter
template:
metadata:
labels:
run: custom-metrics-stackdriver-adapter
k8s-app: custom-metrics-stackdriver-adapter
kubernetes.io/cluster-service: "true"
spec:
serviceAccountName: custom-metrics-stackdriver-adapter
containers:
- image: gcr.io/gke-release/custom-metrics-stackdriver-adapter:v0.12.0-gke.0
imagePullPolicy: Always
name: pod-custom-metrics-stackdriver-adapter
command:
- /adapter
- --use-new-resource-model=true
- --cert-dir=/tmp
- --secure-port=4443
resources:
limits:
cpu: 250m
memory: 200Mi
requests:
cpu: 250m
memory: 200Mi
securityContext:
runAsNonRoot: true
runAsUser: 1000
---
apiVersion: v1
kind: Service
metadata:
labels:
run: custom-metrics-stackdriver-adapter
k8s-app: custom-metrics-stackdriver-adapter
kubernetes.io/cluster-service: 'true'
kubernetes.io/name: Adapter
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
spec:
ports:
- port: 443
protocol: TCP
targetPort: 4443
selector:
run: custom-metrics-stackdriver-adapter
k8s-app: custom-metrics-stackdriver-adapter
type: ClusterIP
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta1.custom.metrics.k8s.io
spec:
insecureSkipTLSVerify: true
group: custom.metrics.k8s.io
groupPriorityMinimum: 100
versionPriority: 100
service:
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
version: v1beta1
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta2.custom.metrics.k8s.io
spec:
insecureSkipTLSVerify: true
group: custom.metrics.k8s.io
groupPriorityMinimum: 100
versionPriority: 200
service:
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
version: v1beta2
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta1.external.metrics.k8s.io
spec:
insecureSkipTLSVerify: true
group: external.metrics.k8s.io
groupPriorityMinimum: 100
versionPriority: 100
service:
name: custom-metrics-stackdriver-adapter
namespace: custom-metrics
version: v1beta1
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: external-metrics-reader
rules:
- apiGroups:
- "external.metrics.k8s.io"
resources:
- "*"
verbs:
- list
- get
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: external-metrics-reader
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: external-metrics-reader
subjects:
- kind: ServiceAccount
name: horizontal-pod-autoscaler
namespace: kube-system
因为它禁用了端口 443,所以我不得不更改为 4443 并放置 --cert-dir=/tmp 选项,因为没有该选项,stackdriver 会返回错误:
"unable to run custom metrics adapter: error creating self-signed certificates: mkdir apiserver.local.config: permission denied"
我想我解释了我为配置它所做的所有步骤,但没有成功。有任何想法吗?
最佳答案
为我解决!
经过几次测试,在HPA yaml中更改,
来自 Pod
的度量至 External
,以及带有 custom.google.apis/my-metric
的度量名称, 有用!
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: my-hpa
namespace: test-namespace
spec:
maxReplicas: 60
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
name: my-set
metrics:
- type: External
external:
metric:
name: custom.googleapis.com|my-metric
target:
averageValue: 1
type: AverageValue
关于kubernetes - 在 GKE : apiserver was unable to write a JSON response: http2: stream closed 中扩展 HPA 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67073909/
此错误显然源于 xlsxwriter。我不确定它来自我的代码的哪一行,因为每次我尝试调试时,我的编辑器 Visual Studio 2019 都会崩溃。但是,在使用 VPN 和远程桌面连接时,我在笔记
我有一个用于原型(prototype)的游戏数据表。我在工作时生成数据,但当我离开并且我的机器进入休眠状态时,数据生成停止。这导致我的元素收藏出现很大差距。 我希望能够移动表格的 DateTimeCr
我正在使用wavesurfer在我的网页上显示歌曲波形。我正在使用以下代码 - function setupSongwaves(songJson) { var songwaveid = '#s
我是 JDBC 新手... Student类有Constructor、add()、update()和delete()等方法... 在构造函数中打开连接。下面代码中的 conn.close() 和 ps
考虑以下代码,它是许多 ChannelFactory 示例的典型代码: WSHttpBinding myBinding = new WSHttpBinding(); EndpointAddress m
我正在阅读 Java Data Access — JDBC、JNDI 和 JAXP,了解 Connection、PooledConnection 接口(interface)。据我了解, PooledC
我正在做我的第一个 android 学习教程,但遇到了标题描述的这个错误..这是我试图在 Eclipse 上做的应用程序,java,这是我的代码..(代码是自动生成的由项目) package com.
我正在使用 JPA、Hibernate、Jboss 和容器管理事务。当我尝试用数据保存我的大实体时,它会抛出以下异常。将我的实体视为图形模型。这个异常并不是每次都会抛出。 ERROR [org.jbo
我有 GWT 应用程序,它与 AdaptivePayment API 上的灯箱集成。 我无法使用提供的代码关闭取消/返回页面: dgFlow = top.dgFlow || top.opener.to
即使我已经实现了上述方法 close(),Eclipse 仍向我显示上述错误。 代码如下: public void update_project(View view) { EditText c
在我的网络应用程序中,我广泛使用了数据库。 我有一个抽象的 servlet,所有需要数据库连接的 servlet 都继承自它。该抽象 servlet 创建一个数据库连接,调用必须由继承 servlet
我在这里看到很多答案都说要使用 close() 来销毁套接字,但我使用的指南来自 msdn让我使用 closesocket()。我想知道是否存在差异,是否有理由使用其中一种。 在这两种情况下,我都看到
我在 python 中使用 with 语句( PEP 343 ) 时遇到了一些问题,以便在上下文之后自动管理资源清理。特别是,with 语句 始终假定资源清理方法是 .close()。 IE。在下面的
在本地连接上调用 RTCPeerConnection.close() 时,我希望远程连接接收到 closed connectionstatechange 事件。 相反,几秒钟后出现disconnect
我正在使用 netty 3.6.6。 有人可以解释以下两个代码之间的区别吗? channel.close(); channel.write(ChannelBuffers.EMPTY_BUFFER).a
WebSocket.readyState可以是CONNECTING、OPEN、CLOSING或CLOSED。 CLOSING 和 CLOSED 状态有什么区别?为什么区分这两种状态很有用?我可以将 C
想象一下,您在 Python 中打开了某个文件(无论是用于读取、写入还是其他)。我刚刚注意到,当您想关闭该文件时,您可以输入: somefile.close() 或者您可以输入: somefile.c
我在我的应用程序的各种类和线程中打开、访问、写入等数据库。我有一个数据库 self.run_params["db"] 我在整个应用程序中都使用它来访问。 问题 1:我是否应该在每次访问后关闭光标? 问
我正在尝试创建一个 vanilla JavaScript 模态,当从 HTML 文件(或 JS 文件)实例化它时,它具有由用户自定义的能力。但是,在处理关闭模式的 close() 函数时,不是一次关闭
所以这可能是一个菜鸟类型的问题,但这就是我想知道的。 假设我有两个屏幕,第一个屏幕是 idk,例如 Screen1。假设用户在 Screen1 上点击了OK,这会将他们带到Screen2。 我目前正在
我是一名优秀的程序员,十分优秀!