cluster

package
v3.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 18 Imported by: 2

Documentation

Overview

Copyright © 2020 The k3d Author(s)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2020 The k3d Author(s)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2020 The k3d Author(s)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2020 The k3d Author(s)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNodeToCluster

func AddNodeToCluster(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, cluster *k3d.Cluster, createNodeOpts k3d.CreateNodeOpts) error

AddNodeToCluster adds a node to an existing cluster

func AddNodesToCluster

func AddNodesToCluster(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, cluster *k3d.Cluster, createNodeOpts k3d.CreateNodeOpts) error

AddNodesToCluster adds multiple nodes to a chosen cluster

func CheckName

func CheckName(name string) error

CheckName ensures that a cluster name is also a valid host name according to RFC 1123. We further restrict the length of the cluster name to maximum 'clusterNameMaxSize' so that we can construct the host names based on the cluster name, and still stay within the 64 characters limit.

func CreateCluster

func CreateCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error

CreateCluster creates a new cluster consisting of - some containerized k3s nodes - a docker network

func CreateNode

func CreateNode(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, createNodeOpts k3d.CreateNodeOpts) error

CreateNode creates a new containerized k3s node

func CreateNodes

func CreateNodes(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, createNodeOpts k3d.CreateNodeOpts) error

CreateNodes creates a list of nodes

func DeleteCluster

func DeleteCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error

DeleteCluster deletes an existing cluster

func DeleteNode

func DeleteNode(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node) error

DeleteNode deletes an existing node

func GenerateClusterToken

func GenerateClusterToken() string

GenerateClusterToken generates a random 20 character string

func GetAndWriteKubeConfig

func GetAndWriteKubeConfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster, output string, writeKubeConfigOptions *WriteKubeConfigOptions) (string, error)

GetAndWriteKubeConfig ... 1. fetches the KubeConfig from the first master node retrieved for a given cluster 2. modifies it by updating some fields with cluster-specific information 3. writes it to the specified output

func GetCluster

func GetCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) (*k3d.Cluster, error)

GetCluster returns an existing cluster with all fields and node lists populated

func GetClusters

func GetClusters(ctx context.Context, runtime k3drt.Runtime) ([]*k3d.Cluster, error)

GetClusters returns a list of all existing clusters

func GetDefaultKubeConfig

func GetDefaultKubeConfig() (*clientcmdapi.Config, error)

GetDefaultKubeConfig loads the default KubeConfig file

func GetDefaultKubeConfigPath

func GetDefaultKubeConfigPath() (string, error)

GetDefaultKubeConfigPath returns the path of the default kubeconfig, but errors if the KUBECONFIG env var specifies more than one file

func GetKubeconfig

func GetKubeconfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) (*clientcmdapi.Config, error)

GetKubeconfig grabs the kubeconfig file from /output from a master node container, modifies it by updating some fields with cluster-specific information and returns a Config object for further processing

func GetNode

func GetNode(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node) (*k3d.Node, error)

GetNode returns a node matching the specified node fields

func GetNodes

func GetNodes(ctx context.Context, runtime runtimes.Runtime) ([]*k3d.Node, error)

GetNodes returns a list of all existing clusters

func RemoveClusterFromDefaultKubeConfig

func RemoveClusterFromDefaultKubeConfig(ctx context.Context, cluster *k3d.Cluster) error

RemoveClusterFromDefaultKubeConfig removes a cluster's details from the default kubeconfig

func RemoveClusterFromKubeConfig

func RemoveClusterFromKubeConfig(ctx context.Context, cluster *k3d.Cluster, kubeconfig *clientcmdapi.Config) *clientcmdapi.Config

RemoveClusterFromKubeConfig removes a cluster's details from a given kubeconfig

func SortClusters

func SortClusters(clusters []*k3d.Cluster) []*k3d.Cluster

SortClusters : in place sort cluster list by cluster name alphabetical order

func StartCluster

func StartCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, startClusterOpts types.StartClusterOpts) error

StartCluster starts a whole cluster (i.e. all nodes of the cluster)

func StopCluster

func StopCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error

StopCluster stops a whole cluster (i.e. all nodes of the cluster)

func UpdateKubeConfig

func UpdateKubeConfig(ctx context.Context, newKubeConfig *clientcmdapi.Config, existingKubeConfig *clientcmdapi.Config, outPath string, overwriteConflicting bool, updateCurrentContext bool) error

UpdateKubeConfig merges a new kubeconfig into an existing kubeconfig and returns the result

func UpdateLoadbalancerConfig

func UpdateLoadbalancerConfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) error

UpdateLoadbalancerConfig updates the loadbalancer config with an updated list of servers belonging to that cluster

func ValidateHostname

func ValidateHostname(name string) error

ValidateHostname ensures that a cluster name is also a valid host name according to RFC 1123.

func WaitForNodeLogMessage

func WaitForNodeLogMessage(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, message string, since time.Time) error

WaitForNodeLogMessage follows the logs of a node container and returns if it finds a specific line in there (or timeout is reached)

func WriteKubeConfig

func WriteKubeConfig(ctx context.Context, kubeconfig *clientcmdapi.Config, path string) error

WriteKubeConfig writes a kubeconfig to a path atomically

func WriteKubeConfigToPath

func WriteKubeConfigToPath(ctx context.Context, kubeconfig *clientcmdapi.Config, path string) error

WriteKubeConfigToPath takes a kubeconfig and writes it to some path, which can be '-' for os.Stdout

Types

type WriteKubeConfigOptions

type WriteKubeConfigOptions struct {
	UpdateExisting       bool
	UpdateCurrentContext bool
	OverwriteExisting    bool
}

WriteKubeConfigOptions provide a set of options for writing a KubeConfig file

Jump to

Keyboard shortcuts

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