install

package
v0.0.0-...-0755659 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2019 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAddr

func CheckAddr(addr string) error

func EnsureServiceUserAndBinary

func EnsureServiceUserAndBinary(userID, groupID string) (*systeminfo.User, error)

EnsureServiceUserAndBinary ensures that the specified user exists on host (creating it if it does not). It also installs the system binary into the proper binary location depending on the OS distribution. Returns the new or existing service user as a result

func FSMSpec

func FSMSpec(config FSMConfig) fsm.FSMSpecFunc

FSMSpec returns a function that returns an appropriate phase executor based on the provided params

func FetchCloudMetadata

func FetchCloudMetadata(cloudProvider string, config *pb.RuntimeConfig) error

FetchCloudMetadata fetches the metadata for the specified cloud provider

func GetApp

GetApp finds the user app in the provided service and returns it

func GetAppPackage

func GetAppPackage(service appservice.Applications) (*loc.Locator, error)

GetAppPackage finds the user app in the provided service and returns its locator

func GetOrCreateServiceUser

func GetOrCreateServiceUser(uid, gid string) (user *systeminfo.User, err error)

GetOrCreateServiceUser returns the user to use for container services.

If the specified ID is empty, a new service user and service group (named defaults.ServiceUser/defaults.ServiceGroup) will be created with system-allocated IDs.

If the specified ID is not empty, the user is expected to exist.

func GetServers

func GetServers(op ops.SiteOperation, servers []checks.ServerInfo) (*ops.OperationUpdateRequest, error)

func GetServiceUser

func GetServiceUser(uid string) (user *systeminfo.User, err error)

GetServiceUser retrieves the service user by ID. If the specified user ID is empty, the function looks up the user by name (defaults.ServiceUser).

func InitLogging

func InitLogging(logFile string)

InitLogging initalizes logging for local installer

func InitProcess

func InitProcess(ctx context.Context, installerConfig Config, gravityConfig processconfig.Config) (process.GravityProcess, error)

InitProcess initializes and starts a gravity process

func LoadRPCCredentials

func LoadRPCCredentials(ctx context.Context, packages pack.PackageService, log log.FieldLogger) (*rpcserver.Credentials, error)

func MakeProcessConfig

func MakeProcessConfig(i Config) (*processconfig.Config, error)

MakeProcessConfig creates a gravity process config from installer config

func NewAgent

func NewAgent(ctx context.Context, config AgentConfig, log log.FieldLogger, watchCh chan rpcserver.WatchEvent) (rpcserver.Server, error)

NewAgent returns a new unstarted agent instance

func NewFSM

func NewFSM(config FSMConfig) (*fsm.FSM, error)

NewFSM returns a new install FSM instance

func PollProgress

func PollProgress(ctx context.Context, send func(Event), operator ops.Operator,
	opKey ops.SiteOperationKey, agentDoneCh <-chan struct{})

func ServerRequirements

func ServerRequirements(flavor schema.Flavor) map[string]storage.ServerProfileRequest

ServerRequirements computes server requirements based on the selected flavor

func StartAgent

func StartAgent(agentURL string, config rpcserver.PeerConfig, log log.FieldLogger) (*rpcserver.PeerServer, error)

func UpsertSystemAccount

func UpsertSystemAccount(operator ops.Operator) (*ops.Account, error)

UpsertSystem account creates or updates system account used for all installs

func ValidateCloudProvider

func ValidateCloudProvider(cloudProvider string) (provider string, err error)

ValidateCloudProvider validates the value of the specified cloud provider. If no cloud provider has been specified, the provider is autodetected.

Types

type AgentConfig

type AgentConfig struct {
	// PackageAddr references the endpoint to bootstrap credentials from
	PackageAddr string
	// AdvertiseAddr is the IP address to advertise
	AdvertiseAddr string
	// ServerAddr specifies the address of the agent server
	ServerAddr string
	// RuntimeConfig specifies runtime configuration
	pb.RuntimeConfig
}

AgentConfig describes configuration for a stateless agent

func (*AgentConfig) CheckAndSetDefaults

func (r *AgentConfig) CheckAndSetDefaults() (err error)

CheckAndSetDefaults validates this config object and sets defaults

type Config

type Config struct {
	// Context controls state of the installer, e.g. it can be cancelled
	Context context.Context
	// Cancel allows to cancel the context above
	Cancel context.CancelFunc
	// AdvertiseAddr is advertise address of this server
	AdvertiseAddr string
	// Token is install token
	Token string
	// CloudProvider is optional cloud provider
	CloudProvider string
	// StateDir is directory with local installer state
	StateDir string
	// WriteStateDir is installer write layer
	WriteStateDir string
	// UserLogFile is the log file where user-facing operation logs go
	UserLogFile string
	// SystemLogFile is the log file for system logs
	SystemLogFile string
	// SiteDomain is the name of the cluster
	SiteDomain string
	// Flavor is installation flavor
	Flavor string
	// Role is server role
	Role string
	// AppPackage is the application being installed
	AppPackage *loc.Locator
	// Resources is a file with resource specs
	Resources []byte
	// EventsC is channel with events indicating install progress
	EventsC chan Event
	// SystemDevice is a device for gravity data
	SystemDevice string
	// DockerDevice is a device for docker
	DockerDevice string
	// Mounts is a list of mount points (name -> source pairs)
	Mounts map[string]string
	// DNSOverrides contains installer node DNS overrides
	DNSOverrides storage.DNSOverrides
	// Mode is the installation mode (wizard or CLI or via Ops Center)
	Mode string
	// PodCIDR is a pod network CIDR
	PodCIDR string
	// ServiceCIDR is a service network CIDR
	ServiceCIDR string
	// VxlanPort is the overlay network port
	VxlanPort int
	// DNSConfig overrides the local cluster DNS configuration
	DNSConfig storage.DNSConfig
	// Docker specifies docker configuration
	Docker storage.DockerConfig
	// Insecure allows to turn off cert validation
	Insecure bool
	// Process is the gravity process running inside the installer
	Process process.GravityProcess
	// LocalPackages is the machine-local package service
	LocalPackages pack.PackageService
	// LocalApps is the machine-local apps service
	LocalApps appservice.Applications
	// LocalBackend is the machine-local backend
	LocalBackend storage.Backend
	// Manual disables automatic phase execution when set to true
	Manual bool
	// ServiceUser specifies the user to use as a service user in planet
	// and for unprivileged kubernetes services
	ServiceUser systeminfo.User
	// GCENodeTags defines the VM instance tags on GCE
	GCENodeTags []string
	// NewProcess is used to launch gravity API server process
	NewProcess process.NewGravityProcess
	// Silent allows installer to output its progress
	localenv.Silent
}

Config is installer configuration

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() (err error)

CheckAndSetDefaults checks the parameters and autodetects some defaults

type Engine

type Engine interface {
	// NewClusterRequest constructs a request to create a new cluster
	NewClusterRequest() ops.NewSiteRequest
	// GetOperationPlan builds a plan for the provided operation
	GetOperationPlan(ops.Site, ops.SiteOperation) (*storage.OperationPlan, error)
	// GetFSM returns the installer FSM engine
	GetFSM() (*fsm.FSM, error)
	// OnPlanComplete is called when install plan finishes execution
	OnPlanComplete(fsm *fsm.FSM, fsmErr error)
	// Cleanup performs post-installation cleanups
	Cleanup(ops.ProgressEntry) error
}

Engine defines interface for installer customization

type Event

type Event struct {
	Progress *ops.ProgressEntry
	Error    error
}

Event represents install event

type FSMConfig

type FSMConfig struct {
	// OperationKey is the install operation key
	OperationKey ops.SiteOperationKey
	// Packages is authenticated installer pack client
	Packages pack.PackageService
	// Apps is authenticated installer apps client
	Apps app.Applications
	// Operator is authenticated installer ops client
	Operator ops.Operator
	// LocalPackages is the machine-local pack service
	LocalPackages pack.PackageService
	// LocalApps is the machine-local apps service
	LocalApps app.Applications
	// LocalBackend is the machine-local backend
	LocalBackend storage.Backend
	// RemoteOpsURL is an optional URL of the remote Ops Center
	RemoteOpsURL string
	// RemoteOpsToken is the auth token for the above Ops Center
	RemoteOpsToken string
	// Spec is the FSM spec
	Spec fsm.FSMSpecFunc
	// Credentials is the credentials for gRPC agents
	Credentials credentials.TransportCredentials
	// Insecure allows to turn off cert validation in dev mode
	Insecure bool
	// UserLogFile is the user-friendly install log file
	UserLogFile string
	// ReportProgress controls whether engine should report progress to Operator
	ReportProgress bool
	// DNSConfig specifies the DNS configuration to use
	DNSConfig storage.DNSConfig
}

FSMConfig is the install FSM config

func (*FSMConfig) CheckAndSetDefaults

func (c *FSMConfig) CheckAndSetDefaults() (err error)

Check validates install FSM config and sets some defaults

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook implements log.Hook and multiplexes log messages both to stderr and a log file. The console output is limited to warning level and above while logging to file logs at all levels.

func (*Hook) Fire

func (r *Hook) Fire(entry *log.Entry) error

Fire writes the provided log entry to the configured log file

It never returns an error to avoid default logrus behavior of spitting out fire hook errors into stderr.

func (*Hook) Levels

func (r *Hook) Levels() []log.Level

type Installer

type Installer struct {
	// Config is the installer configuration
	Config
	// FieldLogger is used for structured logging
	log.FieldLogger
	// AccountID is the wizard system account ID
	AccountID string
	// AppPackage is the application being installed
	AppPackage loc.Locator
	// Token is the generated unique install token
	Token storage.InstallToken
	// Operator is the ops service authenticated with wizard process
	Operator ops.Operator
	// Apps is the app service authenticated with wizard process
	Apps appservice.Applications
	// Packages is the pack service authenticated with wizard process
	Packages pack.PackageService
	// OperationKey is the key of the running operation
	OperationKey ops.SiteOperationKey
	// Cluster is the cluster that is being installed
	Cluster *ops.Site
	// contains filtered or unexported fields
}

Installer is a CLI client that manages installation process

func Init

func Init(ctx context.Context, cfg Config) (*Installer, error)

Init creates a new installer and initializes various services it will need based on the provided config

func (*Installer) Cleanup

func (i *Installer) Cleanup(progress ops.ProgressEntry) error

Cleanup performs post-installation cleanups, e.g. tears down reverse tunnels that were required during installation

func (*Installer) GetFSM

func (i *Installer) GetFSM() (*fsm.FSM, error)

GetFSM returns the installer FSM engine

func (*Installer) GetOperationPlan

func (i *Installer) GetOperationPlan(cluster ops.Site, op ops.SiteOperation) (*storage.OperationPlan, error)

GetOperationPlan builds a plan for the provided operation

func (*Installer) GetPlanBuilder

func (i *Installer) GetPlanBuilder(cluster ops.Site, op ops.SiteOperation) (*PlanBuilder, error)

GetPlanBuilder returns a new plan builder for this installer and provided operation that can be used to build operation plan phases

func (*Installer) LaunchOperation

func (i *Installer) LaunchOperation(req ops.CreateSiteInstallOperationRequest) error

LaunchOperation creates the install operation according the provided request and launches an install agent

func (*Installer) NewClusterRequest

func (i *Installer) NewClusterRequest() ops.NewSiteRequest

NewClusterRequest constructs a request to create a new cluster

func (*Installer) OnPlanComplete

func (i *Installer) OnPlanComplete(fsm *fsm.FSM, fsmErr error)

OnPlanComplete is called when the operation plan finishes execution

func (*Installer) PollProgress

func (i *Installer) PollProgress(agentDoneCh <-chan struct{})

func (*Installer) PrintStep

func (i *Installer) PrintStep(format string, args ...interface{})

func (*Installer) SetEngine

func (i *Installer) SetEngine(engine Engine)

SetEngine sets the installer engine

func (*Installer) SetFlavor

func (i *Installer) SetFlavor(flavor *schema.Flavor)

SetFlavor sets the flavor that will be installed

func (*Installer) Start

func (i *Installer) Start() error

Start starts the installer in the appropriate mode according to its configuration

func (*Installer) StartAgent

func (i *Installer) StartAgent(agentURL string) (rpcserver.Server, error)

StartAgent launches the RPC install agent

func (*Installer) StartCLIInstall

func (i *Installer) StartCLIInstall() (err error)

StartCLIInstall starts non-interactive installation

func (*Installer) StartInteractiveInstall

func (i *Installer) StartInteractiveInstall() error

StartInteractiveInstall starts installation that was initiated in wizard mode

func (*Installer) StartOperation

func (i *Installer) StartOperation() error

StartOperation inializes installation plan, instantiates the install FSM engine and launches the operation (plan execution)

func (*Installer) Stop

func (i *Installer) Stop(ctx context.Context) error

Stop releases resources allocated by the installer and shuts down the agent cluster.

func (*Installer) UpdateOperationState

func (i *Installer) UpdateOperationState() error

UpdateOperationState updates the operation data according to the agent report

func (*Installer) Wait

func (i *Installer) Wait() error

Wait waits for the install to complete, performs post-installation cleanups and shuts down the installer

type PlanBuilder

type PlanBuilder struct {
	// Application is the app being installed
	Application app.Application
	// Runtime is the Runtime of the app being installed
	Runtime app.Application
	// TeleportPackage is the runtime teleport package
	TeleportPackage loc.Locator
	// RBACPackage is the runtime rbac app package
	RBACPackage loc.Locator
	// GravitySitePackage is the gravity-site app package
	GravitySitePackage loc.Locator
	// DNSAppPackage is the dns-app app package
	DNSAppPackage loc.Locator
	// Masters is the list of master nodes
	Masters []storage.Server
	// Nodes is the list of regular nodes
	Nodes []storage.Server
	// Master is one of the master nodes
	Master storage.Server
	// AdminAgent is the cluster agent with admin privileges
	AdminAgent storage.LoginEntry
	// RegularAgent is the cluster agent with non-admin privileges
	RegularAgent storage.LoginEntry
	// ServiceUser is the cluster system user
	ServiceUser storage.OSUser
	// DNSConfig specifies the custom cluster DNS configuration
	DNSConfig storage.DNSConfig
	// InstallerTrustedCluster represents the trusted cluster for installer process
	InstallerTrustedCluster storage.TrustedCluster
}

PlanBuilder builds operation plan phases

func (*PlanBuilder) AddApplicationPhase

func (b *PlanBuilder) AddApplicationPhase(plan *storage.OperationPlan) error

AddApplicationPhase appends user application installation phase to the provided plan

func (*PlanBuilder) AddBootstrapPhase

func (b *PlanBuilder) AddBootstrapPhase(plan *storage.OperationPlan)

AddBootstrapPhase appends nodes bootstrap phase to the provided plan

func (*PlanBuilder) AddChecksPhase

func (b *PlanBuilder) AddChecksPhase(plan *storage.OperationPlan)

AddChecksPhase appends preflight checks phase to the provided plan

func (*PlanBuilder) AddConfigurePhase

func (b *PlanBuilder) AddConfigurePhase(plan *storage.OperationPlan)

AddConfigurePhase appends package configuration phase to the provided plan

func (*PlanBuilder) AddConnectInstallerPhase

func (b *PlanBuilder) AddConnectInstallerPhase(plan *storage.OperationPlan) error

AddConnectInstallerPhase appends installer/cluster connection phase

func (*PlanBuilder) AddCorednsPhase

func (b *PlanBuilder) AddCorednsPhase(plan *storage.OperationPlan)

AddCorednsPhase generates default coredns configuration for the cluster

func (*PlanBuilder) AddEnableElectionPhase

func (b *PlanBuilder) AddEnableElectionPhase(plan *storage.OperationPlan)

AddEnableElectionPhase appends leader election enabling phase to the provided plan

func (*PlanBuilder) AddExportPhase

func (b *PlanBuilder) AddExportPhase(plan *storage.OperationPlan)

AddExportPhase appends Docker images export phase to the provided plan

func (*PlanBuilder) AddHealthPhase

func (b *PlanBuilder) AddHealthPhase(plan *storage.OperationPlan)

AddHealthPhase appends phase that waits for the cluster to become healthy

func (*PlanBuilder) AddInstallOverlayPhase

func (b *PlanBuilder) AddInstallOverlayPhase(plan *storage.OperationPlan, locator *loc.Locator)

AddInstallOverlayPhase appends a phase to install a non-flannel overlay network

func (*PlanBuilder) AddMastersPhase

func (b *PlanBuilder) AddMastersPhase(plan *storage.OperationPlan) error

AddMastersPhase appends master nodes system installation phase to the provided plan

func (*PlanBuilder) AddNodesPhase

func (b *PlanBuilder) AddNodesPhase(plan *storage.OperationPlan) error

AddNodesPhase appends regular nodes system installation phase to the provided plan

func (*PlanBuilder) AddPullPhase

func (b *PlanBuilder) AddPullPhase(plan *storage.OperationPlan)

AddPullPhase appends package download phase to the provided plan

func (*PlanBuilder) AddRBACPhase

func (b *PlanBuilder) AddRBACPhase(plan *storage.OperationPlan)

AddRBACPhase appends K8s RBAC initialization phase to the provided plan

func (*PlanBuilder) AddResourcesPhase

func (b *PlanBuilder) AddResourcesPhase(plan *storage.OperationPlan, resources []byte)

AddResourcesPhase appends K8s resources initialization phase to the provided plan

func (*PlanBuilder) AddRuntimePhase

func (b *PlanBuilder) AddRuntimePhase(plan *storage.OperationPlan) error

AddRuntimePhase appends system applications installation phase to the provided plan

func (*PlanBuilder) AddWaitPhase

func (b *PlanBuilder) AddWaitPhase(plan *storage.OperationPlan)

AddWaitPhase appends planet startup wait phase to the provided plan

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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