Skip to content

Commit

Permalink
Merge pull request #763 from alenkacz/av/apiserver-defaults
Browse files Browse the repository at this point in the history
✨ (:sparkles, minor) APIServer defaults deduplication
  • Loading branch information
k8s-ci-robot committed Feb 4, 2020
2 parents 65d0423 + 901839a commit 5e2c4c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
18 changes: 2 additions & 16 deletions pkg/envtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,6 @@ func defaultAssetPath(binary string) string {

}

// DefaultKubeAPIServerFlags are default flags necessary to bring up apiserver.
var DefaultKubeAPIServerFlags = []string{
// Allow tests to run offline, by preventing API server from attempting to
// use default route to determine its --advertise-address
"--advertise-address=127.0.0.1",
"--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}",
"--cert-dir={{ .CertDir }}",
"--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}",
"--insecure-bind-address={{ if .URL }}{{ .URL.Hostname }}{{ end }}",
"--secure-port={{ if .SecurePort }}{{ .SecurePort }}{{ end }}",
"--admission-control=AlwaysAdmit",
"--service-cluster-ip-range=10.0.0.0/24",
"--allow-privileged=true",
}

// Environment creates a Kubernetes test environment that will start / stop the Kubernetes control plane and
// install extension APIs
type Environment struct {
Expand Down Expand Up @@ -156,10 +141,11 @@ func (te *Environment) Stop() error {
}

// getAPIServerFlags returns flags to be used with the Kubernetes API server.
// it returns empty slice for api server defined defaults to be applied if no args specified
func (te Environment) getAPIServerFlags() []string {
// Set default API server flags if not set.
if len(te.KubeAPIServerFlags) == 0 {
return DefaultKubeAPIServerFlags
return []string{}
}
// Check KubeAPIServerFlags contains service-cluster-ip-range, if not, set default value to service-cluster-ip-range
containServiceClusterIPRange := false
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/testing/integration/internal/apiserver.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package internal

var APIServerDefaultArgs = []string{
// Allow tests to run offline, by preventing API server from attempting to
// use default route to determine its --advertise-address
"--advertise-address=127.0.0.1",
"--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}",
"--cert-dir={{ .CertDir }}",
"--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}",
"--insecure-bind-address={{ if .URL }}{{ .URL.Hostname }}{{ end }}",
"--secure-port={{ if .SecurePort }}{{ .SecurePort }}{{ end }}",
"--admission-control=AlwaysAdmit",
"--service-cluster-ip-range=10.0.0.0/24",
"--allow-privileged=true",
}

func DoAPIServerArgDefaulting(args []string) []string {
Expand Down

0 comments on commit 5e2c4c8

Please sign in to comment.