k8s.io/perf-tests/clusterloader2@v0.0.0-20240304094227-64bdb12da87e/pkg/provider/gke.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 GKEProvider struct { 26 features Features 27 } 28 29 func NewGKEProvider(_ map[string]string) Provider { 30 return &GKEProvider{ 31 features: Features{ 32 SupportProbe: true, 33 SupportImagePreload: true, 34 SupportSnapshotPrometheusDisk: true, 35 SupportEnablePrometheusServer: true, 36 SupportGrabMetricsFromKubelets: true, 37 SupportAccessAPIServerPprofEndpoint: true, 38 SupportNodeKiller: true, 39 SupportResourceUsageMetering: true, 40 ShouldPrometheusScrapeApiserverOnly: true, 41 ShouldScrapeKubeProxy: false, 42 SupportKubeStateMetrics: true, 43 }, 44 } 45 } 46 47 func (p *GKEProvider) Name() string { 48 return GKEName 49 } 50 51 func (p *GKEProvider) Features() *Features { 52 return &p.features 53 } 54 55 func (p *GKEProvider) GetComponentProtocolAndPort(componentName string) (string, int, error) { 56 return getComponentProtocolAndPort(componentName) 57 } 58 59 func (p *GKEProvider) GetConfig() Config { 60 return Config{} 61 } 62 63 func (p *GKEProvider) RunSSHCommand(cmd, host string) (string, string, int, error) { 64 // gke provider takes ssh key from GCE_SSH_KEY. 65 r, err := sshutil.SSH(cmd, host, "gke") 66 return r.Stdout, r.Stderr, r.Code, err 67 } 68 69 func (p *GKEProvider) Metadata(client clientset.Interface) (map[string]string, error) { 70 return nil, nil 71 } 72 73 func (p *GKEProvider) GetManagedPrometheusClient() (prom.Client, error) { 74 return prom.NewGCPManagedPrometheusClient() 75 }