k8s.io/perf-tests/clusterloader2@v0.0.0-20240304094227-64bdb12da87e/pkg/provider/vsphere.go (about)

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package provider
    18  
    19  import (
    20  	clientset "k8s.io/client-go/kubernetes"
    21  	sshutil "k8s.io/kubernetes/test/e2e/framework/ssh"
    22  	prom "k8s.io/perf-tests/clusterloader2/pkg/prometheus/clients"
    23  )
    24  
    25  type VsphereProvider struct {
    26  	features Features
    27  }
    28  
    29  func NewVsphereProvider(_ map[string]string) Provider {
    30  	return &VsphereProvider{
    31  		features: Features{
    32  			SupportProbe:                        true,
    33  			SupportSSHToMaster:                  true,
    34  			SupportImagePreload:                 true,
    35  			SupportEnablePrometheusServer:       true,
    36  			SupportGrabMetricsFromKubelets:      true,
    37  			SupportAccessAPIServerPprofEndpoint: true,
    38  			SupportResourceUsageMetering:        true,
    39  			ShouldScrapeKubeProxy:               true,
    40  		},
    41  	}
    42  }
    43  
    44  func (p *VsphereProvider) Name() string {
    45  	return VsphereName
    46  }
    47  
    48  func (p *VsphereProvider) Features() *Features {
    49  	return &p.features
    50  }
    51  
    52  func (p *VsphereProvider) GetComponentProtocolAndPort(componentName string) (string, int, error) {
    53  	return getComponentProtocolAndPort(componentName)
    54  }
    55  
    56  func (p *VsphereProvider) GetConfig() Config {
    57  	return Config{}
    58  }
    59  
    60  func (p *VsphereProvider) RunSSHCommand(cmd, host string) (string, string, int, error) {
    61  	// skeleton provider takes ssh key from KUBE_SSH_KEY.
    62  	// TODO(mborsz): Migrate to "vsphere" and LOCAL_SSH_KEY?
    63  	r, err := sshutil.SSH(cmd, host, "skeleton")
    64  	return r.Stdout, r.Stderr, r.Code, err
    65  }
    66  
    67  func (p *VsphereProvider) Metadata(client clientset.Interface) (map[string]string, error) {
    68  	return nil, nil
    69  }
    70  
    71  func (p *VsphereProvider) GetManagedPrometheusClient() (prom.Client, error) {
    72  	return nil, ErrNoManagedPrometheus
    73  }