internal

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
const MinimumRemoteDocker = "1520.3.0"

MinimumRemoteDocker is the first CL bucket with published docker addons

View Source
const (
	// OsReleaseFile contains the default path to the os-release file
	OsReleaseFile = "/usr/lib/os-release"
)
View Source
const TORCX_STORE = "/var/lib/torcx/store"

Variables

View Source
var NoVersionError = errors.New("No suitable version available")

This error is returned when there is no suitable package available to install.

Functions

func GetCurrentOSInfo

func GetCurrentOSInfo() (string, string, error)

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 NewApp

func NewApp(c Config) (*App, error)

func (*App) AddonInStore

func (a *App) AddonInStore(name, reference, osVersion string) bool

AddonInStore returns true if the referenced addon is already in the store

func (*App) Bootstrap

func (a *App) Bootstrap() error

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

func (a *App) EnableDockerCleanupUnit(conn *dbus.Conn) error

EnableDockerCleanupUnit install a systemd service which purges docker datadir before reboot.

func (*App) FetchAddon

func (a *App) FetchAddon(loc *Location) (string, error)

FetchAddon fetches and verifies a torcx addon. It returns the path to the downloaded file if successful, or error

func (*App) GatherState

func (a *App) GatherState(localOnly bool, envPath string) error

GatherState collects the common system state - this has no side effects

func (*App) GetKubeVersion

func (a *App) GetKubeVersion(localOnly bool, envPath string) (string, error)

GetKubeVersion retrieves kubernetes version querying several sources:

  1. a custom/forced version string
  2. GitVersion of the remote API-server `/version` (if localOnly is false)
  3. hyperkube version (container tag) from envPath

func (*App) GetNextOSVersion

func (a *App) GetNextOSVersion() error

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

func (a *App) InstallAddon(name string, reference string, osVersions []string) error

InstallAddon fetches, verify and store an addon image

func (*App) OSUpdate

func (a *App) OSUpdate() error

OSUpdate triggers the update engine to update and waits for it to finish

func (*App) PickVersion

func (a *App) PickVersion(packageName string, packageVersions []string) (string, []string, error)

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

func (a *App) TorcxGC(minOSVersion string) error

TorcxGC removes versioned stores that we know we won't need. All versioned stores older than a given version are removed.

func (*App) UpdateHook

func (a *App) UpdateHook() error

UpdateHook runs the steps expected for a pre-reboot hook - Install torcx package - gc if possible - write "hook successful" annotation

func (*App) UseAddon

func (a *App) UseAddon(name string, reference string) error

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

func (a *App) VersionFor(localOnly bool, name, k8sVersion string) ([]string, error)

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

func (a *App) WriteKubeletEnv(destPath string, k8sVersion string) error

WriteKubeletEnv writes the `kubelet.env` file

func (*App) WriteNodeAnnotation

func (a *App) WriteNodeAnnotation() error

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 Dep

type Dep map[string]map[string][]string

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

type VersionManifest struct {
	Kind     string         `yaml:"kind"`
	Versions map[string]Dep `yaml:"versions"`
}

func (*VersionManifest) VersionFor

func (m *VersionManifest) VersionFor(haveName, haveVersion, wantName string) ([]string, error)

VersionFor is the actual version lookup logic.

Jump to

Keyboard shortcuts

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