userdata

package
v0.1.0-alpha.28 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrRequiredSection denotes a section is required
	ErrRequiredSection = errors.New("required userdata section")
	// ErrInvalidVersion denotes that the config file version is invalid
	ErrInvalidVersion = errors.New("invalid config version")

	// ErrInvalidCert denotes that the certificate specified is invalid
	ErrInvalidCert = errors.New("certificate is invalid")
	// ErrInvalidCertType denotes that the certificate type is invalid
	ErrInvalidCertType = errors.New("certificate type is invalid")

	// ErrUnsupportedCNI denotes that the specified CNI is invalid
	ErrUnsupportedCNI = errors.New("unsupported CNI driver")
	// ErrInvalidTrustdToken denotes that a trustd token has not been specified
	ErrInvalidTrustdToken = errors.New("trustd token is invalid")

	// ErrBadAddressing denotes that an incorrect combination of network
	// address methods have been specified
	ErrBadAddressing = errors.New("invalid network device addressing method")
	// ErrInvalidAddress denotes that a bad address was provided
	ErrInvalidAddress = errors.New("invalid network address")
)

Functions

This section is empty.

Types

type Bond

type Bond struct {
	Mode       string   `yaml:"mode"`
	HashPolicy string   `yaml:"hashpolicy"`
	LACPRate   string   `yaml:"lacprate"`
	Interfaces []string `yaml:"interfaces"`
}

Bond contains the various options for configuring a bonded interface

type BootDevice

type BootDevice struct {
	InstallDevice `yaml:",inline"`

	Kernel    string `yaml:"kernel"`
	Initramfs string `yaml:"initramfs"`
}

BootDevice represents the install options specific to the boot partition.

type CRT

type CRT struct {
	CommonServiceOptions `yaml:",inline"`
}

CRT describes the configuration of the container runtime service.

type CommonServiceOptions

type CommonServiceOptions struct {
	Env Env `yaml:"env,omitempty"`
}

CommonServiceOptions represents the set of options common to all services.

type Device

type Device struct {
	Interface string  `yaml:"interface"`
	CIDR      string  `yaml:"cidr"`
	DHCP      bool    `yaml:"dhcp"`
	Routes    []Route `yaml:"routes"`
	Bond      *Bond   `yaml:"bond"`
}

Device represents a network interface

func (*Device) Validate

func (d *Device) Validate(checks ...NetworkDeviceCheck) error

Validate triggers the specified validation checks to run

type Env

type Env = map[string]string

Env represents a set of environment variables.

type ExtraDevice

type ExtraDevice struct {
	Device     string                  `yaml:"device,omitempty"`
	Partitions []*ExtraDevicePartition `yaml:"partitions,omitempty"`
}

ExtraDevice represents the options available for partitioning, formatting, and mounting extra disks.

type ExtraDevicePartition

type ExtraDevicePartition struct {
	Size       uint   `yaml:"size,omitempty"`
	MountPoint string `yaml:"mountpoint,omitempty"`
}

ExtraDevicePartition represents the options for a device partition.

type File

type File struct {
	Contents    string      `yaml:"contents"`
	Permissions os.FileMode `yaml:"permissions"`
	Path        string      `yaml:"path"`
}

File represents a file to write to disk.

type Init

type Init struct {
	CNI string `yaml:"cni,omitempty"`
}

Init describes the configuration of the init service.

func (*Init) Validate

func (i *Init) Validate(checks ...InitCheck) error

Validate triggers the specified validation checks to run

type InitCheck

type InitCheck func(*Init) error

InitCheck defines the function type for checks

func CheckInitCNI

func CheckInitCNI() InitCheck

CheckInitCNI ensures that a valid cni driver has been specified

type Install

type Install struct {
	Boot         *BootDevice    `yaml:"boot,omitempty"`
	Root         *RootDevice    `yaml:"root"`
	Data         *InstallDevice `yaml:"data,omitempty"`
	ExtraDevices []*ExtraDevice `yaml:"extraDevices,omitempty"`
	Wipe         bool           `yaml:"wipe"`
	Force        bool           `yaml:"force"`
}

Install represents the installation options for preparing a node.

type InstallDevice

type InstallDevice struct {
	Device string `yaml:"device,omitempty"`
	Size   uint   `yaml:"size,omitempty"`
}

InstallDevice represents the specific directions for each partition.

type Kubeadm

type Kubeadm struct {
	CommonServiceOptions `yaml:",inline"`

	// ConfigurationStr is converted to Configuration and back in Marshal/UnmarshalYAML
	Configuration    runtime.Object `yaml:"-"`
	ConfigurationStr string         `yaml:"configuration"`

	ExtraArgs             []string     `yaml:"extraArgs,omitempty"`
	CertificateKey        string       `yaml:"certificateKey,omitempty"`
	IgnorePreflightErrors []string     `yaml:"ignorePreflightErrors,omitempty"`
	Token                 *token.Token `yaml:"initToken,omitempty"`
	// contains filtered or unexported fields
}

Kubeadm describes the set of configuration options available for kubeadm.

func (*Kubeadm) IsBootstrap

func (kdm *Kubeadm) IsBootstrap() bool

IsBootstrap indicates if the current kubeadm configuration is a master init configuration.

func (*Kubeadm) IsControlPlane

func (kdm *Kubeadm) IsControlPlane() bool

IsControlPlane indicates if the current kubeadm configuration is a worker acting as a master.

func (*Kubeadm) IsWorker

func (kdm *Kubeadm) IsWorker() bool

IsWorker indicates if the current kubeadm configuration is a worker configuration.

func (*Kubeadm) MarshalYAML

func (kdm *Kubeadm) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*Kubeadm) UnmarshalYAML

func (kdm *Kubeadm) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Kubelet

type Kubelet struct {
	CommonServiceOptions `yaml:",inline"`
	ExtraMounts          []specs.Mount `yaml:"extraMounts"`
}

Kubelet describes the configuration of the kubelet service.

type KubernetesSecurity

type KubernetesSecurity struct {
	CA         *x509.PEMEncodedCertificateAndKey `yaml:"ca"`
	SA         *x509.PEMEncodedCertificateAndKey `yaml:"sa"`
	FrontProxy *x509.PEMEncodedCertificateAndKey `yaml:"frontproxy"`
	Etcd       *x509.PEMEncodedCertificateAndKey `yaml:"etcd"`
}

KubernetesSecurity represents the set of security options specific to Kubernetes.

func (*KubernetesSecurity) Validate

func (k *KubernetesSecurity) Validate(checks ...KubernetesSecurityCheck) error

Validate triggers the specified validation checks to run

type KubernetesSecurityCheck

type KubernetesSecurityCheck func(*KubernetesSecurity) error

KubernetesSecurityCheck defines the function type for checks

func CheckKubernetesCA

func CheckKubernetesCA() KubernetesSecurityCheck

CheckKubernetesCA verfies the KubernetesSecurity settings are valid

type NTPd

type NTPd struct {
	CommonServiceOptions `yaml:",inline"`

	Server string `yaml:"server,omitempty"`
}

NTPd describes the configuration of the ntp service.

type NetworkDeviceCheck

type NetworkDeviceCheck func(*Device) error

NetworkDeviceCheck defines the function type for checks

func CheckDeviceAddressing

func CheckDeviceAddressing() NetworkDeviceCheck

CheckDeviceAddressing ensures that an appropriate addressing method has been specified

func CheckDeviceInterface

func CheckDeviceInterface() NetworkDeviceCheck

CheckDeviceInterface ensures that the interface has been specified

func CheckDeviceRoutes

func CheckDeviceRoutes() NetworkDeviceCheck

CheckDeviceRoutes ensures that the specified routes are valid

type Networking

type Networking struct {
	Kubernetes struct{} `yaml:"kubernetes"`
	OS         *OSNet   `yaml:"os"`
}

Networking represents the set of options available to configure networking.

type OSD

type OSD struct {
	CommonServiceOptions `yaml:",inline"`
}

OSD describes the configuration of the osd service.

type OSNet

type OSNet struct {
	Devices []Device `yaml:"devices"`
}

OSNet represents the network interfaces present on the host

type OSSecurity

type OSSecurity struct {
	CA       *x509.PEMEncodedCertificateAndKey `yaml:"ca"`
	Identity *x509.PEMEncodedCertificateAndKey `yaml:"identity"`
}

OSSecurity represents the set of security options specific to the OS.

func (*OSSecurity) Validate

func (o *OSSecurity) Validate(checks ...OSSecurityCheck) error

Validate triggers the specified validation checks to run

type OSSecurityCheck

type OSSecurityCheck func(*OSSecurity) error

OSSecurityCheck defines the function type for checks

func CheckOSCA

func CheckOSCA() OSSecurityCheck

CheckOSCA verfies the OSSecurity settings are valid

type Proxyd

type Proxyd struct {
	CommonServiceOptions `yaml:",inline"`
}

Proxyd describes the configuration of the proxyd service.

type RootDevice

type RootDevice struct {
	InstallDevice `yaml:",inline"`

	Rootfs string `yaml:"rootfs"`
}

RootDevice represents the install options specific to the root partition.

type Route

type Route struct {
	Network string `yaml:"network"`
	Gateway string `yaml:"gateway"`
}

Route represents a network route

type Security

type Security struct {
	OS         *OSSecurity         `yaml:"os"`
	Kubernetes *KubernetesSecurity `yaml:"kubernetes"`
}

Security represents the set of options available to configure security.

type ServiceCheck

type ServiceCheck func(*Services) error

ServiceCheck defines the function type for checks

func CheckServices

func CheckServices() ServiceCheck

CheckServices ensures the minimum necessary services config has been provided

type Services

type Services struct {
	Init    *Init    `yaml:"init"`
	Kubelet *Kubelet `yaml:"kubelet"`
	Kubeadm *Kubeadm `yaml:"kubeadm"`
	Trustd  *Trustd  `yaml:"trustd"`
	Proxyd  *Proxyd  `yaml:"proxyd"`
	OSD     *OSD     `yaml:"osd"`
	CRT     *CRT     `yaml:"crt"`
	NTPd    *NTPd    `yaml:"ntp"`
}

Services represents the set of services available to configure.

func (*Services) Validate

func (s *Services) Validate(checks ...ServiceCheck) error

Validate triggers the specified validation checks to run

type Trustd

type Trustd struct {
	CommonServiceOptions `yaml:",inline"`

	Token         string   `yaml:"token"`
	Username      string   `yaml:"username"`
	Password      string   `yaml:"password"`
	Endpoints     []string `yaml:"endpoints,omitempty"`
	CertSANs      []string `yaml:"certSANs,omitempty"`
	BootstrapNode string   `yaml:"bootstrapNode,omitempty"`
}

Trustd describes the configuration of the Root of Trust (RoT) service. The username and password are used by master nodes, and worker nodes. The master nodes use them to authenticate clients, while the workers use them to authenticate as a client. The endpoints should only be specified in the worker user data, and should include all master nodes participating as a RoT.

func (*Trustd) Validate

func (t *Trustd) Validate(checks ...TrustdCheck) error

Validate triggers the specified validation checks to run

type TrustdCheck

type TrustdCheck func(*Trustd) error

TrustdCheck defines the function type for checks

func CheckTrustdAuth

func CheckTrustdAuth() TrustdCheck

CheckTrustdAuth ensures that a trustd token has been specified

func CheckTrustdEndpointsArePresent

func CheckTrustdEndpointsArePresent() TrustdCheck

CheckTrustdEndpointsArePresent ensures that tustd endpoints are present.

func CheckTrustdEndpointsAreValidIPs

func CheckTrustdEndpointsAreValidIPs() TrustdCheck

CheckTrustdEndpointsAreValidIPs ensures that the specified trustd endpoints / are valid IP addresses.

type UserData

type UserData struct {
	Version    Version     `yaml:"version"`
	Security   *Security   `yaml:"security"`
	Networking *Networking `yaml:"networking"`
	Services   *Services   `yaml:"services"`
	Files      []*File     `yaml:"files"`
	Debug      bool        `yaml:"debug"`
	Env        Env         `yaml:"env,omitempty"`
	Install    *Install    `yaml:"install,omitempty"`
}

UserData represents the user data.

func Download

func Download(url string, headers *map[string]string) (data *UserData, err error)

Download initializes a UserData struct from a remote URL. nolint: gocyclo

func Open

func Open(p string) (data *UserData, err error)

Open is a convenience function that reads the user data from disk, and unmarshals it.

func (*UserData) NewIdentityCSR

func (data *UserData) NewIdentityCSR() (csr *x509.CertificateSigningRequest, err error)

NewIdentityCSR creates a new CSR for the node's identity certificate.

func (*UserData) Validate

func (data *UserData) Validate() error

Validate ensures the required fields are present in the userdata nolint: gocyclo

func (*UserData) WriteFiles

func (data *UserData) WriteFiles() (err error)

WriteFiles writes the requested files to disk.

type Version

type Version string

Version represents the config file version

func (Version) Validate

func (v Version) Validate() error

Validate triggers the specified validation checks to run

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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