diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index e681a723b..8eae3b021 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -209,6 +209,13 @@ jobs: -f ${{ matrix.test-suite-path }}/values.yaml \ "${extraArgs[@]}" continue-on-error: true + + - name: Install metrics server in host cluster + id: install-metrics-server + run: |- + set -x + helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/ + helm upgrade --install metrics-server metrics-server/metrics-server --set args={--kubelet-insecure-tls} --set containerPort=4443 -n kube-system - name: Wait until vcluster is ready id: wait-until-vcluster-is-ready diff --git a/charts/eks/templates/syncer-deployment.yaml b/charts/eks/templates/syncer-deployment.yaml index c8cd8403b..499251483 100644 --- a/charts/eks/templates/syncer-deployment.yaml +++ b/charts/eks/templates/syncer-deployment.yaml @@ -118,7 +118,7 @@ spec: {{- if not .Values.syncer.noArgs }} args: - --name={{ .Release.Name }} - - --request-header-ca-cert=/pki/ca.crt + - --request-header-ca-cert=/pki/front-proxy-ca.crt - --client-ca-cert=/pki/ca.crt - --server-ca-cert=/pki/ca.crt - --server-ca-key=/pki/ca.key diff --git a/charts/k8s/templates/syncer-deployment.yaml b/charts/k8s/templates/syncer-deployment.yaml index 51306ca76..721f7e631 100644 --- a/charts/k8s/templates/syncer-deployment.yaml +++ b/charts/k8s/templates/syncer-deployment.yaml @@ -148,7 +148,7 @@ spec: {{- if not .Values.syncer.noArgs }} args: - --name={{ .Release.Name }} - - --request-header-ca-cert=/pki/ca.crt + - --request-header-ca-cert=/pki/front-proxy-ca.crt - --client-ca-cert=/pki/ca.crt - --server-ca-cert=/pki/ca.crt - --server-ca-key=/pki/ca.key diff --git a/devspace.yaml b/devspace.yaml index 98d95b661..4a1473688 100644 --- a/devspace.yaml +++ b/devspace.yaml @@ -52,6 +52,12 @@ deployments: disabled: "false" instanceCreatorType: "devspace" instanceCreatorUID: "devspace" + proxy: + metricsServer: + nodes: + enabled: true + pods: + enabled: true sync: generic: clusterRole: diff --git a/pkg/controllers/k8sdefaultendpoint/k8sdefaultendpoint.go b/pkg/controllers/k8sdefaultendpoint/k8sdefaultendpoint.go index a9b730a79..ae2022611 100644 --- a/pkg/controllers/k8sdefaultendpoint/k8sdefaultendpoint.go +++ b/pkg/controllers/k8sdefaultendpoint/k8sdefaultendpoint.go @@ -9,6 +9,7 @@ import ( "github.com/loft-sh/vcluster/pkg/setup/options" "sigs.k8s.io/controller-runtime/pkg/controller" + "github.com/loft-sh/vcluster/pkg/specialservices" "github.com/loft-sh/vcluster/pkg/util/loghelper" corev1 "k8s.io/api/core/v1" discoveryv1 "k8s.io/api/discovery/v1" @@ -42,6 +43,8 @@ type EndpointController struct { Log loghelper.Logger provider provider + + k8sDistro bool } func NewEndpointController(ctx *options.ControllerContext, provider provider) *EndpointController { @@ -53,6 +56,7 @@ func NewEndpointController(ctx *options.ControllerContext, provider provider) *E VirtualManagerCache: ctx.VirtualManager.GetCache(), Log: loghelper.New("kubernetes-default-endpoint-controller"), provider: provider, + k8sDistro: ctx.Options.IsK8sDistro, } } @@ -69,6 +73,13 @@ func (e *EndpointController) Reconcile(ctx context.Context, _ ctrl.Request) (ctr if err != nil { return ctrl.Result{RequeueAfter: time.Second}, err } + + if e.k8sDistro { + err = e.syncMetricsServerEndpoints(ctx, e.VirtualClient, e.LocalClient, e.ServiceName, e.ServiceNamespace) + if err != nil { + return ctrl.Result{RequeueAfter: time.Second}, err + } + } return ctrl.Result{}, nil } @@ -81,7 +92,18 @@ func (e *EndpointController) SetupWithManager(mgr ctrl.Manager) error { pfuncs := predicate.NewPredicateFuncs(pp) vp := func(object client.Object) bool { - return object.GetNamespace() == "default" && object.GetName() == "kubernetes" + if object.GetNamespace() == specialservices.DefaultKubernetesSvcKey.Namespace && object.GetName() == specialservices.DefaultKubernetesSvcKey.Name { + return true + } + + if e.k8sDistro { + if object.GetNamespace() == specialservices.VclusterProxyMetricsSvcKey.Namespace && + object.GetName() == specialservices.VclusterProxyMetricsSvcKey.Name { + return true + } + } + + return false } vfuncs := predicate.NewPredicateFuncs(vp) @@ -99,6 +121,82 @@ func (e *EndpointController) SetupWithManager(mgr ctrl.Manager) error { Complete(e) } +func (e *EndpointController) syncMetricsServerEndpoints(ctx context.Context, virtualClient, localClient client.Client, serviceName, serviceNamespace string) error { + // get physical service endpoints + pEndpoints := &corev1.Endpoints{} + err := localClient.Get(ctx, types.NamespacedName{ + Namespace: serviceNamespace, + Name: serviceName, + }, pEndpoints) + if err != nil { + if kerrors.IsNotFound(err) { + return nil + } + + return err + } + + vEndpoints := &corev1.Endpoints{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: specialservices.VclusterProxyMetricsSvcKey.Namespace, + Name: specialservices.VclusterProxyMetricsSvcKey.Name, + }, + } + + result, err := controllerutil.CreateOrPatch(ctx, virtualClient, vEndpoints, func() error { + if vEndpoints.Labels == nil { + vEndpoints.Labels = map[string]string{} + } + // vEndpoints.Labels[discoveryv1.LabelSkipMirror] = "true" + + // build new subsets + newSubsets := []corev1.EndpointSubset{} + for _, subset := range pEndpoints.Subsets { + newPorts := []corev1.EndpointPort{} + for _, p := range subset.Ports { + if p.Name != "https" { + continue + } + + newPorts = append(newPorts, p) + } + + newAddresses := []corev1.EndpointAddress{} + for _, address := range subset.Addresses { + address.Hostname = "" + address.NodeName = nil + address.TargetRef = nil + newAddresses = append(newAddresses, address) + } + newNotReadyAddresses := []corev1.EndpointAddress{} + for _, address := range subset.NotReadyAddresses { + address.Hostname = "" + address.NodeName = nil + address.TargetRef = nil + newNotReadyAddresses = append(newNotReadyAddresses, address) + } + + newSubsets = append(newSubsets, corev1.EndpointSubset{ + Addresses: newAddresses, + NotReadyAddresses: newNotReadyAddresses, + Ports: newPorts, + }) + } + + vEndpoints.Subsets = newSubsets + return nil + }) + if err != nil { + return nil + } + + if result == controllerutil.OperationResultCreated || result == controllerutil.OperationResultUpdated { + return e.provider.createOrPatch(ctx, virtualClient, vEndpoints) + } + + return err +} + func (e *EndpointController) syncKubernetesServiceEndpoints(ctx context.Context, virtualClient client.Client, localClient client.Client, serviceName, serviceNamespace string) error { // get physical service endpoints pEndpoints := &corev1.Endpoints{} diff --git a/pkg/controllers/resources/endpoints/syncer.go b/pkg/controllers/resources/endpoints/syncer.go index 6ae1fa006..1062d967b 100644 --- a/pkg/controllers/resources/endpoints/syncer.go +++ b/pkg/controllers/resources/endpoints/syncer.go @@ -40,7 +40,7 @@ func (s *endpointsSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, var _ syncer.Starter = &endpointsSyncer{} func (s *endpointsSyncer) ReconcileStart(ctx *synccontext.SyncContext, req ctrl.Request) (bool, error) { - if req.Namespace == "default" && req.Name == "kubernetes" { + if req.NamespacedName == specialservices.DefaultKubernetesSvcKey { return true, nil } else if _, ok := specialservices.Default.SpecialServicesToSync()[req.NamespacedName]; ok { return true, nil diff --git a/pkg/controllers/resources/pods/syncer_test.go b/pkg/controllers/resources/pods/syncer_test.go index cc478f794..744b59825 100644 --- a/pkg/controllers/resources/pods/syncer_test.go +++ b/pkg/controllers/resources/pods/syncer_test.go @@ -7,6 +7,8 @@ import ( podtranslate "github.com/loft-sh/vcluster/pkg/controllers/resources/pods/translate" synccontext "github.com/loft-sh/vcluster/pkg/controllers/syncer/context" generictesting "github.com/loft-sh/vcluster/pkg/controllers/syncer/testing" + "github.com/loft-sh/vcluster/pkg/setup/options" + "github.com/loft-sh/vcluster/pkg/specialservices" "github.com/loft-sh/vcluster/pkg/util/maps" "github.com/loft-sh/vcluster/pkg/util/translate" "gotest.tools/assert" @@ -21,6 +23,8 @@ import ( func TestSync(t *testing.T) { translate.Default = translate.NewSingleNamespaceTranslator(generictesting.DefaultTestTargetNamespace) + specialservices.SetDefault(&options.VirtualClusterOptions{}) + PodLogsVolumeName := "pod-logs" LogsVolumeName := "logs" KubeletPodVolumeName := "kubelet-pods" diff --git a/pkg/metricsapiservice/register.go b/pkg/metricsapiservice/register.go index af17453ab..3a5ee0022 100644 --- a/pkg/metricsapiservice/register.go +++ b/pkg/metricsapiservice/register.go @@ -2,31 +2,43 @@ package metricsapiservice import ( "context" + "fmt" "math" "time" "github.com/loft-sh/vcluster/pkg/setup/options" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" "k8s.io/metrics/pkg/apis/metrics" + "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" kerrors "k8s.io/apimachinery/pkg/api/errors" ) +var ( + ErrNoMetricsManifests = fmt.Errorf("no metrics server service manifests found") +) + const ( - MetricsVersion = "v1beta1" - MetricsAPIService = MetricsVersion + "." + metrics.GroupName // "v1beta1.metrics.k8s.io" + ManifestRelativePath = "metrics-server/service.yaml" + MetricsVersion = "v1beta1" + MetricsAPIServiceName = MetricsVersion + "." + metrics.GroupName // "v1beta1.metrics.k8s.io" + + AuxVirtualSvcName = "metrics-server" + AuxVirtualSvcNamespace = "kube-system" ) func checkExistingAPIService(ctx context.Context, client client.Client) bool { var exists bool _ = applyOperation(ctx, func(ctx context.Context) (bool, error) { - err := client.Get(ctx, types.NamespacedName{Name: MetricsAPIService}, &apiregistrationv1.APIService{}) + err := client.Get(ctx, types.NamespacedName{Name: MetricsAPIServiceName}, &apiregistrationv1.APIService{}) if err != nil { if kerrors.IsNotFound(err) { return true, nil @@ -51,11 +63,39 @@ func applyOperation(ctx context.Context, operationFunc wait.ConditionWithContext }, operationFunc) } -func deleteOperation(_ context.Context, client client.Client) wait.ConditionWithContextFunc { +func deleteOperation(ctrlCtx *options.ControllerContext) wait.ConditionWithContextFunc { return func(ctx context.Context) (bool, error) { - err := client.Delete(ctx, &apiregistrationv1.APIService{ - ObjectMeta: v1.ObjectMeta{ - Name: MetricsAPIService, + if ctrlCtx.Options.IsK8sDistro { + auxVirtualSvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: AuxVirtualSvcName, + Namespace: AuxVirtualSvcNamespace, + }, + } + err := ctrlCtx.VirtualManager.GetClient().Delete(ctx, auxVirtualSvc) + if err != nil { + if !kerrors.IsNotFound(err) { + return false, nil + } + } + + hostMetricsProxySvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: ctrlCtx.Options.ServiceName + "-metrics-proxy", + Namespace: ctrlCtx.CurrentNamespace, + }, + } + err = ctrlCtx.LocalManager.GetClient().Delete(ctx, hostMetricsProxySvc) + if err != nil { + if !kerrors.IsNotFound(err) { + return false, nil + } + } + } + + err := ctrlCtx.VirtualManager.GetClient().Delete(ctx, &apiregistrationv1.APIService{ + ObjectMeta: metav1.ObjectMeta{ + Name: MetricsAPIServiceName, }, }) if err != nil { @@ -63,7 +103,7 @@ func deleteOperation(_ context.Context, client client.Client) wait.ConditionWith return true, nil } - klog.Errorf("error creating api service %v", err) + klog.Errorf("error deleting api service %v", err) return false, nil } @@ -71,7 +111,7 @@ func deleteOperation(_ context.Context, client client.Client) wait.ConditionWith } } -func createOperation(_ context.Context, client client.Client) wait.ConditionWithContextFunc { +func createOperation(ctrlCtx *options.ControllerContext) wait.ConditionWithContextFunc { return func(ctx context.Context) (bool, error) { spec := apiregistrationv1.APIServiceSpec{ Group: metrics.GroupName, @@ -80,13 +120,98 @@ func createOperation(_ context.Context, client client.Client) wait.ConditionWith VersionPriority: 100, } + if ctrlCtx.Options.IsK8sDistro { + // in this case we register an apiservice with a service reference object + // this service is created as a special service and the physical-virtual + // pair makes sure the service discovery happens as expected in even non single + // binary distros like k8s and eks + spec.Service = &apiregistrationv1.ServiceReference{ + Name: AuxVirtualSvcName, + Namespace: AuxVirtualSvcNamespace, + Port: pointer.Int32(443), + } + spec.InsecureSkipTLSVerify = true + + // create aux metrics server service in vcluster + auxVirtualSvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: AuxVirtualSvcName, + Namespace: AuxVirtualSvcNamespace, + Labels: map[string]string{ + "k8s-app": "metrics-server", + }, + }, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + { + Name: "https", + Port: 443, + Protocol: "TCP", + TargetPort: intstr.FromInt(8443), + }, + }, + Selector: map[string]string{ + "k8s-app": "metrics-server", + }, + SessionAffinity: corev1.ServiceAffinityNone, + Type: corev1.ServiceTypeClusterIP, + }, + } + err := ctrlCtx.VirtualManager.GetClient().Create(ctx, auxVirtualSvc) + if err != nil { + if !kerrors.IsAlreadyExists(err) { + klog.Errorf("error creating metrics server service inside vcluster %v", err) + return false, nil + } + } + + // create aux metrics service in host cluster + hostMetricsProxySvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: ctrlCtx.Options.ServiceName + "-metrics-proxy", + Namespace: ctrlCtx.CurrentNamespace, + Labels: map[string]string{ + "app": "vcluster-metrics-proxy", + "release": ctrlCtx.Options.Name, + }, + }, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + { + Name: "https", + Port: 443, + Protocol: "TCP", + TargetPort: intstr.FromInt(8443), + }, + { + Name: "kubelet", + Port: 10250, + Protocol: "TCP", + TargetPort: intstr.FromInt(8443), + }, + }, + Selector: map[string]string{ + "app": "vcluster", + "release": ctrlCtx.Options.Name, + }, + }, + } + err = ctrlCtx.LocalManager.GetClient().Create(ctx, hostMetricsProxySvc) + if err != nil { + if !kerrors.IsAlreadyExists(err) { + klog.Errorf("error create host metrics proxy service %v", err) + return false, nil + } + } + } + apiService := &apiregistrationv1.APIService{ - ObjectMeta: v1.ObjectMeta{ - Name: MetricsAPIService, + ObjectMeta: metav1.ObjectMeta{ + Name: MetricsAPIServiceName, }, } - _, err := controllerutil.CreateOrUpdate(ctx, client, apiService, func() error { + _, err := controllerutil.CreateOrUpdate(ctx, ctrlCtx.VirtualManager.GetClient(), apiService, func() error { apiService.Spec = spec return nil }) @@ -103,13 +228,13 @@ func createOperation(_ context.Context, client client.Client) wait.ConditionWith } } -func RegisterOrDeregisterAPIService(ctx context.Context, options *options.VirtualClusterOptions, client client.Client) error { +func RegisterOrDeregisterAPIService(ctx *options.ControllerContext) error { // check if the api service should get created - exists := checkExistingAPIService(ctx, client) - if options.ProxyMetricsServer { - return applyOperation(ctx, createOperation(ctx, client)) - } else if !options.ProxyMetricsServer && exists { - return applyOperation(ctx, deleteOperation(ctx, client)) + exists := checkExistingAPIService(ctx.Context, ctx.VirtualManager.GetClient()) + if ctx.Options.ProxyMetricsServer { + return applyOperation(ctx.Context, createOperation(ctx)) + } else if !ctx.Options.ProxyMetricsServer && exists { + return applyOperation(ctx.Context, deleteOperation(ctx)) } return nil diff --git a/pkg/server/cert/cert.go b/pkg/server/cert/cert.go index 4b6eaf318..6d6caf18f 100644 --- a/pkg/server/cert/cert.go +++ b/pkg/server/cert/cert.go @@ -11,12 +11,30 @@ import ( "k8s.io/apimachinery/pkg/util/sets" ) -func GenServingCerts(caCertFile, caKeyFile string, currentCert, currentKey []byte, clusterDomain string, SANs []string) ([]byte, []byte, bool, error) { +func GenServingCerts(caCertFile, caKeyFile string, currentCert, currentKey []byte, clusterDomain string, SANs []string, k8sDistro bool) ([]byte, []byte, bool, error) { regen := false commonName := "kube-apiserver" extKeyUsage := []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth} + + dnsNames := []string{ + "kubernetes.default.svc." + clusterDomain, + "kubernetes.default.svc", + "kubernetes.default", + "kubernetes", + "localhost", + } + + if k8sDistro { + dnsNames = append(dnsNames, []string{ + "metrics-server.kube-system.svc." + clusterDomain, + "metrics-server.kube-system.svc", + "metrics-server.kube-system", + "metrics-server", + }...) + } + altNames := &certhelper.AltNames{ - DNSNames: []string{"kubernetes.default.svc." + clusterDomain, "kubernetes.default.svc", "kubernetes.default", "kubernetes", "localhost"}, + DNSNames: dnsNames, IPs: []net.IP{net.ParseIP("127.0.0.1")}, } diff --git a/pkg/server/cert/syncer.go b/pkg/server/cert/syncer.go index 71a056395..eb9037711 100644 --- a/pkg/server/cert/syncer.go +++ b/pkg/server/cert/syncer.go @@ -44,6 +44,8 @@ func NewSyncer(_ context.Context, currentNamespace string, currentNamespaceClien serviceName: options.ServiceName, currentNamespace: currentNamespace, currentNamespaceCient: currentNamespaceClient, + + k8sDistro: options.IsK8sDistro, }, nil } @@ -67,6 +69,8 @@ type syncer struct { currentCert []byte currentKey []byte currentSANs []string + + k8sDistro bool } func (s *syncer) Name() string { @@ -195,7 +199,7 @@ func (s *syncer) regen(extraSANs []string) error { klog.Infof("Generating serving cert for service ips: %v", extraSANs) // GenServingCerts will write generated or updated cert/key to s.currentCert, s.currentKey - cert, key, _, err := GenServingCerts(s.serverCaCert, s.serverCaKey, s.currentCert, s.currentKey, s.clusterDomain, extraSANs) + cert, key, _, err := GenServingCerts(s.serverCaCert, s.serverCaKey, s.currentCert, s.currentKey, s.clusterDomain, extraSANs, s.k8sDistro) if err != nil { return err } diff --git a/pkg/server/filters/metrics_server.go b/pkg/server/filters/metrics_server.go index 2cfd9842a..2c20c6355 100644 --- a/pkg/server/filters/metrics_server.go +++ b/pkg/server/filters/metrics_server.go @@ -516,7 +516,6 @@ func (p *MetricsServerProxy) rewritePodMetricsListData(data []byte) ([]byte, err // returns the types.NamespacedName list of pods for the given namespace func getVirtualPodObjectsInNamespace(ctx context.Context, vClient client.Client, namespace string) ([]corev1.Pod, error) { podList := &corev1.PodList{} - err := vClient.List(ctx, podList, &client.ListOptions{ Namespace: namespace, }) diff --git a/pkg/server/server.go b/pkg/server/server.go index c98ecc754..2ca3bcba4 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -296,12 +296,17 @@ func (s *Server) ServeOnListenerTLS(address string, port int, stopChan <-chan st } func createCachedClient(ctx context.Context, config *rest.Config, namespace string, restMapper meta.RESTMapper, scheme *runtime.Scheme, registerIndices func(cache cache.Cache) error) (client.Client, error) { + // create cache options + cacheOptions := cache.Options{ + Scheme: scheme, + Mapper: restMapper, + } + if namespace != "" { + cacheOptions.DefaultNamespaces = map[string]cache.Config{namespace: {}} + } + // create the new cache - clientCache, err := cache.New(config, cache.Options{ - Scheme: scheme, - Mapper: restMapper, - DefaultNamespaces: map[string]cache.Config{namespace: {}}, - }) + clientCache, err := cache.New(config, cacheOptions) if err != nil { return nil, err } diff --git a/pkg/setup/controllers.go b/pkg/setup/controllers.go index 1dec866ab..fa56b90c9 100644 --- a/pkg/setup/controllers.go +++ b/pkg/setup/controllers.go @@ -191,8 +191,7 @@ func StartManagers(controllerContext *options.ControllerContext, syncers []synce } func RegisterOrDeregisterAPIService(ctx *options.ControllerContext) { - // check api-service for metrics server - err := metricsapiservice.RegisterOrDeregisterAPIService(ctx.Context, ctx.Options, ctx.VirtualManager.GetClient()) + err := metricsapiservice.RegisterOrDeregisterAPIService(ctx) if err != nil { klog.Errorf("Error registering metrics apiservice: %v", err) } diff --git a/pkg/setup/initialize.go b/pkg/setup/initialize.go index 63c69284a..f0ba749f6 100644 --- a/pkg/setup/initialize.go +++ b/pkg/setup/initialize.go @@ -9,6 +9,7 @@ import ( "github.com/loft-sh/vcluster/pkg/certs" "github.com/loft-sh/vcluster/pkg/k3s" "github.com/loft-sh/vcluster/pkg/setup/options" + "github.com/loft-sh/vcluster/pkg/specialservices" "github.com/loft-sh/vcluster/pkg/util/servicecidr" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -57,6 +58,8 @@ func Initialize( return err } + specialservices.SetDefault(options) + return nil } @@ -113,6 +116,7 @@ func initialize( } }() } else if certificatesDir != "" { + options.IsK8sDistro = true err = GenerateK8sCerts(ctx, currentNamespaceClient, vClusterName, currentNamespace, serviceCIDR, certificatesDir, options.ClusterDomain) if err != nil { return err diff --git a/pkg/setup/options/options.go b/pkg/setup/options/options.go index dbe0fb3c0..7be84b762 100644 --- a/pkg/setup/options/options.go +++ b/pkg/setup/options/options.go @@ -66,6 +66,8 @@ type VirtualClusterOptions struct { SyncLabels []string `json:"syncLabels,omitempty"` + IsK8sDistro bool `json:"singleBinaryDistro,omitempty"` + // hostpath mapper options // this is only needed if using vcluster-hostpath-mapper component // see: https://github.com/loft-sh/vcluster-hostpath-mapper diff --git a/pkg/specialservices/proxy_service_syncer.go b/pkg/specialservices/proxy_service_syncer.go new file mode 100644 index 000000000..b0e490707 --- /dev/null +++ b/pkg/specialservices/proxy_service_syncer.go @@ -0,0 +1,96 @@ +package specialservices + +import ( + synccontext "github.com/loft-sh/vcluster/pkg/controllers/syncer/context" + "github.com/loft-sh/vcluster/pkg/util/translate" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + kerrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "k8s.io/klog/v2" +) + +var ( + VclusterProxyMetricsSvcKey = types.NamespacedName{ + Name: "metrics-server", + Namespace: "kube-system", + } +) + +const ( + PhysicalSvcSelectorKeyApp = "app" + PhysicalSvcSelectorKeyRelease = "release" + PhysicalMetricsServerServiceNameSuffix = "-metrics-proxy" +) + +func SyncVclusterProxyService(ctx *synccontext.SyncContext, + _, + svcName string, + vSvcToSync types.NamespacedName, + _ ServicePortTranslator, +) error { + pClient := ctx.PhysicalClient + // get physical service + pObj := &corev1.Service{} + err := pClient.Get(ctx.Context, types.NamespacedName{ + Namespace: translate.Default.PhysicalNamespace(vSvcToSync.Namespace), + Name: svcName + PhysicalMetricsServerServiceNameSuffix, + }, pObj) + if err != nil { + if kerrors.IsNotFound(err) { + return nil + } + + return err + } + + // check if pobject has the expected selectors, if not update + // and make it point to the syncer pod + expectedPhysicalSvcSelectors := map[string]string{ + PhysicalSvcSelectorKeyApp: "vcluster", + PhysicalSvcSelectorKeyRelease: svcName, + } + + if !equality.Semantic.DeepEqual(pObj.Spec.Selector, expectedPhysicalSvcSelectors) { + pObj.Spec.Selector = expectedPhysicalSvcSelectors + err = pClient.Update(ctx.Context, pObj) + if err != nil { + klog.Errorf("error updating physical metrics server service object %v", err) + return err + } + } + + vClient := ctx.VirtualClient + vObj := &corev1.Service{} + err = vClient.Get(ctx.Context, vSvcToSync, vObj) + if err != nil { + if kerrors.IsNotFound(err) { + return nil + } + + return err + } + + if vObj.Spec.ClusterIP != pObj.Spec.ClusterIP || !equality.Semantic.DeepEqual(vObj.Spec.ClusterIPs, pObj.Spec.ClusterIPs) { + newService := vObj.DeepCopy() + newService.Spec.ClusterIP = pObj.Spec.ClusterIP + newService.Spec.ClusterIPs = pObj.Spec.ClusterIPs + newService.Spec.IPFamilies = pObj.Spec.IPFamilies + + // delete & create with correct ClusterIP + err = vClient.Delete(ctx.Context, vObj) + if err != nil { + return err + } + + newService.ResourceVersion = "" + + // create the new service with the correct cluster ip + err = vClient.Create(ctx.Context, newService) + if err != nil { + return err + } + } + + return nil +} diff --git a/pkg/specialservices/resolver.go b/pkg/specialservices/resolver.go index 7f08691a9..dbb12d0f8 100644 --- a/pkg/specialservices/resolver.go +++ b/pkg/specialservices/resolver.go @@ -2,12 +2,17 @@ package specialservices import ( synccontext "github.com/loft-sh/vcluster/pkg/controllers/syncer/context" + "github.com/loft-sh/vcluster/pkg/setup/options" "github.com/loft-sh/vcluster/pkg/util/translate" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) -var Default = DefaultNameserverFinder() +var Default Interface + +func SetDefault(ctrlCtx *options.VirtualClusterOptions) { + Default = defaultNameserverFinder(ctrlCtx.IsK8sDistro) +} const ( DefaultKubeDNSServiceName = "kube-dns" @@ -39,13 +44,16 @@ func (f *NameserverFinder) SpecialServicesToSync() map[types.NamespacedName]Spec return f.SpecialServices } -func DefaultNameserverFinder() Interface { +func defaultNameserverFinder(k8sDistro bool) Interface { + specialServicesMap := map[types.NamespacedName]SpecialServiceSyncer{ + DefaultKubernetesSvcKey: SyncKubernetesService, + } + + if k8sDistro { + specialServicesMap[VclusterProxyMetricsSvcKey] = SyncVclusterProxyService + } + return &NameserverFinder{ - SpecialServices: map[types.NamespacedName]SpecialServiceSyncer{ - { - Name: DefaultKubernetesSVCName, - Namespace: DefaultKubernetesSVCNamespace, - }: SyncKubernetesService, - }, + SpecialServices: specialServicesMap, } } diff --git a/pkg/specialservices/service_syncer.go b/pkg/specialservices/service_syncer.go index c135387fe..9d28d1e45 100644 --- a/pkg/specialservices/service_syncer.go +++ b/pkg/specialservices/service_syncer.go @@ -9,6 +9,13 @@ import ( "k8s.io/apimachinery/pkg/types" ) +var ( + DefaultKubernetesSvcKey = types.NamespacedName{ + Name: DefaultKubernetesSVCName, + Namespace: DefaultKubernetesSVCNamespace, + } +) + const ( DefaultKubernetesSVCName = "kubernetes" DefaultKubernetesSVCNamespace = "default" diff --git a/test/e2e_metrics_proxy/e2e_metrics_proxy_test.go b/test/e2e_metrics_proxy/e2e_metrics_proxy_test.go new file mode 100644 index 000000000..8d707dbea --- /dev/null +++ b/test/e2e_metrics_proxy/e2e_metrics_proxy_test.go @@ -0,0 +1,56 @@ +package e2emetricsproxy + +import ( + "context" + "testing" + + "github.com/loft-sh/log" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + "k8s.io/apimachinery/pkg/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" + + // Enable cloud provider auth + _ "k8s.io/client-go/plugin/pkg/client/auth" + // Register tests +) + +var ( + scheme = runtime.NewScheme() +) + +func init() { + _ = clientgoscheme.AddToScheme(scheme) + // API extensions are not in the above scheme set, + // and must thus be added separately. + _ = apiextensionsv1beta1.AddToScheme(scheme) + _ = apiextensionsv1.AddToScheme(scheme) + _ = apiregistrationv1.AddToScheme(scheme) +} + +// TestRunE2ETargetNamespaceTests checks configuration parameters (specified through flags) and then runs +// E2E tests using the Ginkgo runner. +// If a "report directory" is specified, one or more JUnit test reports will be +// generated in this directory, and cluster logs will also be saved. +// This function is called on each Ginkgo node in parallel mode. +func TestRunE2ETargetNamespaceTests(t *testing.T) { + gomega.RegisterFailHandler(ginkgo.Fail) + err := framework.CreateFramework(context.Background(), scheme) + if err != nil { + log.GetInstance().Fatalf("Error setting up framework: %v", err) + } + + var _ = ginkgo.AfterSuite(func() { + err = framework.DefaultFramework.Cleanup() + if err != nil { + log.GetInstance().Warnf("Error executing testsuite cleanup: %v", err) + } + }) + + ginkgo.RunSpecs(t, "Vcluster e2eProxyMetricsServer suite") +} diff --git a/test/e2e_metrics_proxy/metricsProxy.go b/test/e2e_metrics_proxy/metricsProxy.go new file mode 100644 index 000000000..3893475ee --- /dev/null +++ b/test/e2e_metrics_proxy/metricsProxy.go @@ -0,0 +1,71 @@ +package e2emetricsproxy + +import ( + "context" + "fmt" + "time" + + "github.com/loft-sh/vcluster/pkg/metricsapiservice" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" + apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" + apiregistrationv1clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1" + + metricsv1beta1client "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" +) + +var _ = ginkgo.Describe("Target Namespace", func() { + f := framework.DefaultFramework + + ginkgo.It("Make sure the metrics api service is registered and available", func() { + err := wait.PollUntilContextTimeout(f.Context, time.Second, time.Minute*1, false, func(ctx context.Context) (bool, error) { + apiRegistrationClient := apiregistrationv1clientset.NewForConfigOrDie(f.VclusterConfig) + apiService, err := apiRegistrationClient.APIServices().Get(f.Context, metricsapiservice.MetricsAPIServiceName, metav1.GetOptions{}) + if err != nil { + return false, nil + } + + if apiService.Status.Conditions[0].Type != apiregistrationv1.Available { + return false, nil + } + + return true, nil + }) + framework.ExpectNoError(err) + }) + + ginkgo.It("Make sure get nodeMetrics and podMetrics succeed", func() { + err := wait.PollUntilContextTimeout(f.Context, time.Second, time.Minute*1, false, func(ctx context.Context) (bool, error) { + metricsClient := metricsv1beta1client.NewForConfigOrDie(f.VclusterConfig) + + nodeMetricsList, err := metricsClient.NodeMetricses().List(f.Context, metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(ginkgo.GinkgoWriter, "error getting node metrics list %v", err) + return false, nil + } + + if len(nodeMetricsList.Items) == 0 { + fmt.Fprintf(ginkgo.GinkgoWriter, "expecting node metrics list to have at least 1 entry, got %d", len(nodeMetricsList.Items)) + return false, nil + } + + podMetricsList, err := metricsClient.PodMetricses("kube-system").List(f.Context, metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(ginkgo.GinkgoWriter, "error getting pod metrics list %v", err) + return false, nil + } + + if len(podMetricsList.Items) == 0 { + fmt.Fprintf(ginkgo.GinkgoWriter, "expecting pod metrics list to have at least 1 entry, got %d", len(podMetricsList.Items)) + return false, nil + } + + return true, nil + }) + + framework.ExpectNoError(err) + }) +}) diff --git a/test/e2e_metrics_proxy/values.yaml b/test/e2e_metrics_proxy/values.yaml new file mode 100644 index 000000000..c3d366048 --- /dev/null +++ b/test/e2e_metrics_proxy/values.yaml @@ -0,0 +1,6 @@ +proxy: + metricsServer: + nodes: + enabled: true + pods: + enabled: true \ No newline at end of file diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/doc.go b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/doc.go new file mode 100644 index 000000000..8e06b2205 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/doc.go @@ -0,0 +1,24 @@ +/* +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. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:protobuf-gen=package +// +k8s:conversion-gen=k8s.io/metrics/pkg/apis/metrics +// +k8s:openapi-gen=true +// +groupName=metrics.k8s.io + +// Package v1alpha1 is the v1alpha1 version of the metrics API. +package v1alpha1 // import "k8s.io/metrics/pkg/apis/metrics/v1alpha1" diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.pb.go b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.pb.go new file mode 100644 index 000000000..c472bacd4 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.pb.go @@ -0,0 +1,1758 @@ +/* +Copyright 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. +*/ + +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.proto + +package v1alpha1 + +import ( + fmt "fmt" + + io "io" + + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + + k8s_io_api_core_v1 "k8s.io/api/core/v1" + k8s_io_apimachinery_pkg_api_resource "k8s.io/apimachinery/pkg/api/resource" + resource "k8s.io/apimachinery/pkg/api/resource" + + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func (m *ContainerMetrics) Reset() { *m = ContainerMetrics{} } +func (*ContainerMetrics) ProtoMessage() {} +func (*ContainerMetrics) Descriptor() ([]byte, []int) { + return fileDescriptor_4bcbecebae081ea6, []int{0} +} +func (m *ContainerMetrics) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ContainerMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *ContainerMetrics) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContainerMetrics.Merge(m, src) +} +func (m *ContainerMetrics) XXX_Size() int { + return m.Size() +} +func (m *ContainerMetrics) XXX_DiscardUnknown() { + xxx_messageInfo_ContainerMetrics.DiscardUnknown(m) +} + +var xxx_messageInfo_ContainerMetrics proto.InternalMessageInfo + +func (m *NodeMetrics) Reset() { *m = NodeMetrics{} } +func (*NodeMetrics) ProtoMessage() {} +func (*NodeMetrics) Descriptor() ([]byte, []int) { + return fileDescriptor_4bcbecebae081ea6, []int{1} +} +func (m *NodeMetrics) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NodeMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *NodeMetrics) XXX_Merge(src proto.Message) { + xxx_messageInfo_NodeMetrics.Merge(m, src) +} +func (m *NodeMetrics) XXX_Size() int { + return m.Size() +} +func (m *NodeMetrics) XXX_DiscardUnknown() { + xxx_messageInfo_NodeMetrics.DiscardUnknown(m) +} + +var xxx_messageInfo_NodeMetrics proto.InternalMessageInfo + +func (m *NodeMetricsList) Reset() { *m = NodeMetricsList{} } +func (*NodeMetricsList) ProtoMessage() {} +func (*NodeMetricsList) Descriptor() ([]byte, []int) { + return fileDescriptor_4bcbecebae081ea6, []int{2} +} +func (m *NodeMetricsList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NodeMetricsList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *NodeMetricsList) XXX_Merge(src proto.Message) { + xxx_messageInfo_NodeMetricsList.Merge(m, src) +} +func (m *NodeMetricsList) XXX_Size() int { + return m.Size() +} +func (m *NodeMetricsList) XXX_DiscardUnknown() { + xxx_messageInfo_NodeMetricsList.DiscardUnknown(m) +} + +var xxx_messageInfo_NodeMetricsList proto.InternalMessageInfo + +func (m *PodMetrics) Reset() { *m = PodMetrics{} } +func (*PodMetrics) ProtoMessage() {} +func (*PodMetrics) Descriptor() ([]byte, []int) { + return fileDescriptor_4bcbecebae081ea6, []int{3} +} +func (m *PodMetrics) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PodMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *PodMetrics) XXX_Merge(src proto.Message) { + xxx_messageInfo_PodMetrics.Merge(m, src) +} +func (m *PodMetrics) XXX_Size() int { + return m.Size() +} +func (m *PodMetrics) XXX_DiscardUnknown() { + xxx_messageInfo_PodMetrics.DiscardUnknown(m) +} + +var xxx_messageInfo_PodMetrics proto.InternalMessageInfo + +func (m *PodMetricsList) Reset() { *m = PodMetricsList{} } +func (*PodMetricsList) ProtoMessage() {} +func (*PodMetricsList) Descriptor() ([]byte, []int) { + return fileDescriptor_4bcbecebae081ea6, []int{4} +} +func (m *PodMetricsList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PodMetricsList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *PodMetricsList) XXX_Merge(src proto.Message) { + xxx_messageInfo_PodMetricsList.Merge(m, src) +} +func (m *PodMetricsList) XXX_Size() int { + return m.Size() +} +func (m *PodMetricsList) XXX_DiscardUnknown() { + xxx_messageInfo_PodMetricsList.DiscardUnknown(m) +} + +var xxx_messageInfo_PodMetricsList proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ContainerMetrics)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.ContainerMetrics") + proto.RegisterMapType((k8s_io_api_core_v1.ResourceList)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.ContainerMetrics.UsageEntry") + proto.RegisterType((*NodeMetrics)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.NodeMetrics") + proto.RegisterMapType((k8s_io_api_core_v1.ResourceList)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.NodeMetrics.UsageEntry") + proto.RegisterType((*NodeMetricsList)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.NodeMetricsList") + proto.RegisterType((*PodMetrics)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.PodMetrics") + proto.RegisterType((*PodMetricsList)(nil), "k8s.io.metrics.pkg.apis.metrics.v1alpha1.PodMetricsList") +} + +func init() { + proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.proto", fileDescriptor_4bcbecebae081ea6) +} + +var fileDescriptor_4bcbecebae081ea6 = []byte{ + // 661 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x41, 0x4f, 0x13, 0x41, + 0x18, 0xed, 0xd0, 0x96, 0xc0, 0x54, 0x11, 0xf7, 0x44, 0x7a, 0xd8, 0x92, 0x9e, 0x1a, 0x13, 0x66, + 0x85, 0xa0, 0x21, 0x9c, 0xcc, 0x0a, 0x07, 0x13, 0x41, 0xd9, 0xa0, 0x46, 0xf4, 0xe0, 0x74, 0x3b, + 0x6e, 0xc7, 0xb2, 0x3b, 0x9b, 0x99, 0xd9, 0x92, 0xde, 0x8c, 0x7a, 0xf2, 0x64, 0xe2, 0x9f, 0xc2, + 0x78, 0xe1, 0xc8, 0x45, 0x90, 0xf5, 0xee, 0x0f, 0xf0, 0x64, 0x76, 0x76, 0xb6, 0x5b, 0x29, 0xc2, + 0xca, 0xc1, 0x13, 0xb7, 0xee, 0x37, 0xf3, 0xde, 0xfb, 0xe6, 0x7d, 0x6f, 0x26, 0x85, 0x5b, 0xbd, + 0x15, 0x81, 0x28, 0xb3, 0x7a, 0x51, 0x9b, 0xf0, 0x80, 0x48, 0x22, 0xac, 0x3e, 0x09, 0x3a, 0x8c, + 0x5b, 0x7a, 0xc1, 0x27, 0x92, 0x53, 0x57, 0x58, 0x61, 0xcf, 0xb3, 0x70, 0x48, 0xc5, 0xb0, 0xd0, + 0x5f, 0xc4, 0xbb, 0x61, 0x17, 0x2f, 0x5a, 0x1e, 0x09, 0x08, 0xc7, 0x92, 0x74, 0x50, 0xc8, 0x99, + 0x64, 0x46, 0x2b, 0x45, 0x22, 0xbd, 0x11, 0x85, 0x3d, 0x0f, 0x25, 0xc8, 0x61, 0x21, 0x43, 0xd6, + 0x17, 0x3c, 0x2a, 0xbb, 0x51, 0x1b, 0xb9, 0xcc, 0xb7, 0x3c, 0xe6, 0x31, 0x4b, 0x11, 0xb4, 0xa3, + 0xd7, 0xea, 0x4b, 0x7d, 0xa8, 0x5f, 0x29, 0x71, 0xbd, 0xa9, 0x5b, 0xc2, 0x21, 0xb5, 0x5c, 0xc6, + 0x89, 0xd5, 0x1f, 0x13, 0xaf, 0x2f, 0xe7, 0x7b, 0x7c, 0xec, 0x76, 0x69, 0x40, 0xf8, 0x20, 0xeb, + 0xdd, 0xe2, 0x44, 0xb0, 0x88, 0xbb, 0xe4, 0x9f, 0x50, 0xea, 0xc4, 0xf8, 0x2c, 0x2d, 0xeb, 0x6f, + 0x28, 0x1e, 0x05, 0x92, 0xfa, 0xe3, 0x32, 0x77, 0x2f, 0x02, 0x08, 0xb7, 0x4b, 0x7c, 0x7c, 0x1a, + 0xd7, 0x7c, 0x5f, 0x86, 0xb3, 0xf7, 0x59, 0x20, 0x71, 0x82, 0xd8, 0x48, 0x5d, 0x34, 0xe6, 0x61, + 0x25, 0xc0, 0x3e, 0x99, 0x03, 0xf3, 0xa0, 0x35, 0x6d, 0x5f, 0xdb, 0x3f, 0x6a, 0x94, 0xe2, 0xa3, + 0x46, 0x65, 0x13, 0xfb, 0xc4, 0x51, 0x2b, 0x46, 0x0c, 0x60, 0x35, 0x12, 0xd8, 0x23, 0x73, 0x13, + 0xf3, 0xe5, 0x56, 0x6d, 0x69, 0x1d, 0x15, 0x9d, 0x0c, 0x3a, 0xad, 0x86, 0x9e, 0x24, 0x3c, 0xeb, + 0x81, 0xe4, 0x03, 0xfb, 0x03, 0xd0, 0x5a, 0x55, 0x55, 0xfc, 0x75, 0xd4, 0x68, 0x8c, 0x0f, 0x06, + 0x39, 0xda, 0xeb, 0x87, 0x54, 0xc8, 0x77, 0xc7, 0xe7, 0x6e, 0x49, 0x5a, 0xfe, 0x78, 0xdc, 0x58, + 0x28, 0x32, 0x3a, 0xb4, 0x15, 0xe1, 0x40, 0x52, 0x39, 0x70, 0xd2, 0xa3, 0xd5, 0xbb, 0x10, 0xe6, + 0xbd, 0x19, 0xb3, 0xb0, 0xdc, 0x23, 0x83, 0xd4, 0x13, 0x27, 0xf9, 0x69, 0xac, 0xc1, 0x6a, 0x1f, + 0xef, 0x46, 0x89, 0x07, 0xa0, 0x55, 0x5b, 0x42, 0x99, 0x07, 0xa3, 0x2a, 0x99, 0x11, 0xe8, 0x0c, + 0x15, 0x05, 0x5e, 0x9d, 0x58, 0x01, 0xcd, 0x9f, 0x15, 0x58, 0xdb, 0x64, 0x1d, 0x92, 0x0d, 0xe0, + 0x15, 0x9c, 0x4a, 0x92, 0xd1, 0xc1, 0x12, 0x2b, 0xc1, 0xda, 0xd2, 0xed, 0xf3, 0xc8, 0x95, 0xcb, + 0x18, 0xf5, 0x17, 0xd1, 0xa3, 0xf6, 0x1b, 0xe2, 0xca, 0x0d, 0x22, 0xb1, 0x6d, 0x68, 0x2b, 0x61, + 0x5e, 0x73, 0x86, 0xac, 0xc6, 0x0b, 0x38, 0x9d, 0xc4, 0x42, 0x48, 0xec, 0x87, 0xba, 0xff, 0x5b, + 0xc5, 0x24, 0xb6, 0xa9, 0x4f, 0xec, 0x9b, 0x9a, 0x7c, 0x7a, 0x3b, 0x23, 0x71, 0x72, 0x3e, 0xe3, + 0x29, 0x9c, 0xdc, 0xa3, 0x41, 0x87, 0xed, 0xcd, 0x95, 0x2f, 0x76, 0x26, 0x67, 0x5e, 0x8b, 0x38, + 0x96, 0x94, 0x05, 0xf6, 0x8c, 0x66, 0x9f, 0x7c, 0xa6, 0x58, 0x1c, 0xcd, 0x66, 0x7c, 0x1b, 0xa6, + 0xae, 0xa2, 0x52, 0x77, 0xaf, 0x78, 0xea, 0x46, 0xdc, 0xbd, 0x0a, 0x1c, 0x68, 0x7e, 0x05, 0xf0, + 0xc6, 0x88, 0x25, 0xc9, 0xc1, 0x8c, 0x97, 0x63, 0xa1, 0x2b, 0x38, 0xb7, 0x04, 0xad, 0x22, 0x37, + 0xab, 0xcd, 0x9c, 0xca, 0x2a, 0x23, 0x81, 0xdb, 0x81, 0x55, 0x2a, 0x89, 0x2f, 0xf4, 0x83, 0x71, + 0xe7, 0x52, 0xa3, 0xb3, 0xaf, 0x67, 0xe3, 0x7a, 0x90, 0x70, 0x39, 0x29, 0x65, 0xf3, 0x73, 0x19, + 0xc2, 0xc7, 0xac, 0x73, 0x75, 0x7b, 0xce, 0xbd, 0x3d, 0x01, 0x84, 0x6e, 0xf6, 0xf6, 0x0a, 0x7d, + 0x83, 0x56, 0x2f, 0xff, 0x6e, 0xe7, 0x16, 0x0d, 0x57, 0x84, 0x33, 0xa2, 0xd0, 0xfc, 0x02, 0xe0, + 0x4c, 0x3e, 0x95, 0xff, 0x10, 0xb1, 0xe7, 0x7f, 0x46, 0x6c, 0xb9, 0xf8, 0xd9, 0xf2, 0x36, 0xcf, + 0x4e, 0x98, 0xbd, 0xb9, 0x7f, 0x62, 0x96, 0x0e, 0x4e, 0xcc, 0xd2, 0xe1, 0x89, 0x59, 0x7a, 0x1b, + 0x9b, 0x60, 0x3f, 0x36, 0xc1, 0x41, 0x6c, 0x82, 0xc3, 0xd8, 0x04, 0xdf, 0x63, 0x13, 0x7c, 0xfa, + 0x61, 0x96, 0x76, 0x5a, 0x45, 0xff, 0xd8, 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xe2, 0xb1, + 0xf3, 0x1c, 0x09, 0x00, 0x00, +} + +func (m *ContainerMetrics) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ContainerMetrics) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ContainerMetrics) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Usage) > 0 { + keysForUsage := make([]string, 0, len(m.Usage)) + for k := range m.Usage { + keysForUsage = append(keysForUsage, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForUsage) + for iNdEx := len(keysForUsage) - 1; iNdEx >= 0; iNdEx-- { + v := m.Usage[k8s_io_api_core_v1.ResourceName(keysForUsage[iNdEx])] + baseI := i + { + size, err := ((*resource.Quantity)(&v)).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(keysForUsage[iNdEx]) + copy(dAtA[i:], keysForUsage[iNdEx]) + i = encodeVarintGenerated(dAtA, i, uint64(len(keysForUsage[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintGenerated(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *NodeMetrics) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NodeMetrics) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NodeMetrics) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Usage) > 0 { + keysForUsage := make([]string, 0, len(m.Usage)) + for k := range m.Usage { + keysForUsage = append(keysForUsage, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForUsage) + for iNdEx := len(keysForUsage) - 1; iNdEx >= 0; iNdEx-- { + v := m.Usage[k8s_io_api_core_v1.ResourceName(keysForUsage[iNdEx])] + baseI := i + { + size, err := ((*resource.Quantity)(&v)).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(keysForUsage[iNdEx]) + copy(dAtA[i:], keysForUsage[iNdEx]) + i = encodeVarintGenerated(dAtA, i, uint64(len(keysForUsage[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintGenerated(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Window.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Timestamp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.ObjectMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *NodeMetricsList) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NodeMetricsList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NodeMetricsList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.ListMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *PodMetrics) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PodMetrics) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PodMetrics) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Containers) > 0 { + for iNdEx := len(m.Containers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Containers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Window.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Timestamp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.ObjectMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *PodMetricsList) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PodMetricsList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PodMetricsList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.ListMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { + offset -= sovGenerated(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ContainerMetrics) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Usage) > 0 { + for k, v := range m.Usage { + _ = k + _ = v + l = ((*resource.Quantity)(&v)).Size() + mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + l + sovGenerated(uint64(l)) + n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) + } + } + return n +} + +func (m *NodeMetrics) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ObjectMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Timestamp.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Window.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Usage) > 0 { + for k, v := range m.Usage { + _ = k + _ = v + l = ((*resource.Quantity)(&v)).Size() + mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + l + sovGenerated(uint64(l)) + n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) + } + } + return n +} + +func (m *NodeMetricsList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ListMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func (m *PodMetrics) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ObjectMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Timestamp.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Window.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Containers) > 0 { + for _, e := range m.Containers { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func (m *PodMetricsList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ListMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func sovGenerated(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenerated(x uint64) (n int) { + return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *ContainerMetrics) String() string { + if this == nil { + return "nil" + } + keysForUsage := make([]string, 0, len(this.Usage)) + for k := range this.Usage { + keysForUsage = append(keysForUsage, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForUsage) + mapStringForUsage := "k8s_io_api_core_v1.ResourceList{" + for _, k := range keysForUsage { + mapStringForUsage += fmt.Sprintf("%v: %v,", k, this.Usage[k8s_io_api_core_v1.ResourceName(k)]) + } + mapStringForUsage += "}" + s := strings.Join([]string{`&ContainerMetrics{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Usage:` + mapStringForUsage + `,`, + `}`, + }, "") + return s +} +func (this *NodeMetrics) String() string { + if this == nil { + return "nil" + } + keysForUsage := make([]string, 0, len(this.Usage)) + for k := range this.Usage { + keysForUsage = append(keysForUsage, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForUsage) + mapStringForUsage := "k8s_io_api_core_v1.ResourceList{" + for _, k := range keysForUsage { + mapStringForUsage += fmt.Sprintf("%v: %v,", k, this.Usage[k8s_io_api_core_v1.ResourceName(k)]) + } + mapStringForUsage += "}" + s := strings.Join([]string{`&NodeMetrics{`, + `ObjectMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ObjectMeta), "ObjectMeta", "v1.ObjectMeta", 1), `&`, ``, 1) + `,`, + `Timestamp:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Timestamp), "Time", "v1.Time", 1), `&`, ``, 1) + `,`, + `Window:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Window), "Duration", "v1.Duration", 1), `&`, ``, 1) + `,`, + `Usage:` + mapStringForUsage + `,`, + `}`, + }, "") + return s +} +func (this *NodeMetricsList) String() string { + if this == nil { + return "nil" + } + repeatedStringForItems := "[]NodeMetrics{" + for _, f := range this.Items { + repeatedStringForItems += strings.Replace(strings.Replace(f.String(), "NodeMetrics", "NodeMetrics", 1), `&`, ``, 1) + "," + } + repeatedStringForItems += "}" + s := strings.Join([]string{`&NodeMetricsList{`, + `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v1.ListMeta", 1), `&`, ``, 1) + `,`, + `Items:` + repeatedStringForItems + `,`, + `}`, + }, "") + return s +} +func (this *PodMetrics) String() string { + if this == nil { + return "nil" + } + repeatedStringForContainers := "[]ContainerMetrics{" + for _, f := range this.Containers { + repeatedStringForContainers += strings.Replace(strings.Replace(f.String(), "ContainerMetrics", "ContainerMetrics", 1), `&`, ``, 1) + "," + } + repeatedStringForContainers += "}" + s := strings.Join([]string{`&PodMetrics{`, + `ObjectMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ObjectMeta), "ObjectMeta", "v1.ObjectMeta", 1), `&`, ``, 1) + `,`, + `Timestamp:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Timestamp), "Time", "v1.Time", 1), `&`, ``, 1) + `,`, + `Window:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Window), "Duration", "v1.Duration", 1), `&`, ``, 1) + `,`, + `Containers:` + repeatedStringForContainers + `,`, + `}`, + }, "") + return s +} +func (this *PodMetricsList) String() string { + if this == nil { + return "nil" + } + repeatedStringForItems := "[]PodMetrics{" + for _, f := range this.Items { + repeatedStringForItems += strings.Replace(strings.Replace(f.String(), "PodMetrics", "PodMetrics", 1), `&`, ``, 1) + "," + } + repeatedStringForItems += "}" + s := strings.Join([]string{`&PodMetricsList{`, + `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v1.ListMeta", 1), `&`, ``, 1) + `,`, + `Items:` + repeatedStringForItems + `,`, + `}`, + }, "") + return s +} +func valueToStringGenerated(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *ContainerMetrics) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ContainerMetrics: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContainerMetrics: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Usage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Usage == nil { + m.Usage = make(k8s_io_api_core_v1.ResourceList) + } + var mapkey k8s_io_api_core_v1.ResourceName + mapvalue := &resource.Quantity{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthGenerated + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = k8s_io_api_core_v1.ResourceName(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthGenerated + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthGenerated + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &resource.Quantity{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Usage[k8s_io_api_core_v1.ResourceName(mapkey)] = ((k8s_io_apimachinery_pkg_api_resource.Quantity)(*mapvalue)) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NodeMetrics) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NodeMetrics: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NodeMetrics: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Window", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Window.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Usage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Usage == nil { + m.Usage = make(k8s_io_api_core_v1.ResourceList) + } + var mapkey k8s_io_api_core_v1.ResourceName + mapvalue := &resource.Quantity{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthGenerated + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = k8s_io_api_core_v1.ResourceName(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthGenerated + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthGenerated + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &resource.Quantity{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Usage[k8s_io_api_core_v1.ResourceName(mapkey)] = ((k8s_io_apimachinery_pkg_api_resource.Quantity)(*mapvalue)) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NodeMetricsList) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NodeMetricsList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NodeMetricsList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, NodeMetrics{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PodMetrics) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PodMetrics: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PodMetrics: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Window", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Window.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Containers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Containers = append(m.Containers, ContainerMetrics{}) + if err := m.Containers[len(m.Containers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PodMetricsList) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PodMetricsList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PodMetricsList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, PodMetrics{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenerated(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenerated + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenerated + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenerated + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group") +) diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.proto b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.proto new file mode 100644 index 000000000..d1938a85c --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/generated.proto @@ -0,0 +1,95 @@ +/* +Copyright 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. +*/ + + +// This file was autogenerated by go-to-protobuf. Do not edit it manually! + +syntax = "proto2"; + +package k8s.io.metrics.pkg.apis.metrics.v1alpha1; + +import "k8s.io/api/core/v1/generated.proto"; +import "k8s.io/apimachinery/pkg/api/resource/generated.proto"; +import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; +import "k8s.io/apimachinery/pkg/runtime/generated.proto"; +import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; + +// Package-wide variables from generator "generated". +option go_package = "k8s.io/metrics/pkg/apis/metrics/v1alpha1"; + +// ContainerMetrics sets resource usage metrics of a container. +message ContainerMetrics { + // Container name corresponding to the one from pod.spec.containers. + optional string name = 1; + + // The memory usage is the memory working set. + map usage = 2; +} + +// NodeMetrics sets resource usage metrics of a node. +message NodeMetrics { + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; + + // The following fields define time interval from which metrics were + // collected from the interval [Timestamp-Window, Timestamp]. + optional k8s.io.apimachinery.pkg.apis.meta.v1.Time timestamp = 2; + + optional k8s.io.apimachinery.pkg.apis.meta.v1.Duration window = 3; + + // The memory usage is the memory working set. + map usage = 4; +} + +// NodeMetricsList is a list of NodeMetrics. +message NodeMetricsList { + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1; + + // List of node metrics. + repeated NodeMetrics items = 2; +} + +// PodMetrics sets resource usage metrics of a pod. +message PodMetrics { + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; + + // The following fields define time interval from which metrics were + // collected from the interval [Timestamp-Window, Timestamp]. + optional k8s.io.apimachinery.pkg.apis.meta.v1.Time timestamp = 2; + + optional k8s.io.apimachinery.pkg.apis.meta.v1.Duration window = 3; + + // Metrics for all containers are collected within the same time window. + repeated ContainerMetrics containers = 4; +} + +// PodMetricsList is a list of PodMetrics. +message PodMetricsList { + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1; + + // List of pod metrics. + repeated PodMetrics items = 2; +} + diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/register.go b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/register.go new file mode 100644 index 000000000..3e5359a8e --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/register.go @@ -0,0 +1,53 @@ +/* +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "metrics.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder points to a list of functions added to Scheme. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + localSchemeBuilder = &SchemeBuilder + // AddToScheme applies all the stored functions to the scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &NodeMetrics{}, + &NodeMetricsList{}, + &PodMetrics{}, + &PodMetricsList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/types.go b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/types.go new file mode 100644 index 000000000..871a3b177 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/types.go @@ -0,0 +1,101 @@ +/* +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 v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +resourceName=nodes +// +genclient:readonly +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NodeMetrics sets resource usage metrics of a node. +type NodeMetrics struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // The following fields define time interval from which metrics were + // collected from the interval [Timestamp-Window, Timestamp]. + Timestamp metav1.Time `json:"timestamp" protobuf:"bytes,2,opt,name=timestamp"` + Window metav1.Duration `json:"window" protobuf:"bytes,3,opt,name=window"` + + // The memory usage is the memory working set. + Usage v1.ResourceList `json:"usage" protobuf:"bytes,4,rep,name=usage,casttype=k8s.io/api/core/v1.ResourceList,castkey=k8s.io/api/core/v1.ResourceName,castvalue=k8s.io/apimachinery/pkg/api/resource.Quantity"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NodeMetricsList is a list of NodeMetrics. +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"` +} + +// +genclient +// +resourceName=pods +// +genclient:readonly +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodMetrics sets resource usage metrics of a pod. +type PodMetrics struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // The following fields define time interval from which metrics were + // collected from the interval [Timestamp-Window, Timestamp]. + Timestamp metav1.Time `json:"timestamp" protobuf:"bytes,2,opt,name=timestamp"` + Window metav1.Duration `json:"window" protobuf:"bytes,3,opt,name=window"` + + // Metrics for all containers are collected within the same time window. + Containers []ContainerMetrics `json:"containers" protobuf:"bytes,4,rep,name=containers"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodMetricsList is a list of PodMetrics. +type PodMetricsList 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 pod metrics. + Items []PodMetrics `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// ContainerMetrics sets resource usage metrics of a container. +type ContainerMetrics struct { + // Container name corresponding to the one from pod.spec.containers. + Name string `json:"name" protobuf:"bytes,1,opt,name=name"` + // The memory usage is the memory working set. + Usage v1.ResourceList `json:"usage" protobuf:"bytes,2,rep,name=usage,casttype=k8s.io/api/core/v1.ResourceList,castkey=k8s.io/api/core/v1.ResourceName,castvalue=k8s.io/apimachinery/pkg/api/resource.Quantity"` +} diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/zz_generated.conversion.go b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/zz_generated.conversion.go new file mode 100644 index 000000000..f29d64659 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/zz_generated.conversion.go @@ -0,0 +1,209 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by conversion-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + unsafe "unsafe" + + v1 "k8s.io/api/core/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + metrics "k8s.io/metrics/pkg/apis/metrics" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*ContainerMetrics)(nil), (*metrics.ContainerMetrics)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ContainerMetrics_To_metrics_ContainerMetrics(a.(*ContainerMetrics), b.(*metrics.ContainerMetrics), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*metrics.ContainerMetrics)(nil), (*ContainerMetrics)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_metrics_ContainerMetrics_To_v1alpha1_ContainerMetrics(a.(*metrics.ContainerMetrics), b.(*ContainerMetrics), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*NodeMetrics)(nil), (*metrics.NodeMetrics)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeMetrics_To_metrics_NodeMetrics(a.(*NodeMetrics), b.(*metrics.NodeMetrics), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*metrics.NodeMetrics)(nil), (*NodeMetrics)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_metrics_NodeMetrics_To_v1alpha1_NodeMetrics(a.(*metrics.NodeMetrics), b.(*NodeMetrics), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*NodeMetricsList)(nil), (*metrics.NodeMetricsList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeMetricsList_To_metrics_NodeMetricsList(a.(*NodeMetricsList), b.(*metrics.NodeMetricsList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*metrics.NodeMetricsList)(nil), (*NodeMetricsList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_metrics_NodeMetricsList_To_v1alpha1_NodeMetricsList(a.(*metrics.NodeMetricsList), b.(*NodeMetricsList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PodMetrics)(nil), (*metrics.PodMetrics)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_PodMetrics_To_metrics_PodMetrics(a.(*PodMetrics), b.(*metrics.PodMetrics), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*metrics.PodMetrics)(nil), (*PodMetrics)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_metrics_PodMetrics_To_v1alpha1_PodMetrics(a.(*metrics.PodMetrics), b.(*PodMetrics), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PodMetricsList)(nil), (*metrics.PodMetricsList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_PodMetricsList_To_metrics_PodMetricsList(a.(*PodMetricsList), b.(*metrics.PodMetricsList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*metrics.PodMetricsList)(nil), (*PodMetricsList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_metrics_PodMetricsList_To_v1alpha1_PodMetricsList(a.(*metrics.PodMetricsList), b.(*PodMetricsList), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha1_ContainerMetrics_To_metrics_ContainerMetrics(in *ContainerMetrics, out *metrics.ContainerMetrics, s conversion.Scope) error { + out.Name = in.Name + out.Usage = *(*v1.ResourceList)(unsafe.Pointer(&in.Usage)) + return nil +} + +// Convert_v1alpha1_ContainerMetrics_To_metrics_ContainerMetrics is an autogenerated conversion function. +func Convert_v1alpha1_ContainerMetrics_To_metrics_ContainerMetrics(in *ContainerMetrics, out *metrics.ContainerMetrics, s conversion.Scope) error { + return autoConvert_v1alpha1_ContainerMetrics_To_metrics_ContainerMetrics(in, out, s) +} + +func autoConvert_metrics_ContainerMetrics_To_v1alpha1_ContainerMetrics(in *metrics.ContainerMetrics, out *ContainerMetrics, s conversion.Scope) error { + out.Name = in.Name + out.Usage = *(*v1.ResourceList)(unsafe.Pointer(&in.Usage)) + return nil +} + +// Convert_metrics_ContainerMetrics_To_v1alpha1_ContainerMetrics is an autogenerated conversion function. +func Convert_metrics_ContainerMetrics_To_v1alpha1_ContainerMetrics(in *metrics.ContainerMetrics, out *ContainerMetrics, s conversion.Scope) error { + return autoConvert_metrics_ContainerMetrics_To_v1alpha1_ContainerMetrics(in, out, s) +} + +func autoConvert_v1alpha1_NodeMetrics_To_metrics_NodeMetrics(in *NodeMetrics, out *metrics.NodeMetrics, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Timestamp = in.Timestamp + out.Window = in.Window + out.Usage = *(*v1.ResourceList)(unsafe.Pointer(&in.Usage)) + return nil +} + +// Convert_v1alpha1_NodeMetrics_To_metrics_NodeMetrics is an autogenerated conversion function. +func Convert_v1alpha1_NodeMetrics_To_metrics_NodeMetrics(in *NodeMetrics, out *metrics.NodeMetrics, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeMetrics_To_metrics_NodeMetrics(in, out, s) +} + +func autoConvert_metrics_NodeMetrics_To_v1alpha1_NodeMetrics(in *metrics.NodeMetrics, out *NodeMetrics, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Timestamp = in.Timestamp + out.Window = in.Window + out.Usage = *(*v1.ResourceList)(unsafe.Pointer(&in.Usage)) + return nil +} + +// Convert_metrics_NodeMetrics_To_v1alpha1_NodeMetrics is an autogenerated conversion function. +func Convert_metrics_NodeMetrics_To_v1alpha1_NodeMetrics(in *metrics.NodeMetrics, out *NodeMetrics, s conversion.Scope) error { + return autoConvert_metrics_NodeMetrics_To_v1alpha1_NodeMetrics(in, out, s) +} + +func autoConvert_v1alpha1_NodeMetricsList_To_metrics_NodeMetricsList(in *NodeMetricsList, out *metrics.NodeMetricsList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]metrics.NodeMetrics)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NodeMetricsList_To_metrics_NodeMetricsList is an autogenerated conversion function. +func Convert_v1alpha1_NodeMetricsList_To_metrics_NodeMetricsList(in *NodeMetricsList, out *metrics.NodeMetricsList, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeMetricsList_To_metrics_NodeMetricsList(in, out, s) +} + +func autoConvert_metrics_NodeMetricsList_To_v1alpha1_NodeMetricsList(in *metrics.NodeMetricsList, out *NodeMetricsList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]NodeMetrics)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_metrics_NodeMetricsList_To_v1alpha1_NodeMetricsList is an autogenerated conversion function. +func Convert_metrics_NodeMetricsList_To_v1alpha1_NodeMetricsList(in *metrics.NodeMetricsList, out *NodeMetricsList, s conversion.Scope) error { + return autoConvert_metrics_NodeMetricsList_To_v1alpha1_NodeMetricsList(in, out, s) +} + +func autoConvert_v1alpha1_PodMetrics_To_metrics_PodMetrics(in *PodMetrics, out *metrics.PodMetrics, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Timestamp = in.Timestamp + out.Window = in.Window + out.Containers = *(*[]metrics.ContainerMetrics)(unsafe.Pointer(&in.Containers)) + return nil +} + +// Convert_v1alpha1_PodMetrics_To_metrics_PodMetrics is an autogenerated conversion function. +func Convert_v1alpha1_PodMetrics_To_metrics_PodMetrics(in *PodMetrics, out *metrics.PodMetrics, s conversion.Scope) error { + return autoConvert_v1alpha1_PodMetrics_To_metrics_PodMetrics(in, out, s) +} + +func autoConvert_metrics_PodMetrics_To_v1alpha1_PodMetrics(in *metrics.PodMetrics, out *PodMetrics, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Timestamp = in.Timestamp + out.Window = in.Window + out.Containers = *(*[]ContainerMetrics)(unsafe.Pointer(&in.Containers)) + return nil +} + +// Convert_metrics_PodMetrics_To_v1alpha1_PodMetrics is an autogenerated conversion function. +func Convert_metrics_PodMetrics_To_v1alpha1_PodMetrics(in *metrics.PodMetrics, out *PodMetrics, s conversion.Scope) error { + return autoConvert_metrics_PodMetrics_To_v1alpha1_PodMetrics(in, out, s) +} + +func autoConvert_v1alpha1_PodMetricsList_To_metrics_PodMetricsList(in *PodMetricsList, out *metrics.PodMetricsList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]metrics.PodMetrics)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_PodMetricsList_To_metrics_PodMetricsList is an autogenerated conversion function. +func Convert_v1alpha1_PodMetricsList_To_metrics_PodMetricsList(in *PodMetricsList, out *metrics.PodMetricsList, s conversion.Scope) error { + return autoConvert_v1alpha1_PodMetricsList_To_metrics_PodMetricsList(in, out, s) +} + +func autoConvert_metrics_PodMetricsList_To_v1alpha1_PodMetricsList(in *metrics.PodMetricsList, out *PodMetricsList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]PodMetrics)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_metrics_PodMetricsList_To_v1alpha1_PodMetricsList is an autogenerated conversion function. +func Convert_metrics_PodMetricsList_To_v1alpha1_PodMetricsList(in *metrics.PodMetricsList, out *PodMetricsList, s conversion.Scope) error { + return autoConvert_metrics_PodMetricsList_To_v1alpha1_PodMetricsList(in, out, s) +} diff --git a/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/zz_generated.deepcopy.go b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..9cd8619ec --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/apis/metrics/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,186 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerMetrics) DeepCopyInto(out *ContainerMetrics) { + *out = *in + if in.Usage != nil { + in, out := &in.Usage, &out.Usage + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerMetrics. +func (in *ContainerMetrics) DeepCopy() *ContainerMetrics { + if in == nil { + return nil + } + out := new(ContainerMetrics) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeMetrics) DeepCopyInto(out *NodeMetrics) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Timestamp.DeepCopyInto(&out.Timestamp) + out.Window = in.Window + if in.Usage != nil { + in, out := &in.Usage, &out.Usage + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeMetrics. +func (in *NodeMetrics) DeepCopy() *NodeMetrics { + if in == nil { + return nil + } + out := new(NodeMetrics) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeMetrics) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeMetricsList) DeepCopyInto(out *NodeMetricsList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NodeMetrics, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeMetricsList. +func (in *NodeMetricsList) DeepCopy() *NodeMetricsList { + if in == nil { + return nil + } + out := new(NodeMetricsList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeMetricsList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodMetrics) DeepCopyInto(out *PodMetrics) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Timestamp.DeepCopyInto(&out.Timestamp) + out.Window = in.Window + if in.Containers != nil { + in, out := &in.Containers, &out.Containers + *out = make([]ContainerMetrics, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMetrics. +func (in *PodMetrics) DeepCopy() *PodMetrics { + if in == nil { + return nil + } + out := new(PodMetrics) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodMetrics) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodMetricsList) DeepCopyInto(out *PodMetricsList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodMetrics, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMetricsList. +func (in *PodMetricsList) DeepCopy() *PodMetricsList { + if in == nil { + return nil + } + out := new(PodMetricsList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodMetricsList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/scheme/doc.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 000000000..7dc375616 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/scheme/register.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 000000000..a92b020a9 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,58 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + metricsv1alpha1 "k8s.io/metrics/pkg/apis/metrics/v1alpha1" + metricsv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + metricsv1alpha1.AddToScheme, + metricsv1beta1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/doc.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/doc.go new file mode 100644 index 000000000..771101956 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/generated_expansion.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/generated_expansion.go new file mode 100644 index 000000000..a89ca3c78 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type NodeMetricsExpansion interface{} + +type PodMetricsExpansion interface{} diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/metrics_client.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/metrics_client.go new file mode 100644 index 000000000..7a02cea2e --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/metrics_client.go @@ -0,0 +1,112 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "net/http" + + rest "k8s.io/client-go/rest" + v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" + "k8s.io/metrics/pkg/client/clientset/versioned/scheme" +) + +type MetricsV1beta1Interface interface { + RESTClient() rest.Interface + NodeMetricsesGetter + PodMetricsesGetter +} + +// MetricsV1beta1Client is used to interact with features provided by the metrics.k8s.io group. +type MetricsV1beta1Client struct { + restClient rest.Interface +} + +func (c *MetricsV1beta1Client) NodeMetricses() NodeMetricsInterface { + return newNodeMetricses(c) +} + +func (c *MetricsV1beta1Client) PodMetricses(namespace string) PodMetricsInterface { + return newPodMetricses(c, namespace) +} + +// NewForConfig creates a new MetricsV1beta1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*MetricsV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new MetricsV1beta1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*MetricsV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &MetricsV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new MetricsV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *MetricsV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new MetricsV1beta1Client for the given RESTClient. +func New(c rest.Interface) *MetricsV1beta1Client { + return &MetricsV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *MetricsV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go new file mode 100644 index 000000000..a312221ed --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go @@ -0,0 +1,98 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" + scheme "k8s.io/metrics/pkg/client/clientset/versioned/scheme" +) + +// NodeMetricsesGetter has a method to return a NodeMetricsInterface. +// A group's client should implement this interface. +type NodeMetricsesGetter interface { + NodeMetricses() NodeMetricsInterface +} + +// NodeMetricsInterface has methods to work with NodeMetrics resources. +type NodeMetricsInterface interface { + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.NodeMetrics, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.NodeMetricsList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + NodeMetricsExpansion +} + +// nodeMetricses implements NodeMetricsInterface +type nodeMetricses struct { + client rest.Interface +} + +// newNodeMetricses returns a NodeMetricses +func newNodeMetricses(c *MetricsV1beta1Client) *nodeMetricses { + return &nodeMetricses{ + client: c.RESTClient(), + } +} + +// Get takes name of the nodeMetrics, and returns the corresponding nodeMetrics object, and an error if there is any. +func (c *nodeMetricses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.NodeMetrics, err error) { + result = &v1beta1.NodeMetrics{} + err = c.client.Get(). + Resource("nodes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NodeMetricses that match those selectors. +func (c *nodeMetricses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.NodeMetricsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.NodeMetricsList{} + err = c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nodeMetricses. +func (c *nodeMetricses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} diff --git a/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go new file mode 100644 index 000000000..e66c377c2 --- /dev/null +++ b/vendor/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go @@ -0,0 +1,103 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" + scheme "k8s.io/metrics/pkg/client/clientset/versioned/scheme" +) + +// PodMetricsesGetter has a method to return a PodMetricsInterface. +// A group's client should implement this interface. +type PodMetricsesGetter interface { + PodMetricses(namespace string) PodMetricsInterface +} + +// PodMetricsInterface has methods to work with PodMetrics resources. +type PodMetricsInterface interface { + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.PodMetrics, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PodMetricsList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + PodMetricsExpansion +} + +// podMetricses implements PodMetricsInterface +type podMetricses struct { + client rest.Interface + ns string +} + +// newPodMetricses returns a PodMetricses +func newPodMetricses(c *MetricsV1beta1Client, namespace string) *podMetricses { + return &podMetricses{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the podMetrics, and returns the corresponding podMetrics object, and an error if there is any. +func (c *podMetricses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.PodMetrics, err error) { + result = &v1beta1.PodMetrics{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pods"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PodMetricses that match those selectors. +func (c *podMetricses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PodMetricsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PodMetricsList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pods"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podMetricses. +func (c *podMetricses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("pods"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f27d35a68..8ddb56ae1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1686,7 +1686,10 @@ k8s.io/kubernetes/pkg/apis/storage/util # k8s.io/metrics v0.28.1 ## explicit; go 1.20 k8s.io/metrics/pkg/apis/metrics +k8s.io/metrics/pkg/apis/metrics/v1alpha1 k8s.io/metrics/pkg/apis/metrics/v1beta1 +k8s.io/metrics/pkg/client/clientset/versioned/scheme +k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1 # k8s.io/pod-security-admission v0.28.1 ## explicit; go 1.20 k8s.io/pod-security-admission/admission