Documentation ¶
Index ¶
- Constants
- Variables
- func Bootstrap(ctx environs.BootstrapContext, environ environs.BootstrapEnviron, ...) error
- func Cancelled() error
- func IsBootstrapAttribute(attr string) bool
- func IsCancelled(err error) bool
- func PrepareController(isCAASController bool, ctx environs.BootstrapContext, ...) (environs.BootstrapEnviron, error)
- type BootstrapParams
- type Config
- type PrepareParams
Constants ¶
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" )
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 )
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" )
Variables ¶
var BootstrapConfigAttributes = []string{ AdminSecretKey, CACertKey, CAPrivateKeyKey, BootstrapTimeoutKey, BootstrapRetryDelayKey, BootstrapAddressesDelayKey, ControllerServiceType, ControllerExternalName, ControllerExternalIPs, }
BootstrapConfigAttributes are attributes which may be defined by the user at bootstrap time, but should not be present in general controller config.
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 " + "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#servicespec-v1-core " + "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.Tstring, }, }
BootstrapConfigSchema defines the schema used for config items during bootstrap.
Functions ¶
func Bootstrap ¶
func Bootstrap( ctx environs.BootstrapContext, environ environs.BootstrapEnviron, callCtx context.ProviderCallContext, args BootstrapParams, ) error
Bootstrap bootstraps the given environment. The supplied constraints are used to provision the instance, and are also set within the bootstrapped environment.
func IsBootstrapAttribute ¶
IsBootstrapAttribute reports whether or not the specified attribute name is only relevant during bootstrap.
func IsCancelled ¶
IsCancelled reports whether err is a "bootstrap cancelled" error.
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 // BootstrapSeries, if specified, is the series to use for the // initial bootstrap machine. BootstrapSeries string // SupportedBootstrapSeries is a supported set of series to use for // validating against the bootstrap series. SupportedBootstrapSeries set.Strings // 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 // HostedModelConfig is the set of config attributes to be overlaid // on the controller config to construct the initial hosted model // config. HostedModelConfig 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 // DashboardDataSourceBaseURL holds the simplestreams data source base URL // used to retrieve the Juju Dashboard archive installed in the controller. // If not set, the Juju Dashboard is not installed from simplestreams. DashboardDataSourceBaseURL string // 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 // ExtraAgentValuesForTesting are testing only values written to the agent config file. ExtraAgentValuesForTesting map[string]string }
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 ¶
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.
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.