67 lines
2.2 KiB
Go
67 lines
2.2 KiB
Go
/*
|
|
Copyright 2017 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package stats
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
|
|
statsapi "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
|
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
|
"k8s.io/kubernetes/pkg/kubelet/server/stats"
|
|
)
|
|
|
|
// criStatsProvider implements the containerStatsProvider interface by getting
|
|
// the container stats from CRI.
|
|
type criStatsProvider struct {
|
|
// cadvisor is used to get the node root filesystem's stats (such as the
|
|
// capacity/available bytes/inodes) that will be populated in per container
|
|
// filesystem stats.
|
|
cadvisor cadvisor.Interface
|
|
// resourceAnalyzer is used to get the volume stats of the pods.
|
|
resourceAnalyzer stats.ResourceAnalyzer
|
|
// runtimeService is used to get the status and stats of the pods and its
|
|
// managed containers.
|
|
runtimeService internalapi.RuntimeService
|
|
// imageService is used to get the stats of the image filesystem.
|
|
imageService internalapi.ImageManagerService
|
|
}
|
|
|
|
// newCRIStatsProvider returns a containerStatsProvider implementation that
|
|
// provides container stats using CRI.
|
|
func newCRIStatsProvider(
|
|
cadvisor cadvisor.Interface,
|
|
resourceAnalyzer stats.ResourceAnalyzer,
|
|
runtimeService internalapi.RuntimeService,
|
|
imageService internalapi.ImageManagerService,
|
|
) containerStatsProvider {
|
|
return &criStatsProvider{
|
|
cadvisor: cadvisor,
|
|
resourceAnalyzer: resourceAnalyzer,
|
|
runtimeService: runtimeService,
|
|
imageService: imageService,
|
|
}
|
|
}
|
|
|
|
func (p *criStatsProvider) ListPodStats() ([]statsapi.PodStats, error) {
|
|
return nil, fmt.Errorf("not implemented")
|
|
}
|
|
|
|
func (p *criStatsProvider) ImageFsStats() (*statsapi.FsStats, error) {
|
|
return nil, fmt.Errorf("not implemented")
|
|
}
|