2015-12-25 00:08:15 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors.
|
2015-12-25 00:08:15 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Package options contains flags and options for initializing an apiserver
|
|
|
|
package options
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2016-10-06 18:52:32 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api"
|
2015-12-25 00:08:15 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/validation"
|
2016-05-06 15:15:36 +00:00
|
|
|
genericoptions "k8s.io/kubernetes/pkg/genericapiserver/options"
|
2015-12-25 00:08:15 +00:00
|
|
|
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client"
|
|
|
|
"k8s.io/kubernetes/pkg/master/ports"
|
|
|
|
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
)
|
|
|
|
|
2016-10-25 07:18:05 +00:00
|
|
|
// ServerRunOptions runs a kubernetes api server.
|
|
|
|
type ServerRunOptions struct {
|
2016-11-09 18:53:23 +00:00
|
|
|
GenericServerRunOptions *genericoptions.ServerRunOptions
|
|
|
|
Etcd *genericoptions.EtcdOptions
|
|
|
|
SecureServing *genericoptions.SecureServingOptions
|
|
|
|
InsecureServing *genericoptions.ServingOptions
|
2016-11-09 18:14:20 +00:00
|
|
|
Authentication *genericoptions.BuiltInAuthenticationOptions
|
2016-11-10 14:15:50 +00:00
|
|
|
Authorization *genericoptions.BuiltInAuthorizationOptions
|
2016-11-09 18:14:20 +00:00
|
|
|
|
|
|
|
AllowPrivileged bool
|
|
|
|
EventTTL time.Duration
|
|
|
|
KubeletConfig kubeletclient.KubeletClientConfig
|
|
|
|
MaxConnectionBytesPerSec int64
|
|
|
|
SSHKeyfile string
|
|
|
|
SSHUser string
|
2015-12-25 00:08:15 +00:00
|
|
|
}
|
|
|
|
|
2016-10-25 07:18:05 +00:00
|
|
|
// NewServerRunOptions creates a new ServerRunOptions object with default parameters
|
|
|
|
func NewServerRunOptions() *ServerRunOptions {
|
|
|
|
s := ServerRunOptions{
|
2016-11-09 18:53:23 +00:00
|
|
|
GenericServerRunOptions: genericoptions.NewServerRunOptions(),
|
|
|
|
Etcd: genericoptions.NewEtcdOptions(),
|
|
|
|
SecureServing: genericoptions.NewSecureServingOptions(),
|
|
|
|
InsecureServing: genericoptions.NewInsecureServingOptions(),
|
2016-11-09 18:14:20 +00:00
|
|
|
Authentication: genericoptions.NewBuiltInAuthenticationOptions().WithAll(),
|
2016-11-10 14:15:50 +00:00
|
|
|
Authorization: genericoptions.NewBuiltInAuthorizationOptions(),
|
2016-11-09 18:53:23 +00:00
|
|
|
|
|
|
|
EventTTL: 1 * time.Hour,
|
2015-12-25 00:08:15 +00:00
|
|
|
KubeletConfig: kubeletclient.KubeletClientConfig{
|
2016-10-06 18:52:32 +00:00
|
|
|
Port: ports.KubeletPort,
|
|
|
|
PreferredAddressTypes: []string{
|
|
|
|
string(api.NodeHostName),
|
|
|
|
string(api.NodeInternalIP),
|
|
|
|
string(api.NodeExternalIP),
|
|
|
|
string(api.NodeLegacyHostIP),
|
|
|
|
},
|
2015-12-25 00:08:15 +00:00
|
|
|
EnableHttps: true,
|
|
|
|
HTTPTimeout: time.Duration(5) * time.Second,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddFlags adds flags for a specific APIServer to the specified FlagSet
|
2016-10-25 07:18:05 +00:00
|
|
|
func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
|
2016-04-06 22:24:48 +00:00
|
|
|
// Add the generic flags.
|
2016-10-25 07:28:11 +00:00
|
|
|
s.GenericServerRunOptions.AddUniversalFlags(fs)
|
2016-11-09 18:53:23 +00:00
|
|
|
|
|
|
|
s.Etcd.AddFlags(fs)
|
2016-11-09 18:14:20 +00:00
|
|
|
s.SecureServing.AddFlags(fs)
|
|
|
|
s.SecureServing.AddDeprecatedFlags(fs)
|
|
|
|
s.InsecureServing.AddFlags(fs)
|
|
|
|
s.InsecureServing.AddDeprecatedFlags(fs)
|
|
|
|
s.Authentication.AddFlags(fs)
|
2016-11-10 14:15:50 +00:00
|
|
|
s.Authorization.AddFlags(fs)
|
2016-11-09 18:53:23 +00:00
|
|
|
|
2015-12-25 00:08:15 +00:00
|
|
|
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
|
|
|
|
// arrange these text blocks sensibly. Grrr.
|
2016-06-16 00:33:02 +00:00
|
|
|
|
|
|
|
fs.DurationVar(&s.EventTTL, "event-ttl", s.EventTTL,
|
|
|
|
"Amount of time to retain events. Default is 1h.")
|
|
|
|
|
|
|
|
fs.BoolVar(&s.AllowPrivileged, "allow-privileged", s.AllowPrivileged,
|
|
|
|
"If true, allow privileged containers.")
|
|
|
|
|
|
|
|
fs.StringVar(&s.SSHUser, "ssh-user", s.SSHUser,
|
|
|
|
"If non-empty, use secure SSH proxy to the nodes, using this user name")
|
|
|
|
|
|
|
|
fs.StringVar(&s.SSHKeyfile, "ssh-keyfile", s.SSHKeyfile,
|
|
|
|
"If non-empty, use secure SSH proxy to the nodes, using this user keyfile")
|
|
|
|
|
|
|
|
fs.Int64Var(&s.MaxConnectionBytesPerSec, "max-connection-bytes-per-sec", s.MaxConnectionBytesPerSec, ""+
|
|
|
|
"If non-zero, throttle each user connection to this number of bytes/sec. "+
|
|
|
|
"Currently only applies to long-running requests.")
|
|
|
|
|
2015-12-25 00:08:15 +00:00
|
|
|
// Kubelet related flags:
|
2016-06-16 00:33:02 +00:00
|
|
|
fs.BoolVar(&s.KubeletConfig.EnableHttps, "kubelet-https", s.KubeletConfig.EnableHttps,
|
|
|
|
"Use https for kubelet connections.")
|
|
|
|
|
2016-10-06 18:52:32 +00:00
|
|
|
fs.StringSliceVar(&s.KubeletConfig.PreferredAddressTypes, "kubelet-preferred-address-types", s.KubeletConfig.PreferredAddressTypes,
|
|
|
|
"List of the preferred NodeAddressTypes to use for kubelet connections.")
|
|
|
|
|
2016-06-16 00:33:02 +00:00
|
|
|
fs.UintVar(&s.KubeletConfig.Port, "kubelet-port", s.KubeletConfig.Port,
|
|
|
|
"DEPRECATED: kubelet port.")
|
|
|
|
fs.MarkDeprecated("kubelet-port", "kubelet-port is deprecated and will be removed.")
|
|
|
|
|
|
|
|
fs.DurationVar(&s.KubeletConfig.HTTPTimeout, "kubelet-timeout", s.KubeletConfig.HTTPTimeout,
|
|
|
|
"Timeout for kubelet operations.")
|
|
|
|
|
|
|
|
fs.StringVar(&s.KubeletConfig.CertFile, "kubelet-client-certificate", s.KubeletConfig.CertFile,
|
|
|
|
"Path to a client cert file for TLS.")
|
|
|
|
|
|
|
|
fs.StringVar(&s.KubeletConfig.KeyFile, "kubelet-client-key", s.KubeletConfig.KeyFile,
|
|
|
|
"Path to a client key file for TLS.")
|
|
|
|
|
|
|
|
fs.StringVar(&s.KubeletConfig.CAFile, "kubelet-certificate-authority", s.KubeletConfig.CAFile,
|
|
|
|
"Path to a cert file for the certificate authority.")
|
|
|
|
|
2015-12-25 00:08:15 +00:00
|
|
|
// TODO: delete this flag as soon as we identify and fix all clients that send malformed updates, like #14126.
|
2016-06-16 00:33:02 +00:00
|
|
|
fs.BoolVar(&validation.RepairMalformedUpdates, "repair-malformed-updates", validation.RepairMalformedUpdates, ""+
|
|
|
|
"If true, server will do its best to fix the update request to pass the validation, "+
|
|
|
|
"e.g., setting empty UID in update request to its existing value. This flag can be turned off "+
|
|
|
|
"after we fix all the clients that send malformed updates.")
|
2015-12-25 00:08:15 +00:00
|
|
|
}
|