本文整理汇总了Golang中k8s/io/kubernetes/pkg/metrics.MetricsGrabber.GrabFromApiServer方法的典型用法代码示例。如果您正苦于以下问题:Golang MetricsGrabber.GrabFromApiServer方法的具体用法?Golang MetricsGrabber.GrabFromApiServer怎么用?Golang MetricsGrabber.GrabFromApiServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/metrics.MetricsGrabber
的用法示例。
在下文中一共展示了MetricsGrabber.GrabFromApiServer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
var _ = framework.KubeDescribe("MetricsGrabber", func() {
f := framework.NewDefaultFramework("metrics-grabber")
var c clientset.Interface
var grabber *metrics.MetricsGrabber
BeforeEach(func() {
var err error
c = f.ClientSet
framework.ExpectNoError(err)
grabber, err = metrics.NewMetricsGrabber(c, true, true, true, true)
framework.ExpectNoError(err)
})
It("should grab all metrics from API server.", func() {
By("Connecting to /metrics endpoint")
response, err := grabber.GrabFromApiServer()
framework.ExpectNoError(err)
Expect(response).NotTo(BeEmpty())
})
It("should grab all metrics from a Kubelet.", func() {
By("Proxying to Node through the API server")
nodes := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
Expect(nodes.Items).NotTo(BeEmpty())
response, err := grabber.GrabFromKubelet(nodes.Items[0].Name)
framework.ExpectNoError(err)
Expect(response).NotTo(BeEmpty())
})
It("should grab all metrics from a Scheduler.", func() {
By("Proxying to Pod through the API server")
示例2:
var _ = framework.KubeDescribe("MetricsGrabber", func() {
f := framework.NewDefaultFramework("metrics-grabber")
var c *client.Client
var grabber *metrics.MetricsGrabber
BeforeEach(func() {
var err error
c = f.Client
framework.ExpectNoError(err)
grabber, err = metrics.NewMetricsGrabber(c, true, true, true, true)
framework.ExpectNoError(err)
})
It("should grab all metrics from API server.", func() {
By("Connecting to /metrics endpoint")
unknownMetrics := sets.NewString()
response, err := grabber.GrabFromApiServer(unknownMetrics)
framework.ExpectNoError(err)
Expect(unknownMetrics).To(BeEmpty())
checkMetrics(metrics.Metrics(response), metrics.KnownApiServerMetrics)
})
It("should grab all metrics from a Kubelet.", func() {
By("Proxying to Node through the API server")
nodes := framework.ListSchedulableNodesOrDie(c)
Expect(nodes.Items).NotTo(BeEmpty())
response, err := grabber.GrabFromKubelet(nodes.Items[0].Name)
framework.ExpectNoError(err)
checkNecessaryMetrics(metrics.Metrics(response), metrics.NecessaryKubeletMetrics)
})