Documentation ¶
Index ¶
- Constants
- func TokenID(s string) (string, error)
- type Flags
- func (f *Flags) Add(s string)
- func (f *Flags) AddOrReplace(s string)
- func (f *Flags) AddUnlessExist(s string)
- func (f *Flags) Delete(s string)
- func (f Flags) Get(s string) string
- func (f Flags) GetValue(s string) string
- func (f Flags) Include(s string) bool
- func (f Flags) Index(s string) int
- func (f *Flags) Join() string
- func (f *Flags) Merge(b Flags)
- func (f *Flags) MergeAdd(b Flags)
- func (f *Flags) MergeOverwrite(b Flags)
- type Hooks
- type Host
- func (h *Host) Address() string
- func (h *Host) CheckHTTPStatus(url string, expected ...int) error
- func (h *Host) DrainNode(node *Host) error
- func (h *Host) IsController() bool
- func (h *Host) K0sBackupCommand(targetDir string) string
- func (h *Host) K0sConfigPath() string
- func (h *Host) K0sInstallCommand() string
- func (h *Host) K0sJoinTokenPath() string
- func (h *Host) K0sRestoreCommand(backupfile string) string
- func (h *Host) K0sServiceName() string
- func (h *Host) KubeNodeReady(node *Host) (bool, error)
- func (h *Host) NeedCurl() bool
- func (h *Host) NeedIPTables() bool
- func (h *Host) NeedInetUtils() bool
- func (h *Host) Protocol() string
- func (h *Host) ResolveConfigurer() error
- func (h *Host) SetDefaults()
- func (h *Host) UncordonNode(node *Host) error
- func (h *Host) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (h *Host) UpdateK0sBinary(version string) error
- func (h *Host) Validate() error
- func (h *Host) WaitHTTPStatus(url string, expected ...int) error
- func (h *Host) WaitK0sServiceRunning() error
- func (h *Host) WaitK0sServiceStopped() error
- func (h *Host) WaitKubeAPIReady(port int) error
- func (h *Host) WaitKubeNodeReady(node *Host) error
- type HostMetadata
- type Hosts
- func (hosts Hosts) Controllers() Hosts
- func (hosts Hosts) Filter(filter func(h *Host) bool) Hosts
- func (hosts Hosts) Find(filter func(h *Host) bool) *Host
- func (hosts Hosts) First() *Host
- func (hosts Hosts) Last() *Host
- func (hosts Hosts) ParallelEach(filter ...func(h *Host) error) error
- func (hosts Hosts) Validate() error
- func (hosts Hosts) WithRole(s string) Hosts
- func (hosts Hosts) Workers() Hosts
- type K0s
- type K0sMetadata
- type LocalFile
- type Spec
- type UploadFile
Constants ¶
const K0sMinVersion = "0.11.0-rc1"
K0sMinVersion is the minimum k0s version supported
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Flags ¶
type Flags []string
Flags is a slice of strings with added functions to ease manipulating lists of command-line flags
func (*Flags) AddOrReplace ¶
AddOrReplace replaces a flag with the same prefix or adds a new one if one does not exist
func (*Flags) AddUnlessExist ¶
AddUnlessExist adds a flag unless one with the same prefix exists
func (Flags) Get ¶
Get returns the full flag with the possible value such as "--san=10.0.0.1" or "" when not found
func (Flags) GetValue ¶
GetValue returns the value part of a flag such as "10.0.0.1" for a flag like "--san=10.0.0.1"
func (*Flags) Merge ¶
Merge takes the flags from another Flags and adds them to this one unless this already has that flag set
func (*Flags) MergeAdd ¶
MergeAdd takes the flags from another Flags and adds them into this one even if they exist
func (*Flags) MergeOverwrite ¶
MergeOverwrite takes the flags from another Flags and adds or replaces them into this one
type Hooks ¶
Hooks define a list of hooks such as hooks["apply"]["before"] = ["ls -al", "rm foo.txt"]
func (Hooks) ForActionAndStage ¶
ForActionAndStage return hooks for given action and stage
type Host ¶
type Host struct { rig.Connection `yaml:",inline"` Role string `yaml:"role"` PrivateInterface string `yaml:"privateInterface,omitempty"` PrivateAddress string `yaml:"privateAddress,omitempty"` Environment map[string]string `yaml:"environment,flow,omitempty"` UploadBinary bool `yaml:"uploadBinary,omitempty"` K0sBinaryPath string `yaml:"k0sBinaryPath,omitempty"` InstallFlags Flags `yaml:"installFlags,omitempty"` Files []*UploadFile `yaml:"files,omitempty"` OSIDOverride string `yaml:"os,omitempty"` HostnameOverride string `yaml:"hostname,omitempty"` Hooks Hooks `yaml:"hooks,omitempty"` UploadBinaryPath string `yaml:"-"` Metadata HostMetadata `yaml:"-"` Configurer configurer `yaml:"-"` }
Host contains all the needed details to work with hosts
func (*Host) CheckHTTPStatus ¶
CheckHTTPStatus will perform a web request to the url and return an error if the http status is not the expected
func (*Host) IsController ¶
IsController returns true for controller and controller+worker roles
func (*Host) K0sBackupCommand ¶
K0sBackupCommand returns a full command to be used as run k0s backup
func (*Host) K0sConfigPath ¶
K0sConfigPath returns the config file path from install flags or configurer
func (*Host) K0sInstallCommand ¶
K0sInstallCommand returns a full command that will install k0s service with necessary flags
func (*Host) K0sJoinTokenPath ¶
K0sJoinTokenPath returns the token file path from install flags or configurer
func (*Host) K0sRestoreCommand ¶
K0sRestoreCommand returns a full command to restore cluster state from a backup
func (*Host) K0sServiceName ¶
K0sServiceName returns correct service name
func (*Host) KubeNodeReady ¶
KubeNodeReady runs kubectl on the host and returns true if the given node is marked as ready
func (*Host) NeedIPTables ¶
NeedIPTables returns true when the iptables package is needed on the host
func (*Host) NeedInetUtils ¶
NeedInetUtils returns true when the inetutils package is needed on the host to run `hostname`.
func (*Host) ResolveConfigurer ¶
ResolveConfigurer assigns a rig-style configurer to the Host (see configurer/)
func (*Host) SetDefaults ¶
func (h *Host) SetDefaults()
func (*Host) UncordonNode ¶
UncordonNode marks the node schedulable again
func (*Host) UnmarshalYAML ¶
UnmarshalYAML sets in some sane defaults when unmarshaling the data from yaml
func (*Host) UpdateK0sBinary ¶
UpdateK0sBinary updates the binary on the host either by downloading or uploading, based on the config
func (*Host) WaitHTTPStatus ¶
WaitHTTPStatus waits until http status received for a GET from the URL is the expected one
func (*Host) WaitK0sServiceRunning ¶
WaitK0sServiceRunning blocks until the k0s service is running on the host
func (*Host) WaitK0sServiceStopped ¶
WaitK0sServiceStopped blocks until the k0s service is no longer running on the host
func (*Host) WaitKubeAPIReady ¶
WaitKubeAPIReady blocks until the local kube api responds to /version
func (*Host) WaitKubeNodeReady ¶
WaitKubeNodeReady blocks until node becomes ready. TODO should probably use Context
type HostMetadata ¶
type HostMetadata struct { K0sBinaryVersion string K0sRunningVersion string Arch string IsK0sLeader bool Hostname string Ready bool NeedsUpgrade bool }
HostMetadata resolved metadata for host
type Hosts ¶
type Hosts []*Host
Hosts are destnation hosts
func (Hosts) Controllers ¶
Controllers returns hosts with the role "controller"
func (Hosts) Filter ¶
Filter returns a filtered list of Hosts. The filter function should return true for hosts matching the criteria.
func (Hosts) Find ¶
Find returns the first matching Host. The finder function should return true for a Host matching the criteria.
func (Hosts) ParallelEach ¶
ParallelEach runs a function (or multiple functions chained) on every Host parallelly. Any errors will be concatenated and returned.
type K0s ¶
type K0s struct { Version string `yaml:"version"` Config dig.Mapping `yaml:"config,omitempty"` Metadata K0sMetadata `yaml:"-"` }
K0s holds configuration for bootstraping a k0s cluster
func (K0s) GenerateToken ¶
GenerateToken runs the k0s token create command
func (K0s) GetClusterID ¶
GetClusterID uses kubectl to fetch the kube-system namespace uid
func (*K0s) SetDefaults ¶
func (k *K0s) SetDefaults()
SetDefaults (implements defaults Setter interface) defaults the version to latest k0s version
func (*K0s) UnmarshalYAML ¶
UnmarshalYAML sets in some sane defaults when unmarshaling the data from yaml
type K0sMetadata ¶
K0sMetadata contains gathered information about k0s cluster
type Spec ¶
type Spec struct { Hosts Hosts `yaml:"hosts"` K0s *K0s `yaml:"k0s"` // contains filtered or unexported fields }
Spec defines cluster config spec section
func (*Spec) K0sLeader ¶
K0sLeader returns a controller host that is selected to be a "leader", or an initial node, a node that creates join tokens for other controllers.
func (*Spec) KubeAPIURL ¶
KubeAPIURL returns an url to the cluster's kube api
func (*Spec) UnmarshalYAML ¶
UnmarshalYAML sets in some sane defaults when unmarshaling the data from yaml
type UploadFile ¶
type UploadFile struct { Name string `yaml:"name,omitempty"` Source string `yaml:"src"` DestinationDir string `yaml:"dstDir"` DestinationFile string `yaml:"dst"` PermMode interface{} `yaml:"perm"` DirPermMode interface{} `yaml:"dirPerm"` User string `yaml:"user"` Group string `yaml:"group"` PermString string `yaml:"-"` DirPermString string `yaml:"-"` Sources []*LocalFile `yaml:"-"` Base string `yaml:"-"` }
UploadFile describes a file to be uploaded for the host
func (*UploadFile) IsURL ¶
func (u *UploadFile) IsURL() bool
IsURL returns true if the source is a URL
func (*UploadFile) Owner ¶
func (u *UploadFile) Owner() string
Owner returns a chown compatible user:group string from User and Group, or empty when neither are set.
func (*UploadFile) String ¶
func (u *UploadFile) String() string
String returns the file bundle name or if it is empty, the source.
func (*UploadFile) UnmarshalYAML ¶
func (u *UploadFile) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML sets in some sane defaults when unmarshaling the data from yaml
func (UploadFile) Validate ¶
func (u UploadFile) Validate() error