- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们有一个Istio集群,我们正在尝试为Kubernetes配置水平容器自动缩放。我们希望将请求计数用作hpa的自定义指标。我们如何才能将Istio的Prometheus用于同一目的?
最佳答案
事实证明,这个问题比我预期的要复杂得多,但最后我得到了答案。
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: podinfo
spec:
replicas: 2
template:
metadata:
labels:
app: podinfo
annotations:
prometheus.io/scrape: 'true'
spec:
containers:
- name: podinfod
image: stefanprodan/podinfo:0.0.1
imagePullPolicy: Always
command:
- ./podinfo
- -port=9898
- -logtostderr=true
- -v=2
volumeMounts:
- name: metadata
mountPath: /etc/podinfod/metadata
readOnly: true
ports:
- containerPort: 9898
protocol: TCP
readinessProbe:
httpGet:
path: /readyz
port: 9898
initialDelaySeconds: 1
periodSeconds: 2
failureThreshold: 1
livenessProbe:
httpGet:
path: /healthz
port: 9898
initialDelaySeconds: 1
periodSeconds: 3
failureThreshold: 2
resources:
requests:
memory: "32Mi"
cpu: "1m"
limits:
memory: "256Mi"
cpu: "100m"
volumes:
- name: metadata
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
---
apiVersion: v1
kind: Service
metadata:
name: podinfo
labels:
app: podinfo
spec:
type: NodePort
ports:
- port: 9898
targetPort: 9898
nodePort: 31198
protocol: TCP
selector:
app: podinfo
annotations: prometheus.io/scrape: 'true'
。需要请求Prometheus从资源中读取指标。还要注意,还有两个附加注释,它们具有默认值。但是如果您在应用程序中更改了它们,则需要为它们添加正确的值:prometheus.io/path
:如果度量标准路径不是/ metrics,则使用此注释对其进行定义。 prometheus.io/port
:在指定的端口上刮除Pod,而不是Pod的声明端口(如果未声明,则默认为无端口目标)。 kubectl edit configmap -n istio-system prometheus
# pod's declared ports (default is a port-free target if none are declared).
- job_name: 'kubernetes-pods'
# if you want to use metrics on jobs, set the below field to
# true to prevent Prometheus from setting the `job` label
# automatically.
honor_labels: false
kubernetes_sd_configs:
- role: pod
# skip verification so you can do HTTPS to pods
tls_config:
insecure_skip_verify: true
# make sure your labels are in order
relabel_configs:
# these labels tell Prometheus to automatically attach source
# pod and namespace information to each collected sample, so
# that they'll be exposed in the custom metrics API automatically.
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod
# these labels tell Prometheus to look for
# prometheus.io/{scrape,path,port} annotations to configure
# how to scrape
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
<repository-directory>/deploy/manifests/custom-metrics-apiserver-deployment.yaml
中更改Prometheus服务器的地址。例如,- --prometheus-url=http://prometheus.istio-system:9090/
kubectl apply -f <repository-directory>/deploy/manifests
一段时间后,custom.metrics.k8s.io/v1beta1
应该出现在命令“kubectl api-vesions”的输出中。 kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq .
和
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/http_requests" | jq .
命令检查自定义API的输出
{
"kind": "MetricValueList",
"apiVersion": "custom.metrics.k8s.io/v1beta1",
"metadata": {
"selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/%2A/http_requests"
},
"items": [
{
"describedObject": {
"kind": "Pod",
"namespace": "default",
"name": "podinfo-6b86c8ccc9-kv5g9",
"apiVersion": "/__internal"
},
"metricName": "http_requests",
"timestamp": "2018-01-10T16:49:07Z",
"value": "901m" },
{
"describedObject": {
"kind": "Pod",
"namespace": "default",
"name": "podinfo-6b86c8ccc9-nm7bl",
"apiVersion": "/__internal"
},
"metricName": "http_requests",
"timestamp": "2018-01-10T16:49:07Z",
"value": "898m"
}
]
}
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq . | grep "pods/"
和http_requests
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq . | grep "http"
中查看可用于Pod的API。 MetricNames是根据Prometheus从Pods收集的度量标准生成的,如果它们为空,则需要朝该方向查看。
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: podinfo
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: podinfo
minReplicas: 2
maxReplicas: 10
metrics:
- type: Pods
pods:
metricName: http_requests
targetAverageValue: 10
#install hey
go get -u github.com/rakyll/hey
#do 10K requests rate limited at 25 QPS
hey -n 10000 -q 5 -c 5 http://<K8S-IP>:31198/healthz
kubectl describe hpa
和kubectl get hpa
关于kubernetes - 如何使用Istio的Prometheus配置kubernetes hpa?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51840970/
我们有一个将导出流量路由到服务网格之外的外部服务的最小示例。 apiVersion: networking.istio.io/v1alpha3 kind: ServiceEntry metadata:
如何在 istio 的目标规则中使用部分匹配的 URI? 试图实现这样的目标: apiVersion: networking.istio.io/v1alpha3 kind: VirtualServic
我看到了Istio site提到速率限制支持,但我只能找到全局速率限制示例。 是否可以在用户级别这样做?例如,如果我的用户登录但在一秒钟内发送超过 50 个请求,那么我想阻止该用户等。在类似情况下,如
这里是 VirtualService 的例子,同时使用了超时和重试。 apiVersion: networking.istio.io/v1alpha3 kind: VirtualService met
这里是 VirtualService 的例子,同时使用了超时和重试。 apiVersion: networking.istio.io/v1alpha3 kind: VirtualService met
场景 我正在使用 Istio 1.5 来自 this question我知道 Istio 使用的默认 envoy 访问日志格式,即 \[%{TIMESTAMP_ISO8601:timestamp}\]
我们已经在开发和生产环境中使用 helm-chart 部署了 Istio 1.11.0。我们在 istio configmap 中使用以下配置,我们已通过 istio-control helm-cha
文档中没有提到主体名称是如何构造的。我所说的主体是指 istio sidecar 创建的客户端证书中的名称,并且可以在规范的 from 指令中的 istio AuthorizationPolicy 对
我目前正在研究 1.6 版的服务网格 Istio。数据平面(Envoy 代理)由控制平面配置。尤其是 Pilot( istiod 的一部分)负责将路由规则和配置传播给特使。我想知道通信是如何工作的?
当用户有多个与之关联的角色时,授权持有者 token 将超过 istio 提供的最大 header 大小,从而阻止所有请求。 授权不记名 token 超过 35,000 个字符,大小为 34K。 如何
我似乎无法找到/理解如何更改 kubernetes 中 Istio 负载均衡器的默认错误登录页面。 例如 503“上游不健康”页面。 是否可以在 Istio 中更改这些?如果是这样,我将如何去做? 提
我知道您可以使用 istio 在服务没有响应时打开断路器。而不是返回 503 , 是否可以重定向到不同的 URL?同样的问题,但是当原始服务返回 500 时,我们可以重定向到另一个 URL 吗? 或者
如何为 Kubernetes 禁用 Istio sidecar 注入(inject) Job ? apiVersion: batch/v1beta1 kind: CronJob metadata:
我正在尝试让 lua envoy 过滤器与 istio 网关一起工作,但我添加到集群并且它正在工作,就好像过滤器不存在一样。 我已经使用本指南在 GKE 上配置了我的 istio 集群 https:/
我想在 kubernetes 集群中运行的不同服务之间实现 TLS 相互身份验证,我发现 Istio 是一个很好的解决方案,无需对代码进行任何更改即可实现这一目标。 我正在尝试使用 Istio sid
我正在尝试让 lua envoy 过滤器与 istio 网关一起工作,但我添加到集群并且它正在工作,就好像过滤器不存在一样。 我已经使用本指南在 GKE 上配置了我的 istio 集群 https:/
我已经使用 Helm 安装了 ISTIO。我忘了启用 grafana、kiali 和 jaeger。安装 istio 后如何启用上述所有服务? 最佳答案 这里是 howto : 来自官方仓库。 你需要
据我了解,无论如何,您的 Istio 网关前都会有一个 NLB 或 ALB? 但我很困惑,因为 Istio Gateway 似乎为 ALB 为第 7 层甚至更多做了很多事情? 所以我读了 ALB ->
我正在使用 helm 安装带有 --set grafana.enabled=true 的 istio-1.0.0 版本. 要访问 grafana 仪表板,我必须使用 kubectl 进行端口转发命令。
我已经使用 Helm 安装了 ISTIO。我忘了启用 grafana、kiali 和 jaeger。安装 istio 后如何启用上述所有服务? 最佳答案 这里是 howto : 来自官方仓库。 你需要
我是一名优秀的程序员,十分优秀!