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

     1  /*
     2  Copyright 2018 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 config
    18  
    19  import (
    20  	"time"
    21  
    22  	"k8s.io/perf-tests/clusterloader2/pkg/provider"
    23  )
    24  
    25  // ClusterLoaderConfig represents all single test run parameters used by CLusterLoader.
    26  type ClusterLoaderConfig struct {
    27  	ClusterConfig     ClusterConfig
    28  	ReportDir         string
    29  	ExecServiceConfig ExecServiceConfig
    30  	ModifierConfig    ModifierConfig
    31  	PrometheusConfig  PrometheusConfig
    32  	// OverridePaths defines what override files should be applied
    33  	// globally to the config specified by the ConfigPath for each TestScenario.
    34  	OverridePaths []string `json:"overridePaths"`
    35  }
    36  
    37  // ClusterConfig is a structure that represents cluster description.
    38  type ClusterConfig struct {
    39  	KubeConfigPath      string
    40  	RunFromCluster      bool
    41  	Nodes               int
    42  	Provider            provider.Provider
    43  	EtcdCertificatePath string
    44  	EtcdKeyPath         string
    45  	EtcdInsecurePort    int
    46  	MasterIPs           []string
    47  	MasterInternalIPs   []string
    48  	MasterName          string
    49  	// Deprecated: use NamespaceConfig.DeleteStaleNamespaces instead.
    50  	DeleteStaleNamespaces bool
    51  	// TODO(#1696): Clean up after removing automanagedNamespaces
    52  	DeleteAutomanagedNamespaces bool
    53  	// APIServerPprofByClientEnabled determines whether kube-apiserver pprof endpoint can be accessed
    54  	// using kubernetes client. If false, clusterloader will avoid collecting kube-apiserver profiles.
    55  	APIServerPprofByClientEnabled bool
    56  	KubeletPort                   int
    57  	K8SClientsNumber              int
    58  	SkipClusterVerification       bool
    59  }
    60  
    61  // ExecServiceConfig represents all flags used by service config.
    62  type ExecServiceConfig struct {
    63  	// Determines if service config should be enabled.
    64  	Enable bool
    65  }
    66  
    67  // ModifierConfig represent all flags used by test modification
    68  type ModifierConfig struct {
    69  	// A list of overwrites applied to each test config
    70  	OverwriteTestConfig []string
    71  	// A list of names of steps that should be ignored when executing test run
    72  	SkipSteps []string
    73  }
    74  
    75  // PrometheusConfig represents all flags used by prometheus.
    76  type PrometheusConfig struct {
    77  	TearDownServer             bool
    78  	EnableServer               bool
    79  	EnablePushgateway          bool
    80  	ScrapeEtcd                 bool
    81  	ScrapeNodeExporter         bool
    82  	ScrapeWindowsNodeExporter  bool
    83  	ScrapeKubelets             bool
    84  	ScrapeMasterKubelets       bool
    85  	ScrapeKubeProxy            bool
    86  	KubeProxySelectorKey       string
    87  	ScrapeKubeStateMetrics     bool
    88  	ScrapeMetricsServerMetrics bool
    89  	ScrapeNodeLocalDNS         bool
    90  	ScrapeAnet                 bool
    91  	ScrapeCiliumOperator       bool
    92  	ScrapeMastersWithPublicIPs bool
    93  	APIServerScrapePort        int
    94  	SnapshotProject            string
    95  	ManifestPath               string
    96  	StorageClassProvisioner    string
    97  	StorageClassVolumeType     string
    98  	PVCStorageClass            string
    99  	ReadyTimeout               time.Duration
   100  	PrometheusMemoryRequest    string
   101  }
   102  
   103  // GetMasterIP returns the first master ip, added for backward compatibility.
   104  // TODO(mmatt): Remove this method once all the codebase is migrated to support multiple masters.
   105  func (c *ClusterConfig) GetMasterIP() string {
   106  	if len(c.MasterIPs) > 0 {
   107  		return c.MasterIPs[0]
   108  	}
   109  	return ""
   110  }
   111  
   112  // GetMasterInternalIP returns the first internal master ip, added for backward compatibility.
   113  // TODO(mmatt): Remove this method once all the codebase is migrated to support multiple masters.
   114  func (c *ClusterConfig) GetMasterInternalIP() string {
   115  	if len(c.MasterInternalIPs) > 0 {
   116  		return c.MasterInternalIPs[0]
   117  	}
   118  	return ""
   119  }