Giter Site home page Giter Site logo

metrics's Issues

question: context is building custom controller for `NodeMetricsList` kind

wanted to ask how should I build a custom controller using kubebuilder
for watching this resource

type NodeMetricsList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of node metrics.
Items []NodeMetrics `json:"items" protobuf:"bytes,2,rep,name=items"`
}

here are my kubbuilder commands which failed

kubebuilder init --domain kubesimplify.com --repo kubesimplify.com/ksctl
kubebuilder create api --group metrics.k8s.io --version v1beta1 --kind NodeMetricsList

image

but it is failing
code

func (r *NodeMetricsListReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
	_ = log.FromContext(ctx)

	// TODO(user): your logic here

	fmt.Println("TRIGGERED CONTROLLER!!")

	return ctrl.Result{}, nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *NodeMetricsListReconciler) SetupWithManager(mgr ctrl.Manager) error {
	return ctrl.NewControllerManagedBy(mgr).
		// Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
		For(&metricsServer.NodeMetrics{}).
		Complete(r)
}

Linter error

1. level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package cache: could not load export data: no export data for \"sigs.k8s.io/controller-runtime/pkg/cache\""
   level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package cache: could not load export data: no export data for \"sigs.k8s.io/controller-runtime/pkg/cache\"\n\n"

terminal

➜  ksctl-controller git:(main) ✗ make run
/home/dipankar/Onedrive/gitlab/go-playground/ksctl-controller/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/home/dipankar/Onedrive/gitlab/go-playground/ksctl-controller/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
# sigs.k8s.io/controller-runtime/pkg/cache
../../../../go/pkg/mod/sigs.k8s.io/[email protected]/pkg/cache/multi_namespace_cache.go:308:9: cannot use handles (variable of type map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration) as "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration value in return statement: map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced)
../../../../go/pkg/mod/sigs.k8s.io/[email protected]/pkg/cache/multi_namespace_cache.go:321:9: cannot use handles (variable of type map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration) as "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration value in return statement: map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced)
../../../../go/pkg/mod/sigs.k8s.io/[email protected]/pkg/cache/multi_namespace_cache.go:326:17: impossible type assertion: h.(map[string]toolscache.ResourceEventHandlerRegistration)
	map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced)
make: *** [Makefile:55: vet] Error 1

Fake metrics list only "pods" resources

While trying to make unitest for metrics and using "k8s.io/metrics/pkg/client/clientset/versioned/fake" the following was observed.

the object provided as input to NewSimpleClientset() is of type v1beta1.PodMetricsList. The addition of the object is of Kind: "PodMetrics" as this is extracted in ObjectKinds() and the schema.GroupVersionKind. At the end this results in resource

schema.GroupVersionResource{Group: "metrics.k8s.io", Version: "v1beta1", Resource: "podmetricses"}

The metrices are requested using :

metricsClient.MetricsV1beta1().PodMetricses(namespace).List(getContext(options), getK8sRequestOptions(options))

However when getting the pod metrics the podmetricsesResource is predefined as Resource: "pods" thus no data found when requesting the pod metricses

var podmetricsesResource = v1beta1.SchemeGroupVersion.WithResource("pods")

// Get takes name of the podMetrics, and returns the corresponding podMetrics object, and an error if there is any.
func (c *FakePodMetricses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.PodMetrics, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(podmetricsesResource, c.ns, name), &v1beta1.PodMetrics{})

What type of object should be provided in NewSimpleClientset for v1beta1 version to store the kind as Resource: "pods" for podmetricsesResource in fakepodmetrics.go. Is this functionality correct?

Length restrictions on External Metrics

It appears that using the generic label in MetricIdentifier.Selector comes with the following validation

invalid label value: "prod-redacted-queue": must be no more than 63 characters

I think this might need to be a different struct as it's possible for the values you're looking for to be longer then 63 characters, and RFC-1123 doesn't come into play when looking up metrics by key value.

MarshalToSizedBuffer undefined (type *resource.Quantity has no field

Getting below error while running metrics program.

var kubeconfig, master string //empty, assuming inClusterConfig
config, err := clientcmd.BuildConfigFromFlags(master, kubeconfig)
if err != nil {
	panic(err)
}

mc, err := metrics.NewForConfig(config)
if err != nil {
	panic(err)
}

metricsList, err := mc.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{})
# k8s.io/metrics/pkg/apis/metrics/v1beta1
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:281:44: (*resource.Quantity)(&v).MarshalToSizedBuffer undefined (type *resource.Quantity has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:338:44: (*resource.Quantity)(&v).MarshalToSizedBuffer undefined (type *resource.Quantity has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:358:24: m.Window.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Duration has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:368:27: m.Timestamp.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Time has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:378:28: m.ObjectMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:425:26: m.ListMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ListMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:472:24: m.Window.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Duration has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:482:27: m.Timestamp.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Time has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:492:28: m.ObjectMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:539:26: m.ListMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ListMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1beta1/generated.pb.go:539:26: too many errors
# k8s.io/metrics/pkg/apis/metrics/v1alpha1
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:281:44: (*resource.Quantity)(&v).MarshalToSizedBuffer undefined (type *resource.Quantity has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:338:44: (*resource.Quantity)(&v).MarshalToSizedBuffer undefined (type *resource.Quantity has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:358:24: m.Window.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Duration has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:368:27: m.Timestamp.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Time has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:378:28: m.ObjectMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:425:26: m.ListMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ListMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:472:24: m.Window.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Duration has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:482:27: m.Timestamp.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".Time has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:492:28: m.ObjectMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:539:26: m.ListMeta.MarshalToSizedBuffer undefined (type "k8s.io/apimachinery/pkg/apis/meta/v1".ListMeta has no field or method MarshalToSizedBuffer)
../../pkg/mod/k8s.io/[email protected]/pkg/apis/metrics/v1alpha1/generated.pb.go:539:26: too many errors
make: *** [build-cma] Error 2

Support mutli-cluster for HPA

Multi-cluster is a reasonable scenario in a production environment,but now,can not support it,can you support mutli-cluster for HPA ?

Create a SECURITY_CONTACTS file.

As per the email sent to kubernetes-dev[1], please create a SECURITY_CONTACTS
file.

The template for the file can be found in the kubernetes-template repository[2].
A description for the file is in the steering-committee docs[3], you might need
to search that page for "Security Contacts".

Please feel free to ping me on the PR when you make it, otherwise I will see when
you close this issue. :)

Thanks so much, let me know if you have any questions.

(This issue was generated from a tool, apologies for any weirdness.)

[1] https://groups.google.com/forum/#!topic/kubernetes-dev/codeiIoQ6QE
[2] https://github.com/kubernetes/kubernetes-template-project/blob/master/SECURITY_CONTACTS
[3] https://github.com/kubernetes/community/blob/master/committee-steering/governance/sig-governance-template-short.md

The container.Usage.Cpu().AsInt64

Dear community:
I use this function to get one pod of a container's CPU,Memory

`
func PrintAllResourceOfPodContainers(podContainers []v1beta1.ContainerMetrics){

for _,container := range podContainers{

    fmt.Println("container: ",container)

    cpuQuantiy    := container.Usage.Cpu().AsApproximateFloat64()

    memQuantiy    := container.Usage.Memory().AsApproximateFloat64()

    memQuantiy     = memQuantiy / Mi

    stoQuantiy,ok := container.Usage.Storage().AsInt64()

    containerName := container.Name

    if !ok{
        return 
    }
    msg := fmt.Sprintf("Container Name: %s \n Cpu usage: %f \n memory usage: %f MB\n storage usage: %d\n",containerName,cpuQuantiy,memQuantiy,stoQuantiy)
    fmt.Println(msg)
}

}
`
and I get this output:

container: {free5gc-upf-container map[cpu:{{59076 -9} {<nil>} 59076n DecimalSI} memory:{{30302208 0} {<nil>} BinarySI}]}
According my best knowledge, I know 1CPU = 1000m = 1000 * 1000 n, so is the cpu:{{59076 -9}} is wrong ? I think it is -6 not -9,can anyone know what wrong with this output?

some problems about heapster

Heapster has been archived. But I used heapster in my project ,and my k8s cluster upgrade 1.14 ,now l can't get any data from heapster. someone can tell me what can i do if i wnat to use heapster in 1.14

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.