nodebootstrap

package
v0.193.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 7

README

Nodebootstrap

Until recently, eksctl provided its own bootstrapping/userdata logic on disk, over-writing or ignore those which came with the AMIs. This caused numerous headaches after changes upstream and we got tired of maintaining these extra pieces.

Implementation

For Unmanaged nodes there is an interface:

type Bootstrapper interface {
  UserData() (string, error)
}

AMI families Ubuntu, AmazonLinux2, Bottlerocket and Windows all fulfil this.

As of eksctl version 0.45.0 unmanaged nodes of these families, as well as managed nodes (different interface), will defer to the native bootstrap script which comes built into the image.

This script is found on disk at /etc/eks/bootstrap.sh. UserData will provide a wrapper script which will set custom values and delegate to the official bootstrap script.

Ubuntu & AmazonLinux2

The bootstrapping "prep" for these 2 are fairly similar. Common setup lives in userdata.go. Individual scripts are prepped in ubuntu.go and al2.go.

Non-dynamic assets live in assets/.

Both bootstrappers add assets/bootstrap.helper.sh to the node along with either assets/bootstrap.ubuntu.sh or assets/bootstrap.al2.sh.

The call to UserData will also dynamically add the following:

  • kubelet-extra.json - user configuration for kubelet
  • docker-extra.json - extra config for docker daemon
  • kubelet.env - env vars for kubelet

The bootstrap wrapper scripts will use jq and sed to get user and our config into various files, and then call /etc/eks/bootstrap.sh.

For AL2, enabling either SSM or EFA will add assets/install-ssm.al2.sh or assets/efa.al2.sh.

AmazonLinux2023

While AL2023 implements the Bootstrapper interface, the underlying userdata will be entirely different from other AMI families. Specifically, AL2023 introduces a new node initialization process nodeadm that uses a YAML configuration schema, dropping the use of /etc/eks/bootstrap.sh script. For self-managed nodes, and for EKS-managed nodes based on custom AMIs, eksctl will populate userdata in the fashion below:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=//

--//
Content-Type: application/node.eks.aws

apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
  cluster:
    apiServerEndpoint: https://XXXX.us-west-2.eks.amazonaws.com
    certificateAuthority: XXXX
    cidr: 10.100.0.0/16
    name: my-cluster
  kubelet:
    config:
      clusterDNS:
      - 10.100.0.10
    flags:
    - --node-labels=alpha.eksctl.io/cluster-name=my-cluster,alpha.eksctl.io/nodegroup-name=my-nodegroup
    - --register-with-taints=special=true:NoSchedule (only for EKS-managed nodes)

--//--

For EKS-managed nodes based on native AMIs, the userdata above is fulfilled automatically by the AWS SSM agent.

Troubleshooting

Ubuntu
sudo snap logs kubelet-eks [-n=all/20]
systemctl status docker.service

Files:

/etc/eks/bootstrap.sh
/var/lib/cloud/scripts/eksctl/bootstrap.ubuntu.sh
/etc/kubernetes/kubelet/kubelet-config.json
/etc/docker/daemon.json
AmazonLinux2

Status:

systemctl status kubelet
systemctl status docker

Logs:

journalctl -u kubelet.service

Files:

/etc/eks/bootstrap.sh
/var/lib/cloud/scripts/eksctl/bootstrap.al2.sh
/etc/kubernetes/kubelet/kubelet-config.json
/etc/docker/daemon.json
/var/lib/cloud/scripts/eksctl/efa.al2.sh
/var/lib/cloud/scripts/eksctl/install-ssm.sh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClusterDNS added in v0.55.0

func GetClusterDNS(clusterConfig *api.ClusterConfig) (string, error)

GetClusterDNS returns the DNS address to use

func ProtectTOMLKeys added in v0.47.0

func ProtectTOMLKeys(path []string, tree *toml.Tree)

ProtectTOMLKeys processes a tree finding and replacing dotted keys with quoted keys to retain the configured settings. This prevents TOML parsers from deserializing keys into nested key-value pairs at each dot encountered - which is not uncommon in the context of Kubernetes' labels, annotations, and taints.

func ToKubeletConfig added in v0.178.0

func ToKubeletConfig(kubeletExtraConfig api.InlineDocument) (map[string]runtime.RawExtension, error)

ToKubeletConfig generates a kubelet config that can be used with nodeadm.NodeConfig.

Types

type AL2023 added in v0.176.0

type AL2023 struct {
	UserDataMimeBoundary string
	// contains filtered or unexported fields
}

func NewAL2023Bootstrapper added in v0.176.0

func NewAL2023Bootstrapper(cfg *api.ClusterConfig, ng *api.NodeGroup, clusterDNS string) *AL2023

func NewManagedAL2023Bootstrapper added in v0.176.0

func NewManagedAL2023Bootstrapper(cfg *api.ClusterConfig, mng *api.ManagedNodeGroup, clusterDNS string) *AL2023

func (*AL2023) UserData added in v0.176.0

func (m *AL2023) UserData() (string, error)

type AmazonLinux2 added in v0.47.0

type AmazonLinux2 struct {
	// contains filtered or unexported fields
}

func NewAL2Bootstrapper added in v0.47.0

func NewAL2Bootstrapper(clusterConfig *api.ClusterConfig, ng *api.NodeGroup, clusterDNS string) *AmazonLinux2

func (*AmazonLinux2) UserData added in v0.47.0

func (b *AmazonLinux2) UserData() (string, error)

type Bootstrapper added in v0.47.0

type Bootstrapper interface {
	// UserData returns userdata for bootstrapping nodes
	UserData() (string, error)
}

func NewBootstrapper added in v0.47.0

func NewBootstrapper(clusterConfig *api.ClusterConfig, ng *api.NodeGroup) (Bootstrapper, error)

NewBootstrapper returns the correct bootstrapper for the AMI family

func NewManagedBootstrapper added in v0.53.0

func NewManagedBootstrapper(clusterConfig *api.ClusterConfig, ng *api.ManagedNodeGroup) (Bootstrapper, error)

NewManagedBootstrapper creates a new bootstrapper for managed nodegroups based on the AMI family

type Bottlerocket added in v0.47.0

type Bottlerocket struct {
	// contains filtered or unexported fields
}

func NewBottlerocketBootstrapper added in v0.47.0

func NewBottlerocketBootstrapper(clusterConfig *api.ClusterConfig, np api.NodePool) *Bottlerocket

func (*Bottlerocket) UserData added in v0.47.0

func (b *Bottlerocket) UserData() (string, error)

NewUserDataForBottlerocket generates TOML userdata for bootstrapping a Bottlerocket node.

type ManagedAL2 added in v0.53.0

type ManagedAL2 struct {

	// UserDataMimeBoundary sets the MIME boundary for user data
	UserDataMimeBoundary string
	// contains filtered or unexported fields
}

ManagedAL2 is a bootstrapper for managed Amazon Linux 2 nodegroups

func NewManagedAL2Bootstrapper added in v0.53.0

func NewManagedAL2Bootstrapper(ng *api.ManagedNodeGroup) *ManagedAL2

NewManagedAL2Bootstrapper creates a new ManagedAL2 bootstrapper

func (*ManagedAL2) UserData added in v0.53.0

func (m *ManagedAL2) UserData() (string, error)

UserData returns user data for AL2 managed nodegroups

type ManagedBottlerocket added in v0.72.0

type ManagedBottlerocket struct {
	// contains filtered or unexported fields
}

func NewManagedBottlerocketBootstrapper added in v0.72.0

func NewManagedBottlerocketBootstrapper(clusterConfig *api.ClusterConfig, ng *api.ManagedNodeGroup) *ManagedBottlerocket

NewManagedBottlerocketBootstrapper returns a new bootstrapper for managed Bottlerocket.

func (*ManagedBottlerocket) UserData added in v0.72.0

func (b *ManagedBottlerocket) UserData() (string, error)

UserData generates TOML userdata for bootstrapping a Bottlerocket node.

type ManagedWindows added in v0.124.0

type ManagedWindows struct {
	NodeGroup *api.ManagedNodeGroup
}

ManagedWindows implements a bootstrapper for managed Windows nodegroups.

func (*ManagedWindows) UserData added in v0.124.0

func (w *ManagedWindows) UserData() (string, error)

UserData returns the userdata.

type Ubuntu added in v0.47.0

type Ubuntu struct {
	// contains filtered or unexported fields
}

func NewUbuntuBootstrapper added in v0.47.0

func NewUbuntuBootstrapper(clusterConfig *api.ClusterConfig, np api.NodePool, clusterDNS string) *Ubuntu

func (*Ubuntu) UserData added in v0.47.0

func (b *Ubuntu) UserData() (string, error)

type Windows added in v0.47.0

type Windows struct {
	// contains filtered or unexported fields
}

func NewWindowsBootstrapper added in v0.47.0

func NewWindowsBootstrapper(clusterConfig *api.ClusterConfig, np api.NodePool, clusterDNS string) *Windows

func (*Windows) UserData added in v0.47.0

func (b *Windows) UserData() (string, error)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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