cloudinit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCloudConfig

func GenerateCloudConfig(config CloudConfig) ([]byte, error)

GenerateCloudConfig generates userdata from a CloudConfig.

Types

type BaseUserData

type BaseUserData struct {
	// KubernetesVersion is the Kubernetes version from the cluster object.
	KubernetesVersion string
	// SnapInstallData is the snap install data.
	SnapInstallData *SnapInstallData
	// BootCommands is a list of commands to run early in the boot process.
	BootCommands []string
	// PreRunCommands is a list of commands to run prior to k8s installation.
	PreRunCommands []string
	// PostRunCommands is a list of commands to run after k8s installation.
	PostRunCommands []string
	// BootstrapConfig is the contents of the bootstrap configuration file.
	BootstrapConfig string
	// ExtraFiles is a list of extra files to load on the host.
	ExtraFiles []File
	// ConfigFileContents is the contents of the k8s configuration file.
	ConfigFileContents string
	// AirGapped declares that a custom installation script is to be used.
	AirGapped bool
	// The snap store proxy domain's scheme, e.g. "http" or "https" without "://"
	SnapstoreProxyScheme string
	// The snap store proxy domain
	SnapstoreProxyDomain string
	// The snap store proxy ID
	SnapstoreProxyID string
	// HTTPProxy is http_proxy configuration.
	HTTPProxy string
	// HTTPSProxy is https_proxy configuration.
	HTTPSProxy string
	// NoProxy is no_proxy configuration.
	NoProxy string
	// MicroclusterAddress is the address to use for microcluster.
	MicroclusterAddress string
	// MicroclusterPort is the port to use for microcluster.
	MicroclusterPort int
	// NodeName is the name of the node to set on microcluster.
	NodeName string
	// NodeToken is used for authenticating per-node k8sd endpoints.
	NodeToken string
}

type CloudConfig

type CloudConfig struct {
	// WriteFiles is a list of files cloud-init will create on the first boot.
	WriteFiles []File `yaml:"write_files"`

	// RunCommands is a list of commands to execute during the first boot.
	RunCommands []string `yaml:"runcmd"`

	// BootCommands is a list of commands to run early in the boot process.
	BootCommands []string `yaml:"bootcmd,omitempty"`
}

CloudConfig is cloud-init userdata. The schema matches the examples found in https://cloudinit.readthedocs.io/en/latest/topics/examples.html.

func NewBaseCloudConfig

func NewBaseCloudConfig(data BaseUserData) (CloudConfig, error)

func NewInitControlPlane

func NewInitControlPlane(input InitControlPlaneInput) (CloudConfig, error)

NewInitControlPlane returns the user data string to be used on a controlplane instance.

func NewJoinControlPlane

func NewJoinControlPlane(input JoinControlPlaneInput) (CloudConfig, error)

NewJoinControlPlane returns the user data string to be used on a controlplane instance.

func NewJoinWorker

func NewJoinWorker(input JoinWorkerInput) (CloudConfig, error)

NewJoinWorker returns the user data string to be used on a controlplane instance.

type File

type File struct {
	// Content of the file to create.
	Content string `yaml:"content"`
	// Path where the file should be created.
	Path string `yaml:"path"`
	// Permissions of the file to create, e.g. "0600"
	Permissions string `yaml:"permissions,omitempty"`
	// Owner of the file to create, e.g. "root:root"
	Owner string `yaml:"owner,omitempty"`
	// Encoding is the file encoding, e.g. "base64"
	Encoding string `yaml:"encoding,omitempty"`
}

File is a file that cloud-init will create.

func FilesFromAPI

func FilesFromAPI(files []bootstrapv1.File) []File

type InitControlPlaneInput

type InitControlPlaneInput struct {
	BaseUserData
	// AuthToken is used to join more cluster nodes.
	AuthToken string
	// K8sdProxyDaemonSet is the manifest that deploys k8sd-proxy to the cluster.
	K8sdProxyDaemonSet string
}

InitControlPlaneInput defines the context to generate an init controlplane instance user data.

type InstallOption added in v0.2.0

type InstallOption string
const (
	InstallOptionChannel   InstallOption = "channel"
	InstallOptionRevision  InstallOption = "revision"
	InstallOptionLocalPath InstallOption = "local-path"
)

type JoinControlPlaneInput

type JoinControlPlaneInput struct {
	BaseUserData
	// JoinToken is the token to use to join the cluster.
	JoinToken string
}

JoinControlPlaneInput defines the context to generate a join controlplane instance user data.

type JoinWorkerInput

type JoinWorkerInput struct {
	BaseUserData
	// JoinToken is the token to use to join the cluster.
	JoinToken string
}

JoinWorkerInput defines the context to generate a join controlplane instance user data.

type SnapInstallData added in v0.2.0

type SnapInstallData struct {
	// Option is the snap install option e.g. --channel, --revision.
	Option InstallOption
	// Value is the snap install value e.g. 1.30/stable, 123, /path/to/k8s.snap.
	Value string
}

Jump to

Keyboard shortcuts

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