@@ -53,9 +53,8 @@ func defaultAssetPath(binary string) string {
5353
5454}
5555
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 {
5958 "--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}" ,
6059 "--cert-dir={{ .CertDir }}" ,
6160 "--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}" ,
@@ -93,6 +92,9 @@ type Environment struct {
9392 // may take to stop. It defaults to the KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT
9493 // environment variable or 20 seconds if unspecified
9594 ControlPlaneStopTimeout time.Duration
95+
96+ // KubeAPIServerFlags is the set of flags passed while starting the api server.
97+ KubeAPIServerFlags []string
9698}
9799
98100// Stop stops a running server
@@ -103,6 +105,15 @@ func (te *Environment) Stop() error {
103105 return te .ControlPlane .Stop ()
104106}
105107
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+
106117// Start starts a local Kubernetes server and updates te.ApiserverPort with the port it is listening on
107118func (te * Environment ) Start () (* rest.Config , error ) {
108119 if te .UseExistingCluster {
@@ -118,7 +129,7 @@ func (te *Environment) Start() (*rest.Config, error) {
118129 }
119130 } else {
120131 te .ControlPlane = integration.ControlPlane {}
121- te .ControlPlane .APIServer = & integration.APIServer {Args : defaultKubeAPIServerFlags }
132+ te .ControlPlane .APIServer = & integration.APIServer {Args : te . getAPIServerFlags () }
122133 te .ControlPlane .Etcd = & integration.Etcd {}
123134
124135 if os .Getenv (envKubeAPIServerBin ) == "" {
0 commit comments