status

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: 17 Imported by: 0

Documentation

Overview

Package status allows to inspect and to represent the current status of a K8s cluster created with kind(er).

The current status of a K8s cluster defines the starting point for any kinder operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsKnown

func IsKnown(name string) (bool, error)

IsKnown returns true if a cluster exists with the given name. If obtaining the list of known clusters fails the function returns an error.

func KubeConfigPath

func KubeConfigPath(name string) string

KubeConfigPath returns the kubeconfig path for a cluster name

func ListClusters

func ListClusters() ([]string, error)

ListClusters is part of the providers.Provider interface

Types

type Cluster

type Cluster struct {
	Settings *ClusterSettings
	// contains filtered or unexported fields
}

Cluster represents an existing kind(er) clusters

func FromDocker

func FromDocker(name string) (c *Cluster, err error)

FromDocker returns a new cluster status created by discovering and inspecting existing containers nodes

func (*Cluster) AllNodes

func (c *Cluster) AllNodes() NodeList

AllNodes returns all the nodes in the cluster (including K8s nodes, external loadbalancer and external etcd)

func (*Cluster) BootstrapControlPlane

func (c *Cluster) BootstrapControlPlane() *Node

BootstrapControlPlane returns the first node with control-plane role. This is the node where kubeadm init will be executed.

func (*Cluster) ControlPlanes

func (c *Cluster) ControlPlanes() NodeList

ControlPlanes returns all the nodes with control-plane role

func (*Cluster) ExternalEtcd

func (c *Cluster) ExternalEtcd() *Node

ExternalEtcd returns the node with external-etcd role, if defined

func (*Cluster) ExternalLoadBalancer

func (c *Cluster) ExternalLoadBalancer() *Node

ExternalLoadBalancer returns the node with external-load-balancer role, if defined

func (*Cluster) K8sNodes

func (c *Cluster) K8sNodes() NodeList

K8sNodes returns all the nodes that hosts a Kubernetes nodes in the cluster (all nodes except external loadbalancer and external etcd)

func (*Cluster) KubeConfigPath

func (c *Cluster) KubeConfigPath() string

KubeConfigPath returns the path to where the Kubeconfig would be placed by kinder based on the configuration.

func (*Cluster) Name

func (c *Cluster) Name() string

Name returns the cluster's name

func (*Cluster) ReadSettings

func (c *Cluster) ReadSettings() (err error)

ReadSettings read cluster settings from a control plane node

func (*Cluster) ResolveNodesPath

func (c *Cluster) ResolveNodesPath(nodesPath string) (nodes NodeList, path string, err error)

ResolveNodesPath takes a "topology aware" path and resolve to one (or more) real paths.

Topology aware paths are in the form [selector:]path, where a selector is a shortcut for a node or a set of nodes in the cluster. See SelectNodes

func (*Cluster) SecondaryControlPlanes

func (c *Cluster) SecondaryControlPlanes() NodeList

SecondaryControlPlanes returns all the nodes with control-plane role except the BootstrapControlPlane node, if any,

func (*Cluster) SelectNodes

func (c *Cluster) SelectNodes(nodeSelector string) (nodes NodeList, err error)

SelectNodes returns Nodes according to the given selector. a selector is a shortcut for a node or a set of nodes in the cluster.

func (*Cluster) Validate

func (c *Cluster) Validate() error

Validate the cluster has a consistent set of nodes

func (*Cluster) Workers

func (c *Cluster) Workers() NodeList

Workers returns all the nodes with Worker role, if any

func (*Cluster) WriteSettings

func (c *Cluster) WriteSettings() error

WriteSettings writes cluster settings nodes

type ClusterIPFamily

type ClusterIPFamily string

ClusterIPFamily defines cluster network IP family

const (
	// IPv4Family sets ClusterIPFamily to ipv4
	IPv4Family ClusterIPFamily = "ipv4"
	// IPv6Family sets ClusterIPFamily to ipv6
	IPv6Family ClusterIPFamily = "ipv6"
)

type ClusterSettings

type ClusterSettings struct {
	// kind configuration settings that are used to configure the cluster when
	// generating the kubeadm config file.
	IPFamily ClusterIPFamily `json:"ipFamily,omitempty"`
}

ClusterSettings defines a set of settings that will be stored in the cluster and re-used by kinder during the cluster lifecycle.

Storing value in the cluster is a specific necessity for kinder, because create nodes and actions for setting up a working cluster can happen at different time (while in kind everything happen within an atomic operation)

type ContainerRuntime

type ContainerRuntime string

ContainerRuntime defines CRI runtime that are supported inside a kind(er) node

const (
	// DockerRuntime refers to the docker container runtime
	DockerRuntime ContainerRuntime = "docker"
	// ContainerdRuntime refers to the containerd container runtime
	ContainerdRuntime ContainerRuntime = "containerd"
)

func InspectCRIinContainer

func InspectCRIinContainer(id string) (ContainerRuntime, error)

InspectCRIinContainer inspect a running container and detects the installed container runtime NB. this method use raw kinddocker/kindexec commands because it is used also during "alter" and "create" (before an actual Cluster status exist)

func InspectCRIinImage

func InspectCRIinImage(image string) (ContainerRuntime, error)

InspectCRIinImage inspect an image and detects the installed container runtime

type Node

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

Node defines a K8s node running in a kinde(er) docker container or a container hosting one external dependency of the cluster, like etcd or the load balancer.

func NewNode

func NewNode(name string) (n *Node, err error)

NewNode returns a new kinder.Node wrapper

func (*Node) CRI

func (n *Node) CRI() (cri ContainerRuntime, err error)

CRI returns the ContainerRuntime installed on the node and that should be used by kubeadm for creating the K8s cluster

func (*Node) Command

func (n *Node) Command(command string, args ...string) *exec.NodeCmd

Command returns a ProxyCmd that allows to run commands on the node

func (*Node) CopyFrom

func (n *Node) CopyFrom(source, dest string) error

CopyFrom copies the source file on the node to dest on the host. Please note that this have limitations around symlinks.

func (*Node) CopyTo

func (n *Node) CopyTo(source, dest string) error

CopyTo copies the source file on the host to dest on the node

func (*Node) DryRun

func (n *Node) DryRun()

DryRun instruct the node to dry run all the commands that will be executed on this node. DryRun differs from SkipRun, because in case of DryRun kinder prints all the details for running the command manually.

func (*Node) EtcdImage

func (n *Node) EtcdImage() (string, error)

EtcdImage returns the etcdImage that should be used with the kubernetes version installed on this node

func (*Node) IP

func (n *Node) IP() (ipv4 string, ipv6 string, err error)

IP returns the IP address of the node

func (*Node) Infof

func (n *Node) Infof(message string, args ...interface{})

Infof print an information message in the same format of commands on the node; the message is print after the prompt containing the kind (er) node name.

func (*Node) IsControlPlane

func (n *Node) IsControlPlane() bool

IsControlPlane returns true if the node hosts a control plane instance NB. in single node clusters, control-plane nodes act also as a worker nodes

func (*Node) IsExternalEtcd

func (n *Node) IsExternalEtcd() bool

IsExternalEtcd returns true if the node hosts an external etcd member

func (*Node) IsExternalLoadBalancer

func (n *Node) IsExternalLoadBalancer() bool

IsExternalLoadBalancer returns true if the node hosts an external load balancer

func (*Node) IsWorker

func (n *Node) IsWorker() bool

IsWorker returns true if the node hosts a worker instance

func (*Node) KubeVersion

func (n *Node) KubeVersion() (version string, err error)

KubeVersion returns the Kubernetes version installed on the node

func (*Node) KubeadmVersion

func (n *Node) KubeadmVersion() (*K8sVersion.Version, error)

KubeadmVersion returns the kubeadm version installed on the node

func (*Node) MustKubeVersion

func (n *Node) MustKubeVersion() *K8sVersion.Version

MustKubeVersion returns the Kubernetes version installed on the node or panics if a valid Kubernetes version can't be identified.

func (*Node) MustKubeadmVersion

func (n *Node) MustKubeadmVersion() *K8sVersion.Version

MustKubeadmVersion returns the kubeadm version installed on the node or panics if a valid kubeadm version can't be identified.

func (*Node) Name

func (n *Node) Name() string

Name returns the name of the node

func (*Node) Ports

func (n *Node) Ports(containerPort int32) (hostPort int32, err error)

Ports returns a specific port mapping for the node Node by convention use well known ports internally, while random port are used for making the `kind` cluster accessible from the host machine

func (*Node) ReadClusterSettings

func (n *Node) ReadClusterSettings() (*ClusterSettings, error)

ReadClusterSettings reads from the node a set of cluster-wide settings that are going to be re-used by kinder during the cluster lifecycle (after create)

func (*Node) ReadNodeSettings

func (n *Node) ReadNodeSettings() (*NodeSettings, error)

ReadNodeSettings reads from the node specific settings that are going to be re-used by kinder during the cluster lifecycle (after create)

func (*Node) Role

func (n *Node) Role() string

Role returns the role of the node

func (*Node) SkipActions

func (n *Node) SkipActions()

SkipActions marks the node to be skipped during actions.

func (*Node) WriteClusterSettings

func (n *Node) WriteClusterSettings(settings *ClusterSettings) error

WriteClusterSettings stores in the node a set of cluster-wide settings that will be re-used by kinder during the cluster lifecycle (after create)

func (*Node) WriteFile

func (n *Node) WriteFile(containerPath string, contents []byte) error

WriteFile writes a temporary file with the given contents and copies the file to the node container

func (*Node) WriteNodeSettings

func (n *Node) WriteNodeSettings(settings *NodeSettings) error

WriteNodeSettings stores in the node specific settings that will be re-used by kinder during the cluster lifecycle (after create)

type NodeList

type NodeList []*Node

NodeList defines a list of Node

func (NodeList) EligibleForActions

func (l NodeList) EligibleForActions() NodeList

EligibleForActions returns the list of nodes without nodes marked as SkipAction

func (NodeList) Sort

func (l NodeList) Sort()

Sort the list of Node wrapper by node provisioning order and by name

type NodeSettings

type NodeSettings struct {
}

NodeSettings defines a set of settings that will be stored in the node and re-used by kinder during the node lifecycle.

Storing value in the node is a specific necessity for kinder, because create nodes and actions for setting up a working cluster can happen at different time (while in kind everything happen within an atomic operation).

Jump to

Keyboard shortcuts

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