kubeadm

package
v0.0.0-...-435808f Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package kubeadm contains all the logic for creating kubeadm config and the kubeadm config patches to be used during cluster creation.

Having direct control on kubeadm config is a specific necessity for kinder, because create nodes supports different CRI while kind supports only containerd; additionally, in kinder all the actions for setting up a working cluster can happen at different time while in kind everything - from create to a working K8s cluster - happens within an atomic operation, create.

Another difference from kind, is that kinder support skew from kubeadm version and K8s version, and as a consequence it was necessary to ensure that the code in this package is dependent on the kubeadm version installed on nodes.

Nevertheless, the core config used by kinder is a fork from "sigs.k8s.io/kind/pkg/cluster/internal/kubeadm"; all the kinder specific settings are applied as kustomize patches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(toPatch string, patches []string, patches6902 []PatchJSON6902) (string, error)

Build takes a Kubernetes object YAML document stream to patch, merge patches, and JSON 6902 patches.

It returns a patched YAML document stream.

Matching is performed on Kubernetes style v1 TypeMeta fields (kind and apiVersion), between the YAML documents and the patches.

Patches match if their kind and apiVersion match a document, with the exception that if the patch does not set apiVersion it will be ignored.

func Config

func Config(kubeadmConfigVersion string, data ConfigData) (config string, err error)

Config returns a kubeadm config generated using the config API version and with the customizable settings based on data

func GetAutomaticCopyCertsPatches

func GetAutomaticCopyCertsPatches(kubeadmConfigVersion string) ([]string, error)

GetAutomaticCopyCertsPatches returns the kubeadm config patch that will instruct kubeadm to use a well known certificate key for init/join.

func GetDockerPatch

func GetDockerPatch(kubeadmConfigVersion string, ControlPlane bool) ([]string, error)

GetDockerPatch returns the kubeadm config patch that will instruct kubeadm to setup user docker CRI defaults.

func GetExternalEtcdPatch

func GetExternalEtcdPatch(kubeadmConfigVersion string, etcdIP string) (string, error)

GetExternalEtcdPatch returns the kubeadm config patch that will instruct kubeadm to use external etcd.

func GetFileDiscoveryPatch

func GetFileDiscoveryPatch(kubeadmConfigVersion string) (string, error)

GetFileDiscoveryPatch returns the kubeadm config patch that will instruct kubeadm to use FileDiscovery.

func GetKubeadmConfigVersion

func GetKubeadmConfigVersion(kubeadmVersion *K8sVersion.Version) string

GetKubeadmConfigVersion returns the kubeadm config version corresponding to a Kubernetes kubeadmVersion

func GetPatchesDirectoryPatches

func GetPatchesDirectoryPatches(kubeadmConfigVersion string) ([]string, error)

GetPatchesDirectoryPatches returns the kubeadm config patches that will instruct kubeadm to use patches directory.

func GetTLSBootstrapPatch

func GetTLSBootstrapPatch(kubeadmConfigVersion string) (string, error)

GetTLSBootstrapPatch returns the kubeadm config patch that will instruct kubeadm to use a TLSBootstrap token. NB. for sake of semplicity, we are using the same Token already used for Token discovery

Types

type ConfigData

type ConfigData struct {
	ClusterName       string
	KubernetesVersion string
	// The ControlPlaneEndpoint, that is the address of the external loadbalancer
	// if defined or the bootstrap node
	ControlPlaneEndpoint string
	// The Local API Server port
	APIBindPort int
	// The API server external listen IP (which we will port forward)
	APIServerAddress string
	// ControlPlane flag specifies the node belongs to the control plane
	ControlPlane bool
	// The main IP address of the node
	NodeAddress string
	// The Token for TLS bootstrap
	Token string
	// The subnet used for pods
	PodSubnet string
	// The subnet used for services
	ServiceSubnet string
	// IPv4 values take precedence over IPv6 by default, if true set IPv6 default values
	IPv6 bool
	// The kubeadm feature-gate
	FeatureGateName  string
	FeatureGateValue string
	// DerivedConfigData is populated by Derive()
	// These auto-generated fields are available to Config templates,
	// but not meant to be set by hand
	DerivedConfigData
}

ConfigData is supplied to the kubeadm config template, with values populated by the cluster package

func (*ConfigData) Derive

func (c *ConfigData) Derive()

Derive automatically derives DockerStableTag if not specified

type DerivedConfigData

type DerivedConfigData struct {
	// DockerStableTag is automatically derived from KubernetesVersion
	DockerStableTag string
}

DerivedConfigData fields are automatically derived by ConfigData.Derive if they are not specified / zero valued

type PatchJSON6902

type PatchJSON6902 struct {
	// these fields specify the patch target resource
	Group   string `json:"group"`
	Version string `json:"version"`
	Kind    string `json:"kind"`
	// Patch should contain the contents of the json patch as a string
	Patch string `json:"patch"`
}

PatchJSON6902 represents an inline kustomize json 6902 patch https://tools.ietf.org/html/rfc6902

func GetRemoveTokenPatch

func GetRemoveTokenPatch(kubeadmConfigVersion string) (PatchJSON6902, error)

GetRemoveTokenPatch returns the kubeadm config patch that will instruct kubeadm to not uses token discovery.

Jump to

Keyboard shortcuts

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