Documentation ¶
Index ¶
- Constants
- func ConfigPath() string
- func Dependencies(w io.Writer, services []string) error
- func PrintConfig(w io.Writer, cfg Config) error
- func PrintConfigTemplate(w io.Writer) error
- func RenderContainerLinuxConfigTemplate(w io.Writer) error
- type Config
- type ContainerLinuxConfig
- type JoinConfiguration
- type NodeConfig
- type NodeRole
- type Patches
- type Reboot
- type Server
- func (s Server) AnnotateNodes(cfg Config) error
- func (s Server) Apply(yaml []byte, delete bool, namespace string) error
- func (s Server) ApplyServices(cfg Config, services []string, delete, verbose bool, tries int, ...) error
- func (s Server) ApplyTpl(yaml []byte, delete bool, namespace string, cfg *Config) error
- func (s Server) AwaitDNS(domain string) error
- func (s Server) BootRescueMode(cfg Config) error
- func (s Server) ConfigureFlatcar(cfg Config) error
- func (s Server) ConfigureSSHKeys(cfg Config) error
- func (s Server) CreateUsers(cfg Config) error
- func (s Server) DeployServices(cfg Config, services []string, delete, verbose bool, tries int) error
- func (s Server) Exec(args []string) error
- func (s Server) FinalizeMaintenance(c Config) error
- func (s Server) InitCluster(cfg Config) error
- func (s Server) InstallFlatcar(cfg Config) error
- func (s Server) KubeConfig(w io.Writer, cfg Config) error
- func (s Server) KubernetesStatus() error
- func (s Server) KuredStatus(sentinel string) (bool, error)
- func (s Server) Log(f string, a ...interface{})
- func (s Server) NodesStatus() error
- func (s Server) PatchAPIService(cfg Config) error
- func (s Server) PrepareMaintenance(c Config) error
- func (s Server) Reboot(rst Reboot) error
- func (s Server) RebootToSSH(rst Reboot) error
- func (s Server) RenderContainerLinuxConfig(cfg Config) ([]byte, error)
- func (s Server) RenderIgnitionConfig(cfg Config) ([]byte, error)
- func (s Server) ResetKubeadm() error
- func (s Server) RestartService(svc string) error
- func (s Server) RobotNode() robot.Server
- func (s Server) SetupAddons(cfg Config, delete, verbose bool, tries int) error
- func (s Server) SetupFlatcar(cfg Config) error
- func (s Server) Sonobuoy() error
- func (s Server) TestServices(cfg Config, services []string, verbose, sync bool, reties int, filter string) error
- func (s Server) UptimeStatus() error
- func (s Server) UserKubeConfig(w io.Writer, cfg Config, user string) error
- type Servers
- func (ss Servers) BootRescueMode(cfg Config) error
- func (ss Servers) ConfigureFlatcar(cfg Config) error
- func (ss Servers) ConfigureSSHKeys(cfg Config) error
- func (ss Servers) Count() int
- func (ss Servers) DeleteDataDisk(cfg Config) error
- func (ss Servers) DisableFirewall() error
- func (ss Servers) DisableRescueMode() error
- func (ss Servers) EnableFirewall() error
- func (ss Servers) EnableRescueMode(cfg Config) error
- func (ss Servers) EtcHosts(w io.Writer) error
- func (ss Servers) Exec(args []string, abortOnFailure bool) error
- func (ss Servers) Filter(nodeSelection string) Servers
- func (ss Servers) FirewallStatus() error
- func (ss Servers) InstallFlatcar(cfg Config) error
- func (ss Servers) JoinMasters(primaryMaster Server, cfg Config) error
- func (ss Servers) JoinWorker(master Server, cfg Config) error
- func (ss Servers) KubeadmUpdate(cfg Config, skipDrain, skipAwaitReady, verbose bool) error
- func (ss Servers) KuredStatus(sentinel string) (bool, error)
- func (ss Servers) MastersCount() int
- func (ss Servers) NonePrimaryMaster() Servers
- func (ss Servers) PrimaryMaster() (Server, error)
- func (ss Servers) Reboot(rst Reboot) error
- func (ss Servers) RebootHardware() error
- func (ss Servers) RebootHardwareUngraceful() error
- func (ss Servers) RebootKured() error
- func (ss Servers) RebootKuredRealTime() error
- func (ss Servers) RebootManually() error
- func (ss Servers) RebootRescueSystem() error
- func (ss Servers) RebootSystem() error
- func (ss Servers) RebootToSSH(rst Reboot) error
- func (ss Servers) RenderContainerLinuxConfig(cfg Config, w io.Writer) error
- func (ss Servers) RenderIgnitionConfig(cfg Config, w io.Writer) error
- func (ss Servers) RescueModeOptions() error
- func (ss Servers) RescueModePassword() error
- func (ss Servers) RescueModeStatus() error
- func (ss Servers) ResetKubeadm() error
- func (ss Servers) RestartService(svc string) error
- func (ss Servers) SSHConfig(w io.Writer, disableHostkeyChecking bool) error
- func (ss Servers) SSHKeyscan(w io.Writer) error
- func (ss Servers) SelectBackupMasters() Servers
- func (ss Servers) SelectMasters() Servers
- func (ss Servers) SelectPrimaryMasters() Servers
- func (ss Servers) SelectWorkers() Servers
- func (ss Servers) SetupFlatcar(cfg Config) error
- func (ss Servers) SetupKubeadm(cfg Config, verbose bool, helmfileSyncTries int) error
- func (ss Servers) Uncordon(master Server) error
- func (ss Servers) UptimeStatus() error
- type Services
- type User
Constants ¶
const ( // PrimaryMaster is the node used to initilize and manage the cluster. PrimaryMaster = NodeRole("primary master") // BackupMaster nodes are equal to the PrimaryMaster to achieve high availability. BackupMaster = NodeRole("backup master") // Worker nodes scale the actual cluster. Worker = NodeRole("worker") // SelectAllNodes is the selector for all nodes. SelectAllNodes = "*" )
const ( // RebootKured reboots the node via kured. RebootKured = Reboot("kured") // RebootKured reboots the node via kured directly. RebootKuredRealTime = Reboot("kured-real-time") // RebootHardware reboots the node via hetzner robot API resetting the hardware. RebootHardware = Reboot(robot.RebootHardware) // RebootHardwareUngraceful reboots the node via hetzner robot API resetting the hardware without syncing the disk. RebootHardwareUngraceful = Reboot(robot.RebootHardware + "-no-sync") // RebootManually reboots the node via hetzner robot API sending a technician. RebootManually = Reboot(robot.RebootManually) // RebootRescueSystem reboots the node in rescue mode via 'reboot' command. RebootRescueSystem = Reboot("rescue-system") // RebootSystem reboots the node via 'reboot' command. RebootSystem = Reboot("system") KuredRebootSentinel = "/var/run/update_engine_autoupdate_completed" KuredRebootSentinelRealTime = "/tmp/kured-reboot-required" )
const ( // renovate: datasource=github-tags depName=containernetworking/plugins CNI_VERSION = "v1.4.0" // renovate: datasource=github-tags depName=kubernetes/kubernetes KUBERNETES_VERSION = "v1.28.4" // renovate: datasource=github-tags depName=kubernetes/release RELEASE_VERSION = "v0.16.4" // renovate: datasource=github-tags depName=helm/helm HELM_VERSION = "v3.13.2" // renovate: datasource=github-tags depName=helmfile/helmfile HELMFILE_VERSION = "v0.159.0" // renovate: datasource=github-tags depName=kubernetes-sigs/kustomize KUSTOMIZE_VERSION = "5.3.0" // renovate: datasource=github-tags depName=vmware-tanzu/sonobuoy SONOBUOY_VERSION = "v0.57.1" // renovate: datasource=github-tags depName=kubernetes-sigs/cri-tools CRICTL_VERSION = "v1.28.0" // renovate: datasource=github-tags depName=vmware-tanzu/velero VELERO_VERSION = "v1.12.2" // renovate: datasource=github-tags depName=kubevirt/kubevirt VIRTCTL_VERSION = "v1.1.0" // renovate: datasource=github-tags depName=utopia-planitia/k8status K8STATUS_VERSION = "v0.1.8" )
const (
HELM_RETRIES = 3
)
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
func ConfigPath() string
func Dependencies ¶
Dependencies prints out the dependencies in dot format. The dependencies are defined per service in dependencies.dot.
func PrintConfig ¶
PrintConfig prints the default config template.
func PrintConfigTemplate ¶
PrintConfigTemplate prints the default config template.
func RenderContainerLinuxConfigTemplate ¶
RenderContainerLinuxConfigTemplate prints the container linux (core os) config template.
Types ¶
type Config ¶
type Config struct { SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"` DNSServers []string `yaml:"dns_servers"` NTPServers []string `yaml:"ntp_servers"` VSwitch struct { ID int } Rescue struct { OS string Arch string } Disks struct { OS string Data string } Flatcar struct { InstallScriptUrl string `yaml:"install_script_url"` Version string DisableUpdates bool `yaml:"disable_updates"` UpdateURL string `yaml:"update_url"` BaseURL string `yaml:"base_url"` AppID string `yaml:"app_id"` Group string SignKey struct { URL string `yaml:"url"` SHA256 string `yaml:"sha256"` } `yaml:"sign_key"` } Cloudflare struct { Key string Email string Zone string Subdomains struct { API string HTTP string } } DockerHub struct { Username string Password string DisableViaDns bool `yaml:"disable_via_dns"` } RegistryMirror struct { Endpoint string Username string Password string } RegistryMirrorV2 struct { Host string Path string PathWithV2 string `yaml:"path_with_v2"` Username string Password string } `yaml:"registry_mirror_v2"` Hardware struct { Disk1 string Disk2 string DiskType string `yaml:"diskType"` } Cluster struct { Name string Domain string Password string BasicAuth string `yaml:"basic_auth"` MasterNodeCount int `yaml:"master_node_count"` PodsPerNode int `yaml:"pods_per_node"` } Services Services Users []User Nodes Servers }
Config contains all configurations.
func LoadConfig ¶
LoadConfig load the config from the reader.
func (Config) ApiserverMemory ¶
ApiserverMemory calculates the target memory use for the API Server.
func (Config) KubernetesVersion ¶
KubernetesVersion returns the version of Kubernetes.
func (Config) SanityCheck ¶
SanityCheck verifies the config does not contain obvious errors.
type ContainerLinuxConfig ¶
ContainerLinuxConfig renders the container linux config template.
type JoinConfiguration ¶
JoinConfiguration renders the join config for kubeadm.
type NodeConfig ¶
NodeConfig renders the container linux config template.
type Patches ¶
type Patches struct { Etcd struct { Request struct { CPU string Memory string } Limit struct { CPU string Memory string } } APIServer struct { Request struct { CPU string Memory string } Limit struct { CPU string Memory string } } ControllerManager struct { Request struct { CPU string Memory string } Limit struct { CPU string Memory string } } Scheduler struct { Request struct { CPU string Memory string } Limit struct { CPU string Memory string } } }
Patches represents the changes applied to etcd, apiserver, controller-manager, and scheduler.
type Server ¶
type Server struct { Name string Hetzner struct { Username string Password string } Role NodeRole Network struct { IPv6 string PublicIP string `yaml:"public_ip"` Gateway string PrivateIP string `yaml:"private_ip"` MAC string DeviceName string `yaml:"device_name"` } }
Server represents a node of the cluster.
func (Server) AnnotateNodes ¶
AnnotateNodes adds annotations to the nodes.
func (Server) ApplyServices ¶
func (Server) ApplyTpl ¶
ApplyTpl applies rendered manifests to the setup. Yaml strings are used as templates and rendered before being applied.
func (Server) BootRescueMode ¶
BootRescueMode reboots into rescue mode and installs SSH keys.
func (Server) ConfigureFlatcar ¶
IgnitionConfigUpdate updates the ignition config, marks the config to be recompressed, and triggers a reboot via kured.
func (Server) ConfigureSSHKeys ¶
ConfigureSSHKeys prepares node to be accessible via ssh.
func (Server) CreateUsers ¶
CreateUsers creates and enabled/disables cluster role bindings.
func (Server) DeployServices ¶
func (Server) FinalizeMaintenance ¶
FinalizeMaintenance is a hook to end maintenance.
func (Server) InitCluster ¶
InitCluster creates a new cluster on the node. The node becomes the first master node.
func (Server) InstallFlatcar ¶
InstallFlatcar executes the official flatcar os installer to install flatcar. The installer is downloaded and the rendered igition config is uploaded as a preparation.
func (Server) KubeConfig ¶
KubeConfig prints the admin kube config generated by kubeadm.
func (Server) KubernetesStatus ¶
KubernetesStatus prints the status of kubernetes.
func (Server) KuredStatus ¶
KuredStatus prints kured status.
func (Server) NodesStatus ¶
NodesStatus prints the node status known to kubernetes.
func (Server) PatchAPIService ¶
PatchAPIService avoids connection drops via session stickiness.
func (Server) PrepareMaintenance ¶
PrepareMaintenance is a hook to begin maintenance.
func (Server) RebootToSSH ¶
RebootToSSH triggers a reboots and waits until port 22 (ssh) opened.
func (Server) RenderContainerLinuxConfig ¶
RenderContainerLinuxConfig prints the container linux (core os) config.
func (Server) RenderIgnitionConfig ¶
RenderIgnitionConfig prints the ignition config.
func (Server) ResetKubeadm ¶
ResetKubeadm uses kubeadm to reset kubernetes.
func (Server) RestartService ¶
RestartService restarts the given services by calling systemctl.
func (Server) SetupAddons ¶
func (Server) SetupFlatcar ¶
SetupFlatcar installs flatcar os.
func (Server) TestServices ¶
type Servers ¶
type Servers []Server
Servers represents the nodes of the cluster.
func (Servers) BootRescueMode ¶
BootRescueMode reboots all nodes into rescue mode.
func (Servers) ConfigureFlatcar ¶
ConfigureFlatcar updates each node by rerunning ignition.
func (Servers) ConfigureSSHKeys ¶
ConfigureSSHKeys prepares all nodes to be accessible via ssh.
func (Servers) DeleteDataDisk ¶
DeleteDataDisk empties the data disk on all nodes.
func (Servers) DisableFirewall ¶
DisableFirewall disables the firewall of each node.
func (Servers) DisableRescueMode ¶
DisableRescueMode disable the rescue mode of each node.
func (Servers) EnableFirewall ¶
EnableFirewall enables the firewall of each node.
func (Servers) EnableRescueMode ¶
EnableRescueMode enables the rescue mode of each node.
func (Servers) EtcHosts ¶
EtcHosts prints the /etc/hosts entries to access the nodes without dns entries.
func (Servers) FirewallStatus ¶
FirewallStatus prints the firewall status of each node.
func (Servers) InstallFlatcar ¶
InstallFlatcar installs flatcar os on each node using the official installer.
func (Servers) JoinMasters ¶
JoinMasters joins the nodes as a masters to the cluster.
func (Servers) JoinWorker ¶
JoinWorker joins the node as a worker to the cluster.
func (Servers) KubeadmUpdate ¶
KubeadmUpdate updates the clusters following the instructions at https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/
func (Servers) KuredStatus ¶
KuredStatus prints kured status for each server.
func (Servers) NonePrimaryMaster ¶
NonePrimaryMaster selects backups master and worker nodes.
func (Servers) PrimaryMaster ¶
PrimaryMaster returns the primary master.
func (Servers) RebootHardware ¶
func (Servers) RebootHardwareUngraceful ¶
func (Servers) RebootKured ¶
func (Servers) RebootKuredRealTime ¶
func (Servers) RebootManually ¶
func (Servers) RebootRescueSystem ¶
func (Servers) RebootSystem ¶
func (Servers) RebootToSSH ¶
RebootToSSH reboots all nodes and waits until port 22 (ssh) opened.
func (Servers) RenderContainerLinuxConfig ¶
RenderContainerLinuxConfig prints the container linux (core os) config for each node.
func (Servers) RenderIgnitionConfig ¶
RenderIgnitionConfig prints the ignition config for each node.
func (Servers) RescueModeOptions ¶
RescueModeStatus prints the rescue mode status of each node.
func (Servers) RescueModePassword ¶
RescueModePassword prints the rescue mode password of each node.
func (Servers) RescueModeStatus ¶
RescueModeStatus prints the rescue mode status of each node.
func (Servers) ResetKubeadm ¶
ResetKubeadm uses kubeadm to reset kubernetes on each node.
func (Servers) RestartService ¶
RestartService restarts the given services on each node.
func (Servers) SSHConfig ¶
SSHConfig prints the ssh config to access the nodes via ssh. The content is meant to be placed in ~/.ssh/config.
func (Servers) SSHKeyscan ¶
SSHKeyscan prints the command to scan ssh fingerprints for each node.
func (Servers) SelectBackupMasters ¶
SelectBackupMasters selects the backup master nodes.
func (Servers) SelectMasters ¶
SelectMasters selects the master nodes.
func (Servers) SelectPrimaryMasters ¶
SelectPrimaryMasters selects the backup master nodes.
func (Servers) SelectWorkers ¶
SelectWorkers selects the worker nodes.
func (Servers) SetupFlatcar ¶
SetupFlatcar installs the operating system on all nodes.
func (Servers) SetupKubeadm ¶
SetupKubeadm installs kubernetes on the nodes. First the primary master is created, then the addons are installed, the backup masters join serially, and then the worker nodes join.
func (Servers) UptimeStatus ¶
UptimeStatus prints the uptime for each server.
type Services ¶
type Services struct { Minio struct { AccessKey string `yaml:"access_key"` SecretKey string `yaml:"secret_key"` Backup struct { Cron string Enabled bool Host string AccessKey string `yaml:"access_key"` SecretKey string `yaml:"secret_key"` Directory string } } Cassandra struct { Backups []struct { Keyspace string Cron string Enabled bool } } Kured struct { RebootSentinel string `yaml:"reboot_sentinel"` StartTime string `yaml:"start_time"` EndTime string `yaml:"end_time"` Period string `yaml:"period"` } Registry struct { ServiceIP string `yaml:"service_ip"` Secret string } }
Services configures the services via templates in .yaml.tpl files.