Documentation
¶
Index ¶
- Constants
- Variables
- func GetCurrentOSInfo() (string, string, error)
- type App
- func (a *App) AddonInStore(name, reference, osVersion string) bool
- func (a *App) Bootstrap() error
- func (a *App) EnableDockerCleanupUnit(conn *dbus.Conn) error
- func (a *App) FetchAddon(loc *Location) (string, error)
- func (a *App) GatherState(localOnly bool, envPath string) error
- func (a *App) GetKubeVersion(localOnly bool, envPath string) (string, error)
- func (a *App) GetNextOSVersion() error
- func (a *App) GetPackageManifest(osVersion string) (*PackageManifest, error)
- func (a *App) GetVersionManifest(localOnly bool) (*VersionManifest, error)
- func (a *App) InstallAddon(name string, reference string, osVersions []string) error
- func (a *App) OSUpdate() error
- func (a *App) PickVersion(packageName string, packageVersions []string) (string, []string, error)
- func (a *App) TorcxGC(minOSVersion string) error
- func (a *App) UpdateHook() error
- func (a *App) UseAddon(name string, reference string) error
- func (a *App) VersionFor(localOnly bool, name, k8sVersion string) ([]string, error)
- func (a *App) WriteKubeletEnv(destPath string, k8sVersion string) error
- func (a *App) WriteNodeAnnotation() error
- type Config
- type Dep
- type Location
- type Package
- type PackageManifest
- type PackageVersion
- type VersionManifest
Constants ¶
const ( // StoreTemplate is the URL template for the default ContainerLinux torcx store ManifestURLTemplate = "https://tectonic-torcx.release.core-os.net/manifests/{{.Board}}/{{.OSVersion}}/torcx_manifest.json" KIND_PACKAGE_MANIFEST = "torcx-package-list-v0" )
const ( // CluoRuntimeMappings is the default path for hook runtime-mappings (tectonic-cluo ConfigMap) CluoRuntimeMappings = "/etc/runtime-mappings.yaml" // InstallerRuntimeMappings is the default path for bootstrapper runtime-mappings (installer file) InstallerRuntimeMappings = "/etc/kubernetes/installer/runtime-mappings.yaml" )
const MinimumRemoteDocker = "1520.3.0"
MinimumRemoteDocker is the first CL bucket with published docker addons
const (
// OsReleaseFile contains the default path to the os-release file
OsReleaseFile = "/usr/lib/os-release"
)
const TORCX_STORE = "/var/lib/torcx/store"
Variables ¶
var NoVersionError = errors.New("No suitable version available")
This error is returned when there is no suitable package available to install.
Functions ¶
func GetCurrentOSInfo ¶
GetCurrentOSInfo gets the current OS version and the board
Types ¶
type App ¶
type App struct { Conf Config // The CL "board" Board string CurrentOSVersion string NextOSVersion string K8sVersion string // Preferred docker versions DockerVersions []string // Whether a node reboot is required to finalize a docker upgrade. DockerRequiresReboot bool // Whether a node reboot is required to finalize an OS upgrade. OSRequiresReboot bool // contains filtered or unexported fields }
App contains all the runtime state in a single, mutable place.
func (*App) AddonInStore ¶
AddonInStore returns true if the referenced addon is already in the store
func (*App) Bootstrap ¶
Bootstrap runs the steps necessary for bootstrapping a new node: - do an OS upgrade - install torcx packages - write kubelet.env - (if required) reboot the system
func (*App) EnableDockerCleanupUnit ¶
EnableDockerCleanupUnit install a systemd service which purges docker datadir before reboot.
func (*App) FetchAddon ¶
FetchAddon fetches and verifies a torcx addon. It returns the path to the downloaded file if successful, or error
func (*App) GatherState ¶
GatherState collects the common system state - this has no side effects
func (*App) GetKubeVersion ¶
GetKubeVersion retrieves kubernetes version querying several sources:
- a custom/forced version string
- GitVersion of the remote API-server `/version` (if localOnly is false)
- hyperkube version (container tag) from envPath
func (*App) GetNextOSVersion ¶
NextOSVersion gets the coming OS version from update_engine without changing anything.
func (*App) GetPackageManifest ¶
func (a *App) GetPackageManifest(osVersion string) (*PackageManifest, error)
LocationFor determines the optimal location for a desired torcx package, given a specific docker version. It downloads and verifies the package manifest for a given OS version, caching the parsed manifest for reuse.
func (*App) GetVersionManifest ¶
func (a *App) GetVersionManifest(localOnly bool) (*VersionManifest, error)
GetVersionManifest parses the version manifest file supplied by the user.
func (*App) InstallAddon ¶
InstallAddon fetches, verify and store an addon image
func (*App) PickVersion ¶
PickVersion implements our version selection & fallback logic Returns the desired package version and the OS versions for which to install it. Returns NoVersionError if no suitable versions are available. May also return a nil result if nothing should be installed (i.e. the OS version is too old for Torcx)
Our update strategy is simple: we get a list of preferred packageVersions (in other words, the list of docker versions supported by Kubernetes). Then, pick the first one that is in the manifest for the "coming" OS version.
func (*App) TorcxGC ¶
TorcxGC removes versioned stores that we know we won't need. All versioned stores older than a given version are removed.
func (*App) UpdateHook ¶
UpdateHook runs the steps expected for a pre-reboot hook - Install torcx package - gc if possible - write "hook successful" annotation
func (*App) UseAddon ¶
UseAddon selects the addon for installation on next boot. When run on a fresh machine, this will create a profile of our choosing, otherwise will use the already-enabled version.
func (*App) VersionFor ¶
VersionFor parses the version manifest file and returns the list of preferred package versions for a given k8s version. The returned value will never be empty if error is nil.
func (*App) WriteKubeletEnv ¶
WriteKubeletEnv writes the `kubelet.env` file
func (*App) WriteNodeAnnotation ¶
WriteNodeAnnotation writes the special annotation that indicates completion of the tool.
type Config ¶
type Config struct { // Path to the torcx binary TorcxBin string // Templated URL to torcx package manifest TorcxManifestURL *template.Template // The torcx profile name to create (if no others exist) ProfileName string // Path to the kubeconfig file Kubeconfig string // Path to the kubelet.env file that configures the kubelet service KubeletEnvPath string // Don't use the apiserver to determine k8s version, just use this ForceKubeVersion string // If true, do an OS upgrade before proceeding OSUpgrade bool // If false (default), gpg-verify all fetched images NoVerifySig bool // The path to the gpg keyring to validate GpgKeyringPath string // The node annotation to set to indicate completion // This also causes the process to never exit WriteNodeAnnotation string // Our kubernetes node name NodeName string // The path to the version manifest VersionManifestPath string // Whether to skip torcx setup entirely SkipTorcxSetup bool // contains filtered or unexported fields }
type Location ¶
type Location struct { Version *PackageVersion Path string `json:"path"` URL string `json:"url"` }
type Package ¶
type Package struct { Name string `json:"name"` DefaultVersion string `json:"DefaultVersion"` Versions []PackageVersion `json:"versions"` }
type PackageManifest ¶
type PackageManifest struct {
Packages []Package `json:"packages"`
}
func (*PackageManifest) LocationFor ¶
func (m *PackageManifest) LocationFor(name, version string) (*Location, error)
LocationFor picks the best location for a given package + version from a manifest. If the package or version doesn't exist, returns nil. When multiple locations are present, it prefers ones with a Path on disk, so fetching can be skipped.
type PackageVersion ¶
type PackageVersion struct { Package *Package Version string `json:"version"` Hash string `json:"hash"` Locations []Location `json:"locations"` }
func (*PackageVersion) ValidateHash ¶
func (v *PackageVersion) ValidateHash(inp io.Reader) (bool, error)
ValidateHash checks if the supplied reader matches the package's expected hash.
type VersionManifest ¶
func (*VersionManifest) VersionFor ¶
func (m *VersionManifest) VersionFor(haveName, haveVersion, wantName string) ([]string, error)
VersionFor is the actual version lookup logic.