Documentation ¶
Overview ¶
Package master contains code for setting up and running a Kubernetes cluster master.
Index ¶
- Constants
- func NewEtcdStorage(client tools.EtcdClient, interfacesFunc meta.VersionInterfacesFunc, ...) (etcdStorage storage.Interface, err error)
- func NewHandlerContainer(mux *http.ServeMux) *restful.Container
- type APIGroupVersionOverride
- type AddressFunc
- type Config
- type Controller
- func (c *Controller) CreateNamespaceIfNeeded(ns string) error
- func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, ...) error
- func (c *Controller) ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []api.EndpointPort, ...) error
- func (c *Controller) RunKubernetesService(ch chan struct{})
- func (c *Controller) Start()
- func (c *Controller) UpdateKubernetesService(reconcile bool) error
- type InstallSSHKey
- type Master
- func (m *Master) HandleFuncWithAuth(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (m *Master) HandleWithAuth(pattern string, handler http.Handler)
- func (m *Master) HasThirdPartyResource(rsrc *expapi.ThirdPartyResource) (bool, error)
- func (m *Master) InstallSwaggerAPI()
- func (m *Master) InstallThirdPartyResource(rsrc *expapi.ThirdPartyResource) error
- func (m *Master) IsTunnelSyncHealthy(req *http.Request) error
- func (m *Master) ListThirdPartyResources() []string
- func (m *Master) NewBootstrapController() *Controller
- func (m *Master) RemoveThirdPartyResource(path string) error
- type SSHTunneler
- type StorageDestinations
- type StorageDestinationsForAPIGroup
- type ThirdPartyController
- type Tunneler
Constants ¶
const (
DefaultEtcdPathPrefix = "/registry"
)
Variables ¶
This section is empty.
Functions ¶
func NewEtcdStorage ¶
func NewEtcdStorage(client tools.EtcdClient, interfacesFunc meta.VersionInterfacesFunc, version, prefix string) (etcdStorage storage.Interface, err error)
NewEtcdStorage returns a storage.Interface for the provided arguments or an error if the version is incorrect.
func NewHandlerContainer ¶
Types ¶
type APIGroupVersionOverride ¶
type APIGroupVersionOverride struct { // Whether to enable or disable this group version. Disable bool // List of overrides for individual resources in this group version. ResourceOverrides map[string]bool }
Specifies the overrides for various API group versions. This can be used to enable/disable entire group versions or specific resources.
type AddressFunc ¶
type Config ¶
type Config struct { StorageDestinations StorageDestinations // StorageVersions is a map between groups and their storage versions StorageVersions map[string]string EventTTL time.Duration NodeRegexp string KubeletClient client.KubeletClient // allow downstream consumers to disable the core controller loops EnableCoreControllers bool EnableLogsSupport bool EnableUISupport bool // allow downstream consumers to disable swagger EnableSwaggerSupport bool // Allows api group versions or specific resources to be conditionally enabled/disabled. APIGroupVersionOverrides map[string]APIGroupVersionOverride // allow downstream consumers to disable the index route EnableIndex bool EnableProfiling bool EnableWatchCache bool APIPrefix string APIGroupPrefix string CorsAllowedOriginList []string Authenticator authenticator.Request // TODO(roberthbailey): Remove once the server no longer supports http basic auth. SupportsBasicAuth bool Authorizer authorizer.Authorizer AdmissionControl admission.Interface MasterServiceNamespace string // Map requests to contexts. Exported so downstream consumers can provider their own mappers RequestContextMapper api.RequestContextMapper // If specified, all web services will be registered into this container RestfulContainer *restful.Container // If specified, requests will be allocated a random timeout between this value, and twice this value. // Note that it is up to the request handlers to ignore or honor this timeout. In seconds. MinRequestTimeout int // Number of masters running; all masters must be started with the // same value for this field. (Numbers > 1 currently untested.) MasterCount int // The port on PublicAddress where a read-write server will be installed. // Defaults to 6443 if not set. ReadWritePort int // ExternalHost is the host name to use for external (public internet) facing URLs (e.g. Swagger) ExternalHost string // PublicAddress is the IP address where members of the cluster (kubelet, // kube-proxy, services, etc.) can reach the master. // If nil or 0.0.0.0, the host's default interface will be used. PublicAddress net.IP // Control the interval that pod, node IP, and node heath status caches // expire. CacheTimeout time.Duration // The name of the cluster. ClusterName string // The range of IPs to be assigned to services with type=ClusterIP or greater ServiceClusterIPRange *net.IPNet // The IP address for the master service (must be inside ServiceClusterIPRange ServiceReadWriteIP net.IP // The range of ports to be assigned to services with type=NodePort or greater ServiceNodePortRange util.PortRange // Used to customize default proxy dial/tls options ProxyDialer apiserver.ProxyDialerFunc ProxyTLSClientConfig *tls.Config // Used to start and monitor tunneling Tunneler Tunneler // Additional ports to be exposed on the master service // extraServicePorts is injectable in the event that more ports // (other than the default 443/tcp) are exposed on the master // and those ports need to be load balanced by the master // service because this pkg is linked by out-of-tree projects // like openshift which want to use the master but also do // more stuff. ExtraServicePorts []api.ServicePort // Additional ports to be exposed on the master endpoints // Port names should align with ports defined in ExtraServicePorts ExtraEndpointPorts []api.EndpointPort KubernetesServiceNodePort int }
Config is a structure used to configure a Master.
type Controller ¶ added in v0.21.2
type Controller struct { NamespaceRegistry namespace.Registry ServiceRegistry service.Registry // TODO: MasterCount is yucky MasterCount int ServiceClusterIPRegistry service.RangeRegistry ServiceClusterIPInterval time.Duration ServiceClusterIPRange *net.IPNet ServiceNodePortRegistry service.RangeRegistry ServiceNodePortInterval time.Duration ServiceNodePortRange util.PortRange EndpointRegistry endpoint.Registry EndpointInterval time.Duration PublicIP net.IP ServiceIP net.IP ServicePort int ExtraServicePorts []api.ServicePort ExtraEndpointPorts []api.EndpointPort PublicServicePort int KubernetesServiceNodePort int // contains filtered or unexported fields }
Controller is the controller manager for the core bootstrap Kubernetes controller loops, which manage creating the "kubernetes" service, the "default" namespace, and provide the IP repair check on service IPs
func (*Controller) CreateNamespaceIfNeeded ¶ added in v0.21.2
func (c *Controller) CreateNamespaceIfNeeded(ns string) error
CreateNamespaceIfNeeded will create the namespace that contains the master services if it doesn't already exist
func (*Controller) CreateOrUpdateMasterServiceIfNeeded ¶ added in v1.3.0
func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error
CreateMasterServiceIfNeeded will create the specified service if it doesn't already exist.
func (*Controller) ReconcileEndpoints ¶
func (c *Controller) ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []api.EndpointPort, reconcilePorts bool) error
ReconcileEndpoints sets the endpoints for the given apiserver service (ro or rw). ReconcileEndpoints expects that the endpoints objects it manages will all be managed only by ReconcileEndpoints; therefore, to understand this, you need only understand the requirements and the body of this function.
Requirements:
- All apiservers MUST use the same ports for their {rw, ro} services.
- All apiservers MUST use ReconcileEndpoints and only ReconcileEndpoints to manage the endpoints for their {rw, ro} services.
- All apiservers MUST know and agree on the number of apiservers expected to be running (c.masterCount).
- ReconcileEndpoints is called periodically from all apiservers.
func (*Controller) RunKubernetesService ¶ added in v0.21.2
func (c *Controller) RunKubernetesService(ch chan struct{})
RunKubernetesService periodically updates the kubernetes service
func (*Controller) Start ¶ added in v0.21.2
func (c *Controller) Start()
Start begins the core controller loops that must exist for bootstrapping a cluster.
func (*Controller) UpdateKubernetesService ¶ added in v0.21.2
func (c *Controller) UpdateKubernetesService(reconcile bool) error
UpdateKubernetesService attempts to update the default Kube service.
type InstallSSHKey ¶ added in v0.21.2
type Master ¶
type Master struct { // "Outputs" Handler http.Handler InsecureHandler http.Handler KubernetesServiceNodePort int // contains filtered or unexported fields }
Master contains state for a Kubernetes cluster master/api server.
func New ¶
New returns a new instance of Master from the given config. Certain config fields will be set to a default value if unset, including:
ServiceClusterIPRange ServiceNodePortRange MasterCount ReadWritePort PublicAddress
Certain config fields must be specified, including:
KubeletClient
Public fields:
Handler -- The returned master has a field TopHandler which is an http.Handler which handles all the endpoints provided by the master, including the API, the UI, and miscellaneous debugging endpoints. All these are subject to authorization and authentication. InsecureHandler -- an http.Handler which handles all the same endpoints as Handler, but no authorization and authentication is done.
Public methods:
HandleWithAuth -- Allows caller to add an http.Handler for an endpoint that uses the same authentication and authorization (if any is configured) as the master's built-in endpoints. If the caller wants to add additional endpoints not using the master's auth, then the caller should create a handler for those endpoints, which delegates the any unhandled paths to "Handler".
func (*Master) HandleFuncWithAuth ¶
func (m *Master) HandleFuncWithAuth(pattern string, handler func(http.ResponseWriter, *http.Request))
HandleFuncWithAuth adds an http.Handler for pattern to an http.ServeMux Applies the same authentication and authorization (if any is configured) to the request is used for the master's built-in endpoints.
func (*Master) HandleWithAuth ¶
HandleWithAuth adds an http.Handler for pattern to an http.ServeMux Applies the same authentication and authorization (if any is configured) to the request is used for the master's built-in endpoints.
func (*Master) HasThirdPartyResource ¶ added in v1.3.0
func (m *Master) HasThirdPartyResource(rsrc *expapi.ThirdPartyResource) (bool, error)
HasThirdPartyResource returns true if a particular third party resource currently installed.
func (*Master) InstallSwaggerAPI ¶
func (m *Master) InstallSwaggerAPI()
InstallSwaggerAPI installs the /swaggerapi/ endpoint to allow schema discovery and traversal. It is optional to allow consumers of the Kubernetes master to register their own web services into the Kubernetes mux prior to initialization of swagger, so that other resource types show up in the documentation.
func (*Master) InstallThirdPartyResource ¶ added in v1.3.0
func (m *Master) InstallThirdPartyResource(rsrc *expapi.ThirdPartyResource) error
InstallThirdPartyResource installs a third party resource specified by 'rsrc'. When a resource is installed a corresponding RESTful resource is added as a valid path in the web service provided by the master.
For example, if you install a resource ThirdPartyResource{ Name: "foo.company.com", Versions: {"v1"} } then the following RESTful resource is created on the server:
http://<host>/apis/company.com/v1/foos/...
func (*Master) IsTunnelSyncHealthy ¶ added in v1.0.2
func (*Master) ListThirdPartyResources ¶ added in v1.3.0
ListThirdPartyResources lists all currently installed third party resources
func (*Master) NewBootstrapController ¶ added in v0.21.2
func (m *Master) NewBootstrapController() *Controller
NewBootstrapController returns a controller for watching the core capabilities of the master.
func (*Master) RemoveThirdPartyResource ¶ added in v1.3.0
RemoveThirdPartyResource removes all resources matching `path`. Also deletes any stored data
type SSHTunneler ¶
type SSHTunneler struct { SSHUser string SSHKeyfile string InstallSSHKey InstallSSHKey // contains filtered or unexported fields }
func (*SSHTunneler) Run ¶
func (c *SSHTunneler) Run(getAddresses AddressFunc)
Run establishes tunnel loops and returns
func (*SSHTunneler) SecondsSinceSync ¶
func (c *SSHTunneler) SecondsSinceSync() int64
type StorageDestinations ¶
type StorageDestinations struct {
APIGroups map[string]*StorageDestinationsForAPIGroup
}
StorageDestinations is a mapping from API group & resource to the underlying storage interfaces.
func NewStorageDestinations ¶
func NewStorageDestinations() StorageDestinations
func (*StorageDestinations) AddAPIGroup ¶
func (s *StorageDestinations) AddAPIGroup(group string, defaultStorage storage.Interface)
func (*StorageDestinations) AddStorageOverride ¶
func (s *StorageDestinations) AddStorageOverride(group, resource string, override storage.Interface)
type ThirdPartyController ¶ added in v1.3.0
type ThirdPartyController struct {
// contains filtered or unexported fields
}
ThirdPartyController is a control loop that knows how to synchronize ThirdPartyResource objects with RESTful resources which are present in the API server.
func (*ThirdPartyController) SyncOneResource ¶ added in v1.3.0
func (t *ThirdPartyController) SyncOneResource(rsrc *expapi.ThirdPartyResource) error
Synchronize a single resource with RESTful resources on the master
func (*ThirdPartyController) SyncResources ¶ added in v1.3.0
func (t *ThirdPartyController) SyncResources() error
Synchronize all resources with RESTful resources on the master
type Tunneler ¶
type Tunneler interface { Run(AddressFunc) Stop() Dial(net, addr string) (net.Conn, error) SecondsSinceSync() int64 }
func NewSSHTunneler ¶
func NewSSHTunneler(sshUser string, sshKeyfile string, installSSHKey InstallSSHKey) Tunneler