Documentation
¶
Overview ¶
handler introduces new way to access site API:
1. Get access to k8s master
GET /sites/v1/:account_id/:site_domain/proxy/master/k8s/<k8s-specific endpoints>
for example this request will hit the API
GET /sites/v1/:account_id/:site_domain/proxy/master/k8s/api/v1/namespaces
2. Get list of servers
GET /sites/v1/:account_id/:site_id/servers
returns [{ "advertise-ip": "127.0.0.1", "hostname": "bob.example.com", "role": "database" }
(You can later use the server's hostname in Shrink operation)
3. Access any HTTP(S) URL inside the cluster:
GET /sites/v1/:account_id/:site_domain/proxy/address/:scheme/:host/:port/*rest of the URL
for example this request will hit the http://192.168.1.1:8080
GET /sites/v1/:account_id/:site_domain/proxy/address/http/192.168.1.1/8080
Index ¶
- func MatchTeleportConfigPackage(teleportVersion semver.Version) pack.MatchFunc
- func RemoteAccessConfig(stateDir string) (seedConfig *ops.SeedConfig, err error)
- func Run(ctx context.Context, configDir, importDir string, newProcess NewGravityProcess) error
- func StartProfiling(ctx context.Context, httpEndpoint, profileDir string) error
- func WizardTeleportConfig(clusterName, stateDir string) *telecfg.FileConfig
- type GravityProcess
- type Handlers
- type NewGravityProcess
- type Process
- func (p *Process) APIAdvertiseHost() string
- func (p *Process) AgentServer() rpcserver.Server
- func (p *Process) AgentService() ops.AgentService
- func (p *Process) Backend() storage.Backend
- func (p *Process) Config() *processconfig.Config
- func (p *Process) Context() context.Context
- func (p *Process) Handlers() *Handlers
- func (p *Process) ImportState(importDir string) (err error)
- func (p *Process) Init(ctx context.Context) error
- func (p *Process) InitRPCCredentials() error
- func (p *Process) KubeClient() *kubernetes.Clientset
- func (p *Process) Operator() ops.Operator
- func (p *Process) Packages() pack.PackageService
- func (p *Process) RegisterClusterService(service clusterService)
- func (p *Process) ReportHealth(w http.ResponseWriter, r *http.Request)
- func (p *Process) ReportReadiness(w http.ResponseWriter, r *http.Request)
- func (p *Process) ReverseTunnel() reversetunnel.Server
- func (p *Process) Serve() error
- func (p *Process) ServeAPI() error
- func (p *Process) ServeHealth() error
- func (p *Process) ServeLocal(ctx context.Context, mux http.Handler, addr string) error
- func (p *Process) Shutdown(ctx context.Context)
- func (p *Process) Start() (err error)
- func (p *Process) StartResumeOperationLoop()
- func (p *Process) TeleportConfig() *service.Config
- func (p *Process) UsersService() users.Identity
- func (p *Process) WebAdvertiseHost() string
- type ServiceStartedEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchTeleportConfigPackage ¶
MatchTeleportConfigPackage returns a match function that matches Teleport master configuration package with specified version.
func RemoteAccessConfig ¶
func RemoteAccessConfig(stateDir string) (seedConfig *ops.SeedConfig, err error)
RemoteAccessConfig returns remote access configuration provided during the build of this package
func Run ¶
func Run(ctx context.Context, configDir, importDir string, newProcess NewGravityProcess) error
Run creates a new gravity process using the provided "constructor" function, launches it and waits for it to shut down
func StartProfiling ¶
StartProfiling starts profiling endpoint, will return AlreadyExists if profiling has been initiated
func WizardTeleportConfig ¶
func WizardTeleportConfig(clusterName, stateDir string) *telecfg.FileConfig
WizardTeleportConfig generates a teleport configuration for the gravity wizard process
Types ¶
type GravityProcess ¶
type GravityProcess interface { // Supervisor allows gravity process to register and manage internal services service.Supervisor // StartResumeOperationLoop starts service that resumes pending operations StartResumeOperationLoop() // ImportState imports gravity state from the specified directory ImportState(importDir string) error // InitRPCCredentials initializes package with RPC secrets InitRPCCredentials() error // AgentService returns the process agent service AgentService() ops.AgentService // UsersService returns the process identity service UsersService() users.Identity // Config returns the process config Config() *processconfig.Config // Shutdown starts graceful shutdown of the process, // blocks until all resources are freed and go-routines have shut down Shutdown(context.Context) }
GravityProcess defines an interface for a process that runs gravity service
func NewProcess ¶
func NewProcess(ctx context.Context, gravityConfig processconfig.Config, teleportConfig config.FileConfig) (GravityProcess, error)
NewProcess creates a new gravity API server process
It satisfies NewGravityProcess function type.
type Handlers ¶
type Handlers struct { // Packages is package service web handler Packages *webpack.Server // Apps is app service web handler Apps *apphandler.WebHandler // Operator is ops service web handler Operator *opshandler.WebHandler // Web is web UI handler Web *web.WebHandler // WebProxy is Teleport web API handler WebProxy *teleweb.RewritingHandler // WebAPI is web API handler WebAPI *web.Handler // Proxy is cluster proxy handler Proxy *proxyHandler // BLOB is object storage service web handler BLOB *blobhandler.Server // Registry is the Docker registry handler. Registry http.Handler }
Handlers combines all the process' web and API Handlers
type NewGravityProcess ¶
type NewGravityProcess func(ctx context.Context, gravityConfig processconfig.Config, teleportConfig config.FileConfig) (GravityProcess, error)
NewGravityProcess defines a function that creates a gravity process
type Process ¶
type Process struct { sync.Mutex *service.TeleportProcess logrus.FieldLogger // contains filtered or unexported fields }
func New ¶
func New(ctx context.Context, cfg processconfig.Config, tcfg telecfg.FileConfig) (*Process, error)
New returns and starts a new instance of gravity, either Site or OpsCenter, including services like teleport proxy and teleport auth
func (*Process) APIAdvertiseHost ¶
APIAdvertiseHost returns the hostname advertised to clusters where this process serves its API.
func (*Process) AgentServer ¶
AgentServer returns the process RPC server
func (*Process) AgentService ¶
func (p *Process) AgentService() ops.AgentService
AgentService returns the process agent service
func (*Process) Config ¶
func (p *Process) Config() *processconfig.Config
Config returns the process config
func (*Process) ImportState ¶
ImportState imports site state from the specified import directory into the configured backend
func (*Process) InitRPCCredentials ¶
InitRPCCredentials initializes the package with RPC secrets
func (*Process) KubeClient ¶
func (p *Process) KubeClient() *kubernetes.Clientset
KubeClient returns the process Kubernetes client
func (*Process) Packages ¶
func (p *Process) Packages() pack.PackageService
Packages returns the process package service
func (*Process) RegisterClusterService ¶
func (p *Process) RegisterClusterService(service clusterService)
RegisterClusterService adds the service to the list of registered cluster services to run on the leader
func (*Process) ReportHealth ¶
func (p *Process) ReportHealth(w http.ResponseWriter, r *http.Request)
ReportHealth is HTTP check that reports that the system is healthy if it can successfully connect to the storage backend
func (*Process) ReportReadiness ¶
func (p *Process) ReportReadiness(w http.ResponseWriter, r *http.Request)
ReportReadiness is an HTTP check that reports whether the system is ready. This system is ready if it is the active gravity site leader
func (*Process) ReverseTunnel ¶
func (p *Process) ReverseTunnel() reversetunnel.Server
ReverseTunnel returns the process reverse tunnel service
func (*Process) ServeHealth ¶
ServeHealth registers the process health service with the supervisor
func (*Process) ServeLocal ¶
ServeLocal starts serving provided handler mux on the specified address
The listener is restarted when a certificate change event is detected.
func (*Process) StartResumeOperationLoop ¶
func (p *Process) StartResumeOperationLoop()
StartResumeOperationLoop starts a loop that handles requests to resume pending cluster operations
func (*Process) TeleportConfig ¶
TeleportConfig returns the process teleport config
func (*Process) UsersService ¶
UsersService returns the process identity service
func (*Process) WebAdvertiseHost ¶
WebAdvertiseHost returns the name of the host where public web UI and APIs are served.
In the general case it is the same as the API advertise host.
type ServiceStartedEvent ¶
type ServiceStartedEvent struct { // Error is set if the service has failed to initialize Error error }
ServiceStartedEvent defines the payload of the gravity service start event. It is used to relay success or failure of service initialization to event listeners
func (ServiceStartedEvent) String ¶
func (e ServiceStartedEvent) String() string
String returns event string representation.