ignition

package
v0.0.0-...-0e2c39a Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: UPL-1.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Country = "US"
	Org     = "OCNE"
	OrgUnit = "OCNE"
	State   = "TX"

	InitConfigAPIVersion = "kubeadm.k8s.io/v1beta3"
	InitConfigKind       = "InitConfiguration"
	JoinConfigAPIVersion = "kubeadm.k8s.io/v1beta3"
	JoinConfigKind       = "JoinConfiguration"
	KubeadmFilePath      = "/etc/kubernetes/kubeadm.conf"
	CaCrtFilePath        = "/etc/kubernetes/pki/ca.crt"
	CaKeyFilePath        = "/etc/kubernetes/pki/ca.key"
	VolumePluginDir      = "/var/lib/kubelet/volumeplugins"

	KubeProxyMode = "iptables"
	ActionInit    = "init"
	ActionJoin    = "join"

	KubeletServiceName = "kubelet.service"
	CrioServiceName    = "crio.service"
	IscsidServiceName  = "iscsid.service"

	// Note that OcneServiceCommonBootstrapPatthen has and seemingly
	// pointless endline.  That endline is actually very important.
	// There is a bug in the coreos/go-systemd library used by ignition
	// that is not capable of handling unit files that do not with with
	// and endline.  It counts all such lines as "too long".
	//
	// Please refer to this: https://github.com/coreos/go-systemd/blob/v22.5.0/unit/deserialize.go#L153
	OcneServiceName                   = "ocne.service"
	OcneServiceCommonBootstrapPattern = `[Service]
Environment=ACTION={{.Action}}
Environment=NET_INTERFACE={{.NetInterface}}
`

	OcneUpdateServiceName = "ocne-update.service"
	OcneUpdateConfigPath  = "/etc/ocne/update.yaml"
	OcneUpdateYamlPattern = `registry: %s
tag: %s
transport: %s
`

	// Populating core configuration files, such as crio.conf and the
	// kubeadm init/join files have been moved to the "files" section
	// of ignition.  The script baked in to the OS image are not aware
	// of this and continue to assume that it needs to generate them.
	// Until the OS image is updated, overwrite that script with this
	// simper one.
	OcneSh = `` /* 1498-byte string literal not displayed */

	ContainerRegistryPath    = "/etc/containers/registries.conf"
	ContainerRegistryPattern = `unqualified-search-registries = ["{{.}}"]
`

	NetworkScriptPattern = `` /* 437-byte string literal not displayed */

	ProxyDropinPattern = `` /* 289-byte string literal not displayed */

)
View Source
const (
	IgnitionVersion = "3.4.0"
)
View Source
const (
	KeepAlivedConfigTemplatePath = "/etc/ocne/keepalived.conf.tmpl"
)

Variables

This section is empty.

Functions

func AddFile

func AddFile(ign *igntypes.Config, f *File) error

AddFile adds a file with the correct variables set, and also checks for any conflicts that may have occurred.

func AddGroup

func AddGroup(ign *igntypes.Config, g *Group) error

AddGroup adds a group with the correct variables set, and also checks for any conflicts that may have occurred.

func AddUnit

func AddUnit(ign *igntypes.Config, unit *igntypes.Unit) *igntypes.Config

AddUnit adds a unit to an existing ignition config.

func AddUser

func AddUser(ign *igntypes.Config, u *User) error

AddUser adds a user with the correct variables set, and also checks for any conflicts that may have occurred.

func ContainerConfiguration

func ContainerConfiguration(registry string) (*igntypes.Config, error)

func FromBytes

func FromBytes(in []byte) (*igntypes.Config, error)

FromBytes generates an ignition structure from a string. Both ignition and butane formats are accepted.

func FromPath

func FromPath(path string) (*igntypes.Config, error)

FromPath generates an ignition structure from a path. If the path is a directory, it merges together all valid ignition files in the directory. If it is a file, it uses just the file.

func FromString

func FromString(in string) (*igntypes.Config, error)

FromString generates an ignition structure from a string. Both ignition and butane formats are accepted.

func GenerateClusterConfigurationYaml

func GenerateClusterConfigurationYaml(ci *ClusterInit) (string, error)

func GenerateKubeProxyConfigurationYaml

func GenerateKubeProxyConfigurationYaml(proxyMode string) (string, error)

func GenerateKubeadmInitYaml

func GenerateKubeadmInitYaml(ci *ClusterInit) (string, error)

func GenerateKubeadmJoinYaml

func GenerateKubeadmJoinYaml(cj *ClusterJoin) (string, error)

func InitializeCluster

func InitializeCluster(ci *ClusterInit) (*igntypes.Config, error)

func JoinCluster

func JoinCluster(cj *ClusterJoin) (*igntypes.Config, error)

func MarshalIgnition

func MarshalIgnition(ign *igntypes.Config) ([]byte, error)

Marshal converts and ignition configuration to a byte array containing the json encoding of the configuration.

func Merge

Merge merges two ignition configuration

func NewIgnition

func NewIgnition() *igntypes.Config

NewIgnition initializes an Ingition with no settings.

func OcneUser

func OcneUser(sshKey string, sshKeyPath string, password string) (*igntypes.Config, error)

OcneUser adds the default user to the ignition configuration

func Proxy

func Proxy(inProxy *types.Proxy, noProxies ...string) (*igntypes.Config, error)

Proxy converts a proxy configuration into the correct set of ignition objects for any and all OCNE components and services.

Types

type ApiServer

type ApiServer struct {
	CertSans  []string           `yaml:"certSANs,omitempty"`
	ExtraArgs ApiServerExtraArgs `yaml:"extraArgs,omitempty"`
}

type ApiServerExtraArgs

type ApiServerExtraArgs struct {
	TLSMinVersion   string `yaml:"tls-min-version,omitempty"`
	TLSCipherSuites string `yaml:"tls-cipher-suites,omitempty"`
}

type BootstrapTokenDiscovery

type BootstrapTokenDiscovery struct {
	ApiServerEndpoint string   `yaml:"apiServerEndpoint,omitempty"`
	Token             string   `yaml:"token"`
	CACertHashes      []string `yaml:"caCertHashes,omitempty"`
}

type ClusterConfig

type ClusterConfig struct {
	ApiVersion           string            `yaml:"apiVersion"`
	Kind                 string            `yaml:"kind"`
	ApiServer            ApiServer         `yaml:"apiServer,omitempty"`
	ControllerManager    ControllerManager `yaml:"controllerManager,omitempty"`
	Scheduler            Scheduler         `yaml:"scheduler,omitempty"`
	Networking           Networking        `yaml:"networking"`
	ImageRepository      string            `yaml:"imageRepository"`
	KubernetesVersion    string            `yaml:"kubernetesVersion"`
	ControlPlaneEndpoint string            `yaml:"controlPlaneEndpoint,omitempty"`
	Etcd                 Etcd              `yaml:"etcd"`
	DNS                  DNS               `yaml:"dns"`
}

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/control-plane-flags/ https://kubernetes.io/docs/reference/config-api/kubeadm-config.v1beta3/ https://kubernetes.io/docs/reference/config-api/kubeadm-config.v1beta3/#kubeadm-k8s-io-v1beta3-ControlPlaneComponent

func GenerateClusterConfiguration

func GenerateClusterConfiguration(ci *ClusterInit, kubeVersions versions.KubernetesVersions) *ClusterConfig

type ClusterInit

type ClusterInit struct {
	OsTag                string
	OsRegistry           string
	ImageRegistry        string
	KubeAPIServerIP      string
	KubeAPIBindPort      uint16
	KubeAPIBindPortAlt   uint16
	InternalLB           bool
	Proxy                types.Proxy
	KubeAPIExtraSans     []string
	KubePKICert          string
	KubePKIKey           string
	ServiceSubnet        string
	PodSubnet            string
	ExpectingWorkerNodes bool
	ProxyMode            string
	NetInterface         string
	UploadCertificateKey string
	KubeVersion          string
	TLSCipherSuites      string
}

type ClusterJoin

type ClusterJoin struct {
	Role                 clustertypes.NodeRole
	OsTag                string
	OsRegistry           string
	ImageRegistry        string
	KubeAPIServerIP      string
	JoinToken            string
	KubePKICertHashes    []string
	KubeAPIBindPort      uint16
	KubeAPIBindPortAlt   uint16
	InternalLB           bool
	Proxy                types.Proxy
	ProxyMode            string
	NetInterface         string
	UploadCertificateKey string
	TLSCipherSuites      string
}

type ControlPlane

type ControlPlane struct {
	LocalAPIEndPoint LocalAPIEndpoint `yaml:"localAPIEndpoint"`
	CertificateKey   string           `yaml:"certificateKey,omitempty"`
}

type ControllerManager

type ControllerManager struct {
	ExtraArgs ControllerManagerExtraArgs `yaml:"extraArgs,omitempty"`
}

type ControllerManagerExtraArgs

type ControllerManagerExtraArgs struct {
	TLSMinVersion   string `yaml:"tls-min-version,omitempty"`
	TLSCipherSuites string `yaml:"tls-cipher-suites,omitempty"`
	CloudProvider   string `yaml:"cloud-provider,omitempty"`
	BindAddress     string `yaml:"bind-address,omitempty"`
}

type CustomImage

type CustomImage struct {
	ImageRepository string `yaml:"imageRepository"`
	ImageTag        string `yaml:"imageTag"`
}

CustomImage defines the custom image and tag

type DNS

type DNS struct {
	CustomImage `yaml:",inline"`
}

DNS holds the configuration for the dns

type Discovery

type Discovery struct {
	BootstrapToken BootstrapTokenDiscovery `yaml:"bootstrapToken,omitempty"`
}

type Etcd

type Etcd struct {
	Local EtcdLocal `yaml:"local"`
}

Etcd represents the etcd object in the cluster config. This is used to modify the etcd image registy and tag

type EtcdExtraArgs

type EtcdExtraArgs struct {
	TLSCipherSuites           string `yaml:"cipher-suites,omitempty"`
	ListenClientURLs          string `yaml:"listen-client-urls,omitempty"`
	ListenPeerURLs            string `yaml:"listen-peer-urls,omitempty"`
	ListenMetricsURLs         string `yaml:"listen-metrics-urls,omitempty"`
	AdvertiseClientURLs       string `yaml:"advertise-client-urls,omitempty"`
	InitialAdvertisePeersURLs string `yaml:"initial-advertise-peer-urls,omitempty"`
}

type EtcdLocal

type EtcdLocal struct {
	CustomImage  `yaml:",inline"`
	ExtraArgs    EtcdExtraArgs `yaml:"extraArgs"`
	PeerCertSans []string      `yaml:"peerCertSANs"`
}

EtcdLocal defines configuration options for etcd to be used in a kubeadm config definition

type File

type File struct {
	Path       string       `json:"path"`
	Filesystem string       `json:"filesystem"`
	Mode       int          `json:"mode"`
	Contents   FileContents `json:"contents"`

	Overwrite bool ` json:"overwrite"`
	// contains filtered or unexported fields
}

type FileContents

type FileContents struct {
	Source string `json:"source"`
}

type Group

type Group struct {
	Name string `json:"name"`
}

type IgnitionData

type IgnitionData struct {
	Files []*File
	Units []*igntypes.Unit
}

func GenerateAssetsForVirtualIp

func GenerateAssetsForVirtualIp(bindPort uint16, altPort uint16, virtualIP string, proxy *types.Proxy, netInterface string) (*IgnitionData, error)

GenerateAssetsForVirtualIp generates file and systemd unit contents for configuring control plane HA using a virtual IP

type InitConfig

type InitConfig struct {
	ApiVersion       string           `yaml:"apiVersion"`
	Kind             string           `yaml:"kind"`
	LocalAPIEndpoint LocalAPIEndpoint `yaml:"localAPIEndpoint,omitempty"`
	NodeRegistration NodeRegistration `yaml:"nodeRegistration,omitempty"`
	CertificateKey   string           `yaml:"certificateKey,omitempty"`
}

func GenerateKubeadmInit

func GenerateKubeadmInit(ci *ClusterInit) *InitConfig

type JoinConfig

type JoinConfig struct {
	ApiVersion       string           `yaml:"apiVersion"`
	Kind             string           `yaml:"kind"`
	ControlPlane     ControlPlane     `yaml:"controlPlane,omitempty"`
	NodeRegistration NodeRegistration `yaml:"nodeRegistration,omitempty"`
	Discovery        Discovery        `yaml:"discovery,omitempty"`
}

func GenerateKubeadmJoin

func GenerateKubeadmJoin(cj *ClusterJoin) *JoinConfig

type KubeProxy

type KubeProxy struct {
	ApiVersion         string `yaml:"apiVersion"`
	Kind               string `yaml:"kind"`
	Mode               string `yaml:"mode"`
	MetricsBindAddress string `yaml:"metricsBindAddress"`
}

https://kubernetes.io/docs/reference/config-api/kube-proxy-config.v1alpha1/

func GenerateKubeProxyConfiguration

func GenerateKubeProxyConfiguration(proxyMode string) *KubeProxy

type KubeletExtraArgs

type KubeletExtraArgs struct {
	NodeIP            string `yaml:"node-ip,omitempty"`
	TLSMinVersion     string `yaml:"tls-min-version,omitempty"`
	TLSCipherSuites   string `yaml:"tls-cipher-suites,omitempty"`
	Address           string `yaml:"address,omitempty"`
	AuthorizationMode string `yaml:"authorization-mode,omitempty"`
	VolumePluginDir   string `yaml:"volume-plugin-dir,omitempty"`
}

type LocalAPIEndpoint

type LocalAPIEndpoint struct {
	AdvertiseAddress string `yaml:"advertiseAddress,omitempty"`
	BindPort         uint16 `yaml:"bindPort,omitempty"`
}

type NetworkScript

type NetworkScript struct {
	Name             string
	Type             string
	OnBoot           bool
	BrowserOnly      bool
	BootProto        string
	DefaultRoute     bool
	ProxyMode        string
	IPV4FailureFatal bool
	IPV6Init         bool
	IPV6Autoconf     bool
	IPV6DefaultRoute bool
	IPV6FailureFatal bool
	IPV6AddrGenMode  string
}

func DefaultNetwork

func DefaultNetwork() *NetworkScript

func (*NetworkScript) ToFile

func (n *NetworkScript) ToFile() (*File, error)

type Networking

type Networking struct {
	ServiceCIDR string `yaml:"serviceSubnet"`
	PodCIDR     string `yaml:"podSubnet"`
}

type NodeRegistration

type NodeRegistration struct {
	KubeletExtraArgs KubeletExtraArgs `yaml:"kubeletExtraArgs"`
	Taints           *[]string        `yaml:"taints"`
}

type SchedulerExtraArgs

type SchedulerExtraArgs struct {
	TLSMinVersion   string `yaml:"tls-min-version,omitempty"`
	TLSCipherSuites string `yaml:"tls-cipher-suites,omitempty"`
	BindAddress     string `yaml:"bind-address,omitempty"`
}

type User

type User struct {
	Name     string   `json:"name"`
	SshKey   string   `json:"sshKey"`
	Password string   `json:"password"`
	Groups   []string `json:"groups"`
	Shell    string   `json:"shell"`
}

Jump to

Keyboard shortcuts

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