使用Openshift 1.5.0上的自定义指标进行自动扩展部署

时间:2017-05-24 09:59:41

标签: openshift kubernetes openshift-origin heapster hawkular

是否有可能使用Openshift Origin 1.5.0(kubernetes 1.5.2)进行自动调节部署,并为此目的使用自定义指标?

Kubernetes文档指出,1.2版本支持使用自定义指标进行自动扩展。这看起来是真的,因为Openshift水平pod自动调节器(HPA)试图获得一些指标并计算所需的指标。但是我的配置无法成功执行此操作。伙计们,请帮我找到我做错的事。

那么,会发生什么:

  • 我已根据Origin最新文档中的建议设置了指标(所有步骤均已通过):https://docs.openshift.org/latest/install_config/cluster_metrics.html;

    • 我有一个应用程序,它正在部署类型对象;
    • 此应用程序使用http json endpoint;
    • 公开自定义指标
    • 正在收集和存储自定义指标 - 这显示在相应广告连播的“指标”标签中的Openshift origin UI中;
    • 在我创建HPA之后 - 出现了一些关于收集自定义指标的警告,它写了诸如“收集自定义指标失败”这样的内容,没有收到任何准备好的广告系列的指标&#39 ;;
    • 我使用API​​版本1创建HPA并包含注释alpha/target.custom-metrics.podautoscaler.kubernetes.io: '{"items":[{"name":"requests_count", "value": "10"}]}';
    • 如果我通过master-proxy请求部署的heapster应用程序,我会收到类似这样的内容

      {   "元数据":{},   "项目":[    {     "元数据":{      " name":" resty-1722683747-kmbw0",      "命名空间":" availability-demo",      " creationTimestamp":" 2017-05-24T09:50:24Z"     },     " timestamp":" 2017-05-24T09:50:00Z",     " window":" 1m0s",     "容器":[      {       " name":" resty",       "用法":{        " cpu":" 0",        "记忆":" 2372Ki"       }      }     ]    }   ]  }

    • 如您所见,实际上没有自定义指标,我的自定义指标名为requests_count

我应该采取哪些步骤来成功实施自定义指标自动缩放?

Screenshot with custom metrics being collected and exposed via Openshift Console UI

更新 在openshift中,主日志警告如下所示:

I0524 10:17:47.537985       1 panics.go:76GET /apis/extensions/v1beta1/namespaces/availability-demo/deployments/resty/scale: (3.379724ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.543354       1 panics.go:76] GET /api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/apis/metrics/v1alpha1/namespaces/availability-demo/pods?labelSelector=app%3Dresty: (4.830135ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.553255       1 panics.go:76] GET /api/v1/namespaces/availability-demo/pods?labelSelector=app%3Dresty: (8.864864ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.559909       1 panics.go:76] GET /api/v1/namespaces/availability-demo/pods?labelSelector=app%3Dresty: (5.725342ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.560977       1 panics.go:76] PATCH /api/v1/namespaces/availability-demo/events/resty.14c14bbf8b89534c: (6.385846ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.565418       1 panics.go:76] GET /api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/namespaces/availability-demo/pod-list/resty-1722683747-kmbw0/metrics/custom/requests_count?start=2017-05-24T10%3A12%3A47Z: (5.015336ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.569843       1 panics.go:76] GET /api/v1/namespaces/availability-demo/pods?labelSelector=app%3Dresty: (4.040029ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.575530       1 panics.go:76] PUT /apis/autoscaling/v1/namespaces/availability-demo/horizontalpodautoscalers/resty/status: (4.894835ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:hpa-controller] 10.105.8.81:33945]
I0524 10:17:47.575856       1 horizontal.go:438] Successfully updated status for resty
W0524 10:17:47.575890       1 horizontal.go:104] Failed to reconcile resty: failed to compute desired number of replicas based on Custom Metrics for Deployment/availability-demo/resty: failed to get custom metric value: did not recieve metrics for any ready pods

更新:通过代理找到HPA向heapster发出的请求,以收集自定义指标。此请求始终返回空度量数组:

GET /api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/namespaces/availability-demo/pod-list/availability-example-1694583826-55hqh/metrics/custom/requests_count?start=2017-05-25T13%3A14%3A24Z HTTP/1.1
Host: kubernetes-master:8443
Authorization: Bearer hpa-agent-token

它返回

{"items":[{"metrics":[],"latestTimestamp":"0001-01-01T00:00:00Z"}]}

更新:事实证明,HPA通过代理请求heapster,而heapster - 反过来 - 请求"摘要" kubernetes api。 然后问题是 - 为什么kubernetes"摘要"虽然指标存在,但api没有回答上述请求的指标?

1 个答案:

答案 0 :(得分:0)

可能是一个疯狂的猜测,但我自己在自制群集上遇到了问题,我遇到的两件事是令牌问题,我的HA主设置的证书没有正确设置,另一个问题是关于我的kubedns。不确定这是否适用于openshitf。