Merge pull request #23025 from nikhiljindal/disableSwaggerUI

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-03-24 00:55:06 -07:00
commit 76fde46b16
8 changed files with 60 additions and 27 deletions

View File

@ -58,6 +58,7 @@ type APIServer struct {
EnableLogsSupport bool EnableLogsSupport bool
EnableProfiling bool EnableProfiling bool
EnableWatchCache bool EnableWatchCache bool
EnableSwaggerUI bool
EtcdServersOverrides []string EtcdServersOverrides []string
EtcdConfig etcdstorage.EtcdConfig EtcdConfig etcdstorage.EtcdConfig
EventTTL time.Duration EventTTL time.Duration
@ -244,6 +245,7 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/") fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
// TODO: enable cache in integration tests. // TODO: enable cache in integration tests.
fs.BoolVar(&s.EnableWatchCache, "watch-cache", true, "Enable watch caching in the apiserver") fs.BoolVar(&s.EnableWatchCache, "watch-cache", true, "Enable watch caching in the apiserver")
fs.BoolVar(&s.EnableSwaggerUI, "enable-swagger-ui", false, "Enables swagger ui on the apiserver at /swagger-ui")
fs.StringVar(&s.ExternalHost, "external-hostname", "", "The hostname to use when generating externalized URLs for this master (e.g. Swagger API Docs.)") fs.StringVar(&s.ExternalHost, "external-hostname", "", "The hostname to use when generating externalized URLs for this master (e.g. Swagger API Docs.)")
fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", 400, "The maximum number of requests in flight at a given time. When the server exceeds this, it rejects requests. Zero for no limit.") fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", 400, "The maximum number of requests in flight at a given time. When the server exceeds this, it rejects requests. Zero for no limit.")
fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", 1800, "An optional field indicating the minimum number of seconds a handler must keep a request open before timing it out. Currently only honored by the watch request handler, which picks a randomized value above this number as the connection timeout, to spread out load.") fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", 1800, "An optional field indicating the minimum number of seconds a handler must keep a request open before timing it out. Currently only honored by the watch request handler, which picks a randomized value above this number as the connection timeout, to spread out load.")

View File

@ -20,6 +20,8 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/spf13/pflag"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
@ -76,3 +78,22 @@ func TestGenerateStorageVersionMap(t *testing.T) {
} }
} }
} }
func TestAddFlagsFlag(t *testing.T) {
// TODO: This only tests the enable-swagger-ui flag for now.
// Expand the test to include other flags as well.
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
s := NewAPIServer()
s.AddFlags(f)
if s.EnableSwaggerUI {
t.Errorf("Expected s.EnableSwaggerUI to be false by default")
}
args := []string{
"--enable-swagger-ui=true",
}
f.Parse(args)
if !s.EnableSwaggerUI {
t.Errorf("Expected s.EnableSwaggerUI to be true")
}
}

View File

@ -451,6 +451,7 @@ func Run(s *options.APIServer) error {
EnableLogsSupport: s.EnableLogsSupport, EnableLogsSupport: s.EnableLogsSupport,
EnableUISupport: true, EnableUISupport: true,
EnableSwaggerSupport: true, EnableSwaggerSupport: true,
EnableSwaggerUI: s.EnableSwaggerUI,
EnableProfiling: s.EnableProfiling, EnableProfiling: s.EnableProfiling,
EnableWatchCache: s.EnableWatchCache, EnableWatchCache: s.EnableWatchCache,
EnableIndex: true, EnableIndex: true,

View File

@ -67,6 +67,7 @@ kube-apiserver
--cloud-provider="": The provider for cloud services. Empty string for no provider. --cloud-provider="": The provider for cloud services. Empty string for no provider.
--cors-allowed-origins=[]: List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled. --cors-allowed-origins=[]: List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled.
--delete-collection-workers=1: Number of workers spawned for DeleteCollection call. These are used to speed up namespace cleanup. --delete-collection-workers=1: Number of workers spawned for DeleteCollection call. These are used to speed up namespace cleanup.
--enable-swagger-ui[=false]: Enables swagger ui on the apiserver at /swagger-ui
--etcd-cafile="": SSL Certificate Authority file used to secure etcd communication --etcd-cafile="": SSL Certificate Authority file used to secure etcd communication
--etcd-certfile="": SSL certification file used to secure etcd communication --etcd-certfile="": SSL certification file used to secure etcd communication
--etcd-keyfile="": SSL key file used to secure etcd communication --etcd-keyfile="": SSL key file used to secure etcd communication

View File

@ -38,7 +38,7 @@ Primary system and API concepts are documented in the [User guide](user-guide/RE
Overall API conventions are described in the [API conventions doc](devel/api-conventions.md). Overall API conventions are described in the [API conventions doc](devel/api-conventions.md).
Complete API details are documented via [Swagger](http://swagger.io/). The Kubernetes apiserver (aka "master") exports an API that can be used to retrieve the [Swagger spec](https://github.com/swagger-api/swagger-spec/tree/master/schemas/v1.2) for the Kubernetes API, by default at `/swaggerapi`, and a UI you can use to browse the API documentation at `/swagger-ui`. We also host generated [API reference docs](api-reference/README.md). Complete API details are documented via [Swagger](http://swagger.io/). The Kubernetes apiserver (aka "master") exports an API that can be used to retrieve the [Swagger spec](https://github.com/swagger-api/swagger-spec/tree/master/schemas/v1.2) for the Kubernetes API, by default at `/swaggerapi`. It also exports a UI you can use to browse the API documentation at `/swagger-ui` if the apiserver is passed --enable-swagger-ui=true flag. We also host generated [API reference docs](api-reference/README.md).
Remote access to the API is discussed in the [access doc](admin/accessing-the-api.md). Remote access to the API is discussed in the [access doc](admin/accessing-the-api.md).

View File

@ -21,8 +21,8 @@ auth-path
authorization-mode authorization-mode
authorization-policy-file authorization-policy-file
authorization-webhook-config-file authorization-webhook-config-file
basic-auth-file
babysit-daemons babysit-daemons
basic-auth-file
bench-pods bench-pods
bench-quiet bench-quiet
bench-tasks bench-tasks
@ -43,6 +43,9 @@ cleanup-iptables
client-ca-file client-ca-file
client-certificate client-certificate
client-key client-key
clientset-name
clientset-only
clientset-path
cloud-config cloud-config
cloud-provider cloud-provider
cluster-cidr cluster-cidr
@ -52,9 +55,9 @@ cluster-name
cluster-tag cluster-tag
concurrent-deployment-syncs concurrent-deployment-syncs
concurrent-endpoint-syncs concurrent-endpoint-syncs
concurrent-namespace-syncs
concurrent-replicaset-syncs concurrent-replicaset-syncs
concurrent-resource-quota-syncs concurrent-resource-quota-syncs
concurrent-namespace-syncs
config-sync-period config-sync-period
configure-cbr0 configure-cbr0
conntrack-max conntrack-max
@ -97,16 +100,17 @@ enable-custom-metrics
enable-debugging-handlers enable-debugging-handlers
enable-hostpath-provisioner enable-hostpath-provisioner
enable-server enable-server
enable-swagger-ui
etcd-cafile
etcd-certfile
etcd-config etcd-config
etcd-keyfile
etcd-mutation-timeout etcd-mutation-timeout
etcd-prefix etcd-prefix
etcd-quorum-read etcd-quorum-read
etcd-server etcd-server
etcd-servers etcd-servers
etcd-servers-overrides etcd-servers-overrides
etcd-keyfile
etcd-certfile
etcd-cafile
event-burst event-burst
event-qps event-qps
event-ttl event-ttl
@ -120,6 +124,7 @@ experimental-prefix
external-hostname external-hostname
external-ip external-ip
failover-timeout failover-timeout
fake-clientset
file-check-frequency file-check-frequency
file-suffix file-suffix
file_content_in_loop file_content_in_loop
@ -142,6 +147,7 @@ go-header-file
google-json-key google-json-key
grace-period grace-period
ha-domain ha-domain
hairpin-mode
healthz-bind-address healthz-bind-address
healthz-port healthz-port
horizontal-pod-autoscaler-sync-period horizontal-pod-autoscaler-sync-period
@ -165,20 +171,22 @@ iptables-masquerade-bit
iptables-sync-period iptables-sync-period
ir-data-source ir-data-source
ir-dbname ir-dbname
ir-hawkular
ir-influxdb-host ir-influxdb-host
ir-namespace-only ir-namespace-only
ir-password ir-password
ir-user ir-user
ir-hawkular
jenkins-host jenkins-host
jenkins-jobs jenkins-jobs
k8s-build-output
k8s-bin-dir k8s-bin-dir
k8s-build-output
keep-gogoproto keep-gogoproto
km-path km-path
kube-api-burst kube-api-burst
kube-api-qps kube-api-qps
kube-master kube-master
kube-master
kube-master-url
kube-reserved kube-reserved
kubecfg-file kubecfg-file
kubectl-path kubectl-path
@ -201,14 +209,17 @@ kubelet-read-only-port
kubelet-root-dir kubelet-root-dir
kubelet-sync-frequency kubelet-sync-frequency
kubelet-timeout kubelet-timeout
kube-master
kube-master-url
kubernetes-service-node-port kubernetes-service-node-port
label-columns label-columns
last-release-pr last-release-pr
leader-elect
leader-elect-lease-duration
leader-elect-renew-deadline
leader-elect-retry-period
leave-stdin-open leave-stdin-open
limit-bytes limit-bytes
load-balancer-ip load-balancer-ip
lock-file
log-flush-frequency log-flush-frequency
long-running-request-regexp long-running-request-regexp
low-diskspace-threshold-mb low-diskspace-threshold-mb
@ -268,8 +279,8 @@ non-masquerade-cidr
num-nodes num-nodes
oidc-ca-file oidc-ca-file
oidc-client-id oidc-client-id
oidc-issuer-url
oidc-groups-claim oidc-groups-claim
oidc-issuer-url
oidc-username-claim oidc-username-claim
only-idl only-idl
oom-score-adj oom-score-adj
@ -297,11 +308,11 @@ proxy-mode
proxy-port-range proxy-port-range
public-address-override public-address-override
pv-recycler-increment-timeout-nfs pv-recycler-increment-timeout-nfs
pv-recycler-maximum-retry
pv-recycler-minimum-timeout-hostpath pv-recycler-minimum-timeout-hostpath
pv-recycler-minimum-timeout-nfs pv-recycler-minimum-timeout-nfs
pv-recycler-pod-template-filepath-hostpath pv-recycler-pod-template-filepath-hostpath
pv-recycler-pod-template-filepath-nfs pv-recycler-pod-template-filepath-nfs
pv-recycler-maximum-retry
pv-recycler-timeout-increment-hostpath pv-recycler-timeout-increment-hostpath
pvclaimbinder-sync-period pvclaimbinder-sync-period
read-only-port read-only-port
@ -317,8 +328,8 @@ registry-qps
reject-methods reject-methods
reject-paths reject-paths
repair-malformed-updates repair-malformed-updates
replication-controller-lookup-cache-size
replicaset-lookup-cache-size replicaset-lookup-cache-size
replication-controller-lookup-cache-size
repo-root repo-root
report-dir report-dir
required-contexts required-contexts
@ -332,8 +343,8 @@ rkt-stage1-image
root-ca-file root-ca-file
root-dir root-dir
run-proxy run-proxy
runtime-config
runtime-cgroups runtime-cgroups
runtime-config
save-config save-config
scheduler-config scheduler-config
scheduler-name scheduler-name
@ -399,18 +410,8 @@ volume-dir
volume-plugin-dir volume-plugin-dir
volume-stats-agg-period volume-stats-agg-period
watch-cache watch-cache
watch-cache-sizes
watch-only watch-only
whitelist-override-label whitelist-override-label
windows-line-endings windows-line-endings
www-prefix www-prefix
clientset-name
clientset-only
clientset-path
fake-clientset
leader-elect
leader-elect-lease-duration
leader-elect-renew-deadline
leader-elect-retry-period
watch-cache-sizes
lock-file
hairpin-mode

View File

@ -210,8 +210,12 @@ type Config struct {
// allow downstream consumers to disable the core controller loops // allow downstream consumers to disable the core controller loops
EnableLogsSupport bool EnableLogsSupport bool
EnableUISupport bool EnableUISupport bool
// allow downstream consumers to disable swagger // Allow downstream consumers to disable swagger.
// This includes returning the generated swagger spec at /swaggerapi and swagger ui at /swagger-ui.
EnableSwaggerSupport bool EnableSwaggerSupport bool
// Allow downstream consumers to disable swagger ui.
// Note that this is ignored if either EnableSwaggerSupport or EnableUISupport is false.
EnableSwaggerUI bool
// Allows api group versions or specific resources to be conditionally enabled/disabled. // Allows api group versions or specific resources to be conditionally enabled/disabled.
APIGroupVersionOverrides map[string]APIGroupVersionOverride APIGroupVersionOverrides map[string]APIGroupVersionOverride
// allow downstream consumers to disable the index route // allow downstream consumers to disable the index route
@ -307,6 +311,7 @@ type GenericAPIServer struct {
enableLogsSupport bool enableLogsSupport bool
enableUISupport bool enableUISupport bool
enableSwaggerSupport bool enableSwaggerSupport bool
enableSwaggerUI bool
enableProfiling bool enableProfiling bool
enableWatchCache bool enableWatchCache bool
APIPrefix string APIPrefix string
@ -451,6 +456,7 @@ func New(c *Config) (*GenericAPIServer, error) {
enableLogsSupport: c.EnableLogsSupport, enableLogsSupport: c.EnableLogsSupport,
enableUISupport: c.EnableUISupport, enableUISupport: c.EnableUISupport,
enableSwaggerSupport: c.EnableSwaggerSupport, enableSwaggerSupport: c.EnableSwaggerSupport,
enableSwaggerUI: c.EnableSwaggerUI,
enableProfiling: c.EnableProfiling, enableProfiling: c.EnableProfiling,
enableWatchCache: c.EnableWatchCache, enableWatchCache: c.EnableWatchCache,
APIPrefix: c.APIPrefix, APIPrefix: c.APIPrefix,
@ -553,7 +559,7 @@ func (s *GenericAPIServer) init(c *Config) {
apiserver.InstallLogsSupport(s.MuxHelper) apiserver.InstallLogsSupport(s.MuxHelper)
} }
if c.EnableUISupport { if c.EnableUISupport {
ui.InstallSupport(s.MuxHelper, s.enableSwaggerSupport) ui.InstallSupport(s.MuxHelper, s.enableSwaggerSupport && s.enableSwaggerUI)
} }
if c.EnableProfiling { if c.EnableProfiling {

View File

@ -80,6 +80,7 @@ func TestNew(t *testing.T) {
assert.Equal(s.enableLogsSupport, config.EnableLogsSupport) assert.Equal(s.enableLogsSupport, config.EnableLogsSupport)
assert.Equal(s.enableUISupport, config.EnableUISupport) assert.Equal(s.enableUISupport, config.EnableUISupport)
assert.Equal(s.enableSwaggerSupport, config.EnableSwaggerSupport) assert.Equal(s.enableSwaggerSupport, config.EnableSwaggerSupport)
assert.Equal(s.enableSwaggerUI, config.EnableSwaggerUI)
assert.Equal(s.enableProfiling, config.EnableProfiling) assert.Equal(s.enableProfiling, config.EnableProfiling)
assert.Equal(s.APIPrefix, config.APIPrefix) assert.Equal(s.APIPrefix, config.APIPrefix)
assert.Equal(s.APIGroupPrefix, config.APIGroupPrefix) assert.Equal(s.APIGroupPrefix, config.APIGroupPrefix)