@@ -53,9 +53,8 @@ func defaultAssetPath(binary string) string {
53
53
54
54
}
55
55
56
- // APIServerDefaultArgs are flags necessary to bring up apiserver.
57
- // TODO: create test framework interface to append flag to default flags.
58
- var defaultKubeAPIServerFlags = []string {
56
+ // DefaultKubeAPIServerFlags are default flags necessary to bring up apiserver.
57
+ var DefaultKubeAPIServerFlags = []string {
59
58
"--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}" ,
60
59
"--cert-dir={{ .CertDir }}" ,
61
60
"--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}" ,
@@ -93,6 +92,9 @@ type Environment struct {
93
92
// may take to stop. It defaults to the KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT
94
93
// environment variable or 20 seconds if unspecified
95
94
ControlPlaneStopTimeout time.Duration
95
+
96
+ // KubeAPIServerFlags is the set of flags passed while starting the api server.
97
+ KubeAPIServerFlags []string
96
98
}
97
99
98
100
// Stop stops a running server
@@ -103,6 +105,15 @@ func (te *Environment) Stop() error {
103
105
return te .ControlPlane .Stop ()
104
106
}
105
107
108
+ // getAPIServerFlags returns flags to be used with the Kubernetes API server.
109
+ func (te Environment ) getAPIServerFlags () []string {
110
+ // Set default API server flags if not set.
111
+ if len (te .KubeAPIServerFlags ) == 0 {
112
+ return DefaultKubeAPIServerFlags
113
+ }
114
+ return te .KubeAPIServerFlags
115
+ }
116
+
106
117
// Start starts a local Kubernetes server and updates te.ApiserverPort with the port it is listening on
107
118
func (te * Environment ) Start () (* rest.Config , error ) {
108
119
if te .UseExistingCluster {
@@ -118,7 +129,7 @@ func (te *Environment) Start() (*rest.Config, error) {
118
129
}
119
130
} else {
120
131
te .ControlPlane = integration.ControlPlane {}
121
- te .ControlPlane .APIServer = & integration.APIServer {Args : defaultKubeAPIServerFlags }
132
+ te .ControlPlane .APIServer = & integration.APIServer {Args : te . getAPIServerFlags () }
122
133
te .ControlPlane .Etcd = & integration.Etcd {}
123
134
124
135
if os .Getenv (envKubeAPIServerBin ) == "" {
0 commit comments