process

package
v0.0.0-...-3bfe646 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 94 Imported by: 1

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchTeleportConfigPackage

func MatchTeleportConfigPackage(teleportVersion semver.Version) pack.MatchFunc

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

func StartProfiling(ctx context.Context, httpEndpoint, profileDir string) error

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

New returns and starts a new instance of gravity, either Site or OpsCenter, including services like teleport proxy and teleport auth

func (*Process) APIAdvertiseHost

func (p *Process) APIAdvertiseHost() string

APIAdvertiseHost returns the hostname advertised to clusters where this process serves its API.

func (*Process) AgentServer

func (p *Process) AgentServer() rpcserver.Server

AgentServer returns the process RPC server

func (*Process) AgentService

func (p *Process) AgentService() ops.AgentService

AgentService returns the process agent service

func (*Process) Backend

func (p *Process) Backend() storage.Backend

Backend returns the process backend

func (*Process) Config

func (p *Process) Config() *processconfig.Config

Config returns the process config

func (*Process) Context

func (p *Process) Context() context.Context

Context returns the process context

func (*Process) Handlers

func (p *Process) Handlers() *Handlers

Handlers returns all process web handlers

func (*Process) ImportState

func (p *Process) ImportState(importDir string) (err error)

ImportState imports site state from the specified import directory into the configured backend

func (*Process) Init

func (p *Process) Init(ctx context.Context) error

Init initializes the process internal services but does not start them

func (*Process) InitRPCCredentials

func (p *Process) InitRPCCredentials() error

InitRPCCredentials initializes the package with RPC secrets

func (*Process) KubeClient

func (p *Process) KubeClient() *kubernetes.Clientset

KubeClient returns the process Kubernetes client

func (*Process) Operator

func (p *Process) Operator() ops.Operator

Operator returns the process ops service

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) Serve

func (p *Process) Serve() error

Serve starts serving all process web services

func (*Process) ServeAPI

func (p *Process) ServeAPI() error

ServeAPI starts serving process API services

func (*Process) ServeHealth

func (p *Process) ServeHealth() error

ServeHealth registers the process health service with the supervisor

func (*Process) ServeLocal

func (p *Process) ServeLocal(ctx context.Context, mux http.Handler, addr string) error

ServeLocal starts serving provided handler mux on the specified address

The listener is restarted when a certificate change event is detected.

func (*Process) Shutdown

func (p *Process) Shutdown(ctx context.Context)

Shutdown initiates graceful shutdown of this process

func (*Process) Start

func (p *Process) Start() (err error)

Start initializes the process and starts all services

func (*Process) StartResumeOperationLoop

func (p *Process) StartResumeOperationLoop()

StartResumeOperationLoop starts a loop that handles requests to resume pending cluster operations

func (*Process) TeleportConfig

func (p *Process) TeleportConfig() *service.Config

TeleportConfig returns the process teleport config

func (*Process) UsersService

func (p *Process) UsersService() users.Identity

UsersService returns the process identity service

func (*Process) WebAdvertiseHost

func (p *Process) WebAdvertiseHost() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL