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 ¶
- func IsKnown(name string) (bool, error)
- func KubeConfigPath(name string) string
- func ListClusters() ([]string, error)
- type Cluster
- func (c *Cluster) AllNodes() NodeList
- func (c *Cluster) BootstrapControlPlane() *Node
- func (c *Cluster) ControlPlanes() NodeList
- func (c *Cluster) ExternalEtcd() *Node
- func (c *Cluster) ExternalLoadBalancer() *Node
- func (c *Cluster) K8sNodes() NodeList
- func (c *Cluster) KubeConfigPath() string
- func (c *Cluster) Name() string
- func (c *Cluster) ReadSettings() (err error)
- func (c *Cluster) ResolveNodesPath(nodesPath string) (nodes NodeList, path string, err error)
- func (c *Cluster) SecondaryControlPlanes() NodeList
- func (c *Cluster) SelectNodes(nodeSelector string) (nodes NodeList, err error)
- func (c *Cluster) Validate() error
- func (c *Cluster) Workers() NodeList
- func (c *Cluster) WriteSettings() error
- type ClusterIPFamily
- type ClusterSettings
- type ContainerRuntime
- type Node
- func (n *Node) CRI() (cri ContainerRuntime, err error)
- func (n *Node) Command(command string, args ...string) *exec.NodeCmd
- func (n *Node) CopyFrom(source, dest string) error
- func (n *Node) CopyTo(source, dest string) error
- func (n *Node) DryRun()
- func (n *Node) EtcdImage() (string, error)
- func (n *Node) IP() (ipv4 string, ipv6 string, err error)
- func (n *Node) Infof(message string, args ...interface{})
- func (n *Node) IsControlPlane() bool
- func (n *Node) IsExternalEtcd() bool
- func (n *Node) IsExternalLoadBalancer() bool
- func (n *Node) IsWorker() bool
- func (n *Node) KubeVersion() (version string, err error)
- func (n *Node) KubeadmVersion() (*K8sVersion.Version, error)
- func (n *Node) MustKubeVersion() *K8sVersion.Version
- func (n *Node) MustKubeadmVersion() *K8sVersion.Version
- func (n *Node) Name() string
- func (n *Node) Ports(containerPort int32) (hostPort int32, err error)
- func (n *Node) ReadClusterSettings() (*ClusterSettings, error)
- func (n *Node) ReadNodeSettings() (*NodeSettings, error)
- func (n *Node) Role() string
- func (n *Node) SkipActions()
- func (n *Node) WriteClusterSettings(settings *ClusterSettings) error
- func (n *Node) WriteFile(containerPath string, contents []byte) error
- func (n *Node) WriteNodeSettings(settings *NodeSettings) error
- type NodeList
- type NodeSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsKnown ¶
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 ¶
KubeConfigPath returns the kubeconfig path for a cluster name
func ListClusters ¶
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 ¶
FromDocker returns a new cluster status created by discovering and inspecting existing containers nodes
func (*Cluster) AllNodes ¶
AllNodes returns all the nodes in the cluster (including K8s nodes, external loadbalancer and external etcd)
func (*Cluster) BootstrapControlPlane ¶
BootstrapControlPlane returns the first node with control-plane role. This is the node where kubeadm init will be executed.
func (*Cluster) ControlPlanes ¶
ControlPlanes returns all the nodes with control-plane role
func (*Cluster) ExternalEtcd ¶
ExternalEtcd returns the node with external-etcd role, if defined
func (*Cluster) ExternalLoadBalancer ¶
ExternalLoadBalancer returns the node with external-load-balancer role, if defined
func (*Cluster) K8sNodes ¶
K8sNodes returns all the nodes that hosts a Kubernetes nodes in the cluster (all nodes except external loadbalancer and external etcd)
func (*Cluster) KubeConfigPath ¶
KubeConfigPath returns the path to where the Kubeconfig would be placed by kinder based on the configuration.
func (*Cluster) ReadSettings ¶
ReadSettings read cluster settings from a control plane node
func (*Cluster) ResolveNodesPath ¶
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 ¶
SecondaryControlPlanes returns all the nodes with control-plane role except the BootstrapControlPlane node, if any,
func (*Cluster) SelectNodes ¶
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) WriteSettings ¶
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 (*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) CopyFrom ¶
CopyFrom copies the source file on the node to dest on the host. Please note that this have limitations around symlinks.
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 ¶
EtcdImage returns the etcdImage that should be used with the kubernetes version installed on this node
func (*Node) Infof ¶
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 ¶
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 ¶
IsExternalEtcd returns true if the node hosts an external etcd member
func (*Node) IsExternalLoadBalancer ¶
IsExternalLoadBalancer returns true if the node hosts an external load balancer
func (*Node) KubeVersion ¶
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) Ports ¶
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) 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 ¶
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 ¶
EligibleForActions returns the list of nodes without nodes marked as SkipAction
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).