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 ¶
- func AddNodeToCluster(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func AddNodesToCluster(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, ...) error
- func CheckName(name string) error
- func CreateCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error
- func CreateNode(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func CreateNodes(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, ...) error
- func DeleteCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error
- func DeleteNode(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node) error
- func GenerateClusterToken() string
- func GetAndWriteKubeConfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster, ...) (string, error)
- func GetCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) (*k3d.Cluster, error)
- func GetClusters(ctx context.Context, runtime k3drt.Runtime) ([]*k3d.Cluster, error)
- func GetDefaultKubeConfig() (*clientcmdapi.Config, error)
- func GetDefaultKubeConfigPath() (string, error)
- func GetKubeconfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) (*clientcmdapi.Config, error)
- func GetNode(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node) (*k3d.Node, error)
- func GetNodes(ctx context.Context, runtime runtimes.Runtime) ([]*k3d.Node, error)
- func RemoveClusterFromDefaultKubeConfig(ctx context.Context, cluster *k3d.Cluster) error
- func RemoveClusterFromKubeConfig(ctx context.Context, cluster *k3d.Cluster, kubeconfig *clientcmdapi.Config) *clientcmdapi.Config
- func SortClusters(clusters []*k3d.Cluster) []*k3d.Cluster
- func StartCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, ...) error
- func StopCluster(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error
- func UpdateKubeConfig(ctx context.Context, newKubeConfig *clientcmdapi.Config, ...) error
- func UpdateLoadbalancerConfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) error
- func ValidateHostname(name string) error
- func WaitForNodeLogMessage(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, message string, ...) error
- func WriteKubeConfig(ctx context.Context, kubeconfig *clientcmdapi.Config, path string) error
- func WriteKubeConfigToPath(ctx context.Context, kubeconfig *clientcmdapi.Config, path string) error
- type WriteKubeConfigOptions
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 ¶
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 ¶
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 ¶
DeleteCluster deletes an existing cluster
func DeleteNode ¶
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 ¶
GetClusters returns a list of all existing clusters
func GetDefaultKubeConfig ¶
func GetDefaultKubeConfig() (*clientcmdapi.Config, error)
GetDefaultKubeConfig loads the default KubeConfig file
func GetDefaultKubeConfigPath ¶
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 RemoveClusterFromDefaultKubeConfig ¶
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 ¶
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 ¶
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 ¶
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 ¶
WriteKubeConfig writes a kubeconfig to a path atomically
func WriteKubeConfigToPath ¶
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