k8s.io/perf-tests/clusterloader2@v0.0.0-20240304094227-64bdb12da87e/pkg/provider/kubemark.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 "k8s.io/klog/v2" 22 sshutil "k8s.io/kubernetes/test/e2e/framework/ssh" 23 prom "k8s.io/perf-tests/clusterloader2/pkg/prometheus/clients" 24 ) 25 26 type KubemarkProvider struct { 27 features Features 28 config Config 29 } 30 31 func NewKubemarkProvider(config map[string]string) *KubemarkProvider { 32 supportEnablePrometheusServer := true 33 if config[RootKubeConfigKey] == "" { 34 klog.Warningf("no kubemark-root-kubeconfig path specified. SupportEnablePrometheusServer will be false.") 35 supportEnablePrometheusServer = false 36 } 37 return &KubemarkProvider{ 38 features: Features{ 39 IsKubemarkProvider: true, 40 SupportSSHToMaster: true, 41 SupportEnablePrometheusServer: supportEnablePrometheusServer, 42 SupportAccessAPIServerPprofEndpoint: true, 43 SupportSnapshotPrometheusDisk: true, 44 SupportResourceUsageMetering: true, 45 ShouldScrapeKubeProxy: true, 46 }, 47 config: config, 48 } 49 } 50 51 func (p *KubemarkProvider) Name() string { 52 return KubemarkName 53 } 54 55 func (p *KubemarkProvider) Features() *Features { 56 return &p.features 57 } 58 59 func (p *KubemarkProvider) GetComponentProtocolAndPort(componentName string) (string, int, error) { 60 return getComponentProtocolAndPort(componentName) 61 } 62 63 func (p *KubemarkProvider) GetConfig() Config { 64 return p.config 65 } 66 67 func (p *KubemarkProvider) RunSSHCommand(cmd, host string) (string, string, int, error) { 68 // kubemark provider takes ssh key from GCE_SSH_KEY. 69 r, err := sshutil.SSH(cmd, host, "kubemark") 70 return r.Stdout, r.Stderr, r.Code, err 71 } 72 73 // TODO(mborsz): Dump instanceIDs for master nodes (as in gce). 74 func (p *KubemarkProvider) Metadata(client clientset.Interface) (map[string]string, error) { 75 return nil, nil 76 } 77 78 func (p *KubemarkProvider) GetManagedPrometheusClient() (prom.Client, error) { 79 return nil, ErrNoManagedPrometheus 80 }