bootstrap

package
v0.0.0-...-298751d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 49 Imported by: 59

Documentation

Index

Constants

View Source
const (
	// AdminSecretKey is the attribute key for the administrator password.
	AdminSecretKey = "admin-secret"

	// CACertKey is the attribute key for the controller's CA certificate.
	CACertKey = "ca-cert"

	// CAPrivateKeyKey is the key for the controller's CA certificate private key.
	CAPrivateKeyKey = "ca-private-key"

	// BootstrapTimeoutKey is the attribute key for the amount of time to wait
	// for bootstrap to complete.
	BootstrapTimeoutKey = "bootstrap-timeout"

	// BootstrapRetryDelayKey is the attribute key for the amount of time
	// in between attempts to connect to a bootstrap machine address.
	BootstrapRetryDelayKey = "bootstrap-retry-delay"

	// BootstrapAddressesDelayKey is the attribute key for the amount of
	// time in between refreshing the bootstrap machine addresses.
	BootstrapAddressesDelayKey = "bootstrap-addresses-delay"

	// ControllerServiceType is for k8s controllers to override
	// the opinionated service type for a given cluster.
	ControllerServiceType = "controller-service-type"

	// ControllerExternalName sets the external name
	// for a k8s controller of type external.
	ControllerExternalName = "controller-external-name"

	// ControllerExternalIPs is used to specify a comma separated
	// list of external IPs for a k8s controller of type external.
	ControllerExternalIPs = "controller-external-ips"
)
View Source
const (

	// DefaultBootstrapSSHTimeout is the amount of time to wait
	// contacting a controller, in seconds.
	DefaultBootstrapSSHTimeout = 1200

	// DefaultBootstrapSSHRetryDelay is the amount of time between
	// attempts to connect to an address, in seconds.
	DefaultBootstrapSSHRetryDelay = 5

	// DefaultBootstrapSSHAddressesDelay is the amount of time betwee
	// refreshing the addresses, in seconds. Not too frequent, as we
	// refresh addresses from the provider each time.
	DefaultBootstrapSSHAddressesDelay = 10
)
View Source
const (
	// ControllerModelName is the name of the admin model in each controller.
	ControllerModelName = "controller"

	// ControllerCharmName is the name of the controller charm.
	ControllerCharmName = "juju-controller"

	// ControllerApplicationName is the name of the controller application.
	ControllerApplicationName = "controller"

	// ControllerCharmArchive is the name of the controller charm archive.
	ControllerCharmArchive = "controller.charm"
)
View Source
const (
	// SimplestreamsFetcherContextKey defines a way to change the simplestreams
	// fetcher within a context.
	SimplestreamsFetcherContextKey corecontext.ContextKey = "simplestreams-fetcher"
)

Variables

BootstrapConfigAttributes are attributes which may be defined by the user at bootstrap time, but should not be present in general controller config.

View Source
var BootstrapConfigSchema = environschema.Fields{
	AdminSecretKey: {
		Description: "Sets the Juju administrator password",
		Type:        environschema.Tstring,
	},
	CACertKey: {
		Description: fmt.Sprintf(
			"Sets the bootstrapped controllers CA cert to use and issue "+
				"certificates from, used in conjunction with %s",
			CAPrivateKeyKey),
		Type: environschema.Tstring,
	},
	CAPrivateKeyKey: {
		Description: fmt.Sprintf(
			"Sets the bootstrapped controllers CA cert private key to sign "+
				"certificates with, used in conjunction with %s",
			CACertKey),
		Type: environschema.Tstring,
	},
	BootstrapTimeoutKey: {
		Description: "Controls how long Juju will wait for a bootstrap to " +
			"complete before considering it failed in seconds",
		Type: environschema.Tint,
	},
	BootstrapRetryDelayKey: {
		Description: "Controls the amount of time in seconds between attempts " +
			"to connect to a bootstrap machine address",
		Type: environschema.Tint,
	},
	BootstrapAddressesDelayKey: {
		Description: "Controls the amount of time in seconds in between " +
			"refreshing the bootstrap machine addresses",
		Type: environschema.Tint,
	},
	ControllerServiceType: {
		Description: "Controls the kubernetes service type for Juju " +
			"controllers, see\n" +
			"https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceSpec\n" +
			"valid values are one of cluster, loadbalancer, external",
		Type: environschema.Tstring,
	},
	ControllerExternalName: {
		Description: "Sets the external name for a k8s controller of type " +
			"external",
		Type: environschema.Tstring,
	},
	ControllerExternalIPs: {
		Description: "Specifies a comma separated list of external IPs for a " +
			"k8s controller of type external",
		Type: environschema.Tlist,
	},
}

BootstrapConfigSchema defines the schema used for config items during bootstrap.

Functions

func Bootstrap

Bootstrap bootstraps the given environment. The supplied constraints are used to provision the instance, and are also set within the bootstrapped environment.

func Cancelled

func Cancelled() error

Cancelled returns an error that satisfies IsCancelled.

func IsBootstrapAttribute

func IsBootstrapAttribute(attr string) bool

IsBootstrapAttribute reports whether or not the specified attribute name is only relevant during bootstrap.

func IsContextDone

func IsContextDone(ctx stdcontext.Context) bool

IsContextDone returns true if the context is done.

func PrepareController

func PrepareController(
	isCAASController bool,
	ctx environs.BootstrapContext,
	store jujuclient.ClientStore,
	args PrepareParams,
) (environs.BootstrapEnviron, error)

PrepareController prepares a new controller based on the provided configuration. It is an error to prepare a controller if there already exists an entry in the client store with the same name.

Upon success, Prepare will update the ClientStore with the details of the controller, admin account, and admin model.

Types

type BootstrapParams

type BootstrapParams struct {
	// ModelConstraints are merged with the bootstrap constraints
	// to choose the initial instance, and will be stored in the
	// initial models' states.
	ModelConstraints constraints.Value

	// BootstrapConstraints are used to choose the initial instance.
	// BootstrapConstraints does not affect the model constraints.
	BootstrapConstraints constraints.Value

	// ControllerName is the controller name.
	ControllerName string

	// BootstrapImage, if specified, is the image ID to use for the
	// initial bootstrap machine.
	BootstrapImage string

	// Cloud contains the properties of the cloud that Juju will be
	// bootstrapped in.
	Cloud cloud.Cloud

	// CloudRegion is the name of the cloud region that Juju will be bootstrapped in.
	CloudRegion string

	// CloudCredentialName is the name of the cloud credential that Juju will be
	// bootstrapped with. This may be empty, for clouds that do not require
	// credentials.
	CloudCredentialName string

	// CloudCredential contains the cloud credential that Juju will be
	// bootstrapped with. This may be nil, for clouds that do not require
	// credentialis.
	CloudCredential *cloud.Credential

	// ControllerConfig is the set of config attributes relevant
	// to a controller.
	ControllerConfig controller.Config

	// ControllerInheritedConfig is the set of config attributes to be shared
	// across all models in the same controller.
	ControllerInheritedConfig map[string]interface{}

	// RegionInheritedConfig holds region specific configuration attributes to
	// be shared across all models in the same controller on a particular
	// cloud.
	RegionInheritedConfig cloud.RegionConfig

	// InitialModelConfig is the set of config attributes to be overlaid
	// on the controller config to construct the initial hosted model
	// config.
	InitialModelConfig map[string]interface{}

	// Placement, if non-empty, holds an environment-specific placement
	// directive used to choose the initial instance.
	Placement string

	// BuildAgent reports whether we should build and upload the local agent
	// binary and override the environment's specified agent-version.
	// It is an error to specify BuildAgent with a nil BuildAgentTarball.
	BuildAgent bool

	// BuildAgentTarball, if non-nil, is a function that may be used to
	// build tools to upload. If this is nil, tools uploading will never
	// take place.
	BuildAgentTarball sync.BuildAgentTarballFunc

	// MetadataDir is an optional path to a local directory containing
	// tools and/or image metadata.
	MetadataDir string

	// AgentVersion, if set, determines the exact tools version that
	// will be used to start the Juju agents.
	AgentVersion *version.Number

	// AdminSecret contains the administrator password.
	AdminSecret string

	// CAPrivateKey is the controller's CA certificate private key.
	CAPrivateKey string

	// ControllerServiceType is the service type of a k8s controller.
	ControllerServiceType string

	// ControllerExternalName is the external name of a k8s controller.
	ControllerExternalName string

	// ControllerExternalIPs is the list of external ips for a k8s controller.
	ControllerExternalIPs []string

	// DialOpts contains the bootstrap dial options.
	DialOpts environs.BootstrapDialOpts

	// JujuDbSnapPath is the path to a local .snap file that will be used
	// to run the juju-db service.
	JujuDbSnapPath string

	// JujuDbSnapAssertionsPath is the path to a local .assertfile that
	// will be used to test the contents of the .snap at JujuDbSnap.
	JujuDbSnapAssertionsPath string

	// StoragePools is one or more named storage pools to create
	// in the controller model.
	StoragePools map[string]corestorage.Attrs

	// Force is used to allow a bootstrap to be run on unsupported series.
	Force bool

	// ControllerCharmPath is a local controller charm archive.
	ControllerCharmPath string

	// ControllerCharmChannel is used when fetching the charmhub controller charm.
	ControllerCharmChannel charm.Channel

	// ExtraAgentValuesForTesting are testing only values written to the agent config file.
	ExtraAgentValuesForTesting map[string]string

	// BootstrapBase, if specified, is the base to use for the
	// initial bootstrap machine (deprecated use BootstrapBase).
	BootstrapBase corebase.Base

	// SupportedBootstrapBase is a supported set of bases to use for
	// validating against the bootstrap base.
	SupportedBootstrapBases []corebase.Base
}

BootstrapParams holds the parameters for bootstrapping an environment.

func (BootstrapParams) Validate

func (p BootstrapParams) Validate() error

Validate validates the bootstrap parameters.

type Config

type Config struct {
	AdminSecret             string
	CACert                  string
	CAPrivateKey            string
	ControllerServiceType   string
	ControllerExternalName  string
	ControllerExternalIPs   []string
	BootstrapTimeout        time.Duration
	BootstrapRetryDelay     time.Duration
	BootstrapAddressesDelay time.Duration
}

Config contains bootstrap-specific configuration.

func NewConfig

func NewConfig(attrs map[string]interface{}) (Config, error)

NewConfig creates a new Config from the supplied attributes. Default values will be used where defaults are available.

If ca-cert or ca-private-key are not set, then we will check if ca-cert-path or ca-private-key-path are set, and read the contents. If none of those are set, we will look for files in well-defined locations: $JUJU_DATA/ca-cert.pem, and $JUJU_DATA/ca-private-key.pem. If none of these are set, an error is returned.

func (Config) Validate

func (c Config) Validate() error

Validate validates the controller configuration.

type PrepareParams

type PrepareParams struct {
	// ModelConfig contains the base configuration for the controller model.
	//
	// This includes the model name, cloud type, any user-supplied
	// configuration, config inherited from controller, and any defaults.
	ModelConfig map[string]interface{}

	// ControllerConfig is the configuration of the controller being prepared.
	ControllerConfig controller.Config

	// ControllerName is the name of the controller being prepared.
	ControllerName string

	// Cloud is the specification of the cloud that the controller is
	// being prepared for.
	Cloud environscloudspec.CloudSpec

	// CredentialName is the name of the credential to use to bootstrap.
	// This will be empty for auto-detected credentials.
	CredentialName string

	// AdminSecret contains the password for the admin user.
	AdminSecret string
}

PrepareParams contains the parameters for preparing a controller Environ for bootstrapping.

func (PrepareParams) Validate

func (p PrepareParams) Validate() error

Validate validates the PrepareParams.

Jump to

Keyboard shortcuts

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