Documentation ¶
Overview ¶
Copyright © 2020-2021 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-2021 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-2021 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-2021 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-2021 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-2021 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-2021 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-2021 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 ¶
- Variables
- func CheckName(name string) error
- func ClusterCreate(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, ...) error
- func ClusterDelete(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, ...) error
- func ClusterGet(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) (*k3d.Cluster, error)
- func ClusterList(ctx context.Context, runtime k3drt.Runtime) ([]*k3d.Cluster, error)
- func ClusterPrep(ctx context.Context, runtime k3drt.Runtime, ...) error
- func ClusterPrepImageVolume(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, ...) error
- func ClusterPrepNetwork(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, ...) error
- func ClusterRun(ctx context.Context, runtime k3drt.Runtime, ...) error
- func ClusterStart(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, ...) error
- func ClusterStop(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error
- func EnableCgroupV2FixIfNeeded(runtime runtimes.Runtime)
- func GenerateClusterToken() string
- func GetHostIP(ctx context.Context, rtime rt.Runtime, cluster *k3d.Cluster) (net.IP, error)
- func GetIP(ctx context.Context, runtime k3drt.Runtime, network *k3d.ClusterNetwork) (netaddr.IP, error)
- func KubeconfigGet(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) (*clientcmdapi.Config, error)
- func KubeconfigGetDefaultFile() (*clientcmdapi.Config, error)
- func KubeconfigGetDefaultPath() (string, error)
- func KubeconfigGetWrite(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster, ...) (string, error)
- func KubeconfigMerge(ctx context.Context, newKubeConfig *clientcmdapi.Config, ...) error
- func KubeconfigRemoveCluster(ctx context.Context, cluster *k3d.Cluster, kubeconfig *clientcmdapi.Config) *clientcmdapi.Config
- func KubeconfigRemoveClusterFromDefaultConfig(ctx context.Context, cluster *k3d.Cluster) error
- func KubeconfigWrite(ctx context.Context, kubeconfig *clientcmdapi.Config, path string) error
- func KubeconfigWriteToPath(ctx context.Context, kubeconfig *clientcmdapi.Config, path string) error
- func NodeAddToCluster(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func NodeAddToClusterMulti(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, ...) error
- func NodeCreate(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func NodeCreateMulti(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, ...) error
- func NodeDelete(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func NodeFilterByRoles(nodes []*k3d.Node, includeRoles, excludeRoles []k3d.Role) []*k3d.Node
- func NodeGet(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node) (*k3d.Node, error)
- func NodeList(ctx context.Context, runtime runtimes.Runtime) ([]*k3d.Node, error)
- func NodeRun(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func NodeStart(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, ...) error
- func NodeWaitForLogMessage(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, message string, ...) error
- func RegistryConnectClusters(ctx context.Context, runtime runtimes.Runtime, registryNode *k3d.Node, ...) error
- func RegistryConnectNetworks(ctx context.Context, runtime runtimes.Runtime, registryNode *k3d.Node, ...) error
- func RegistryCreate(ctx context.Context, runtime runtimes.Runtime, reg *k3d.Registry) (*k3d.Node, error)
- func RegistryFromNode(node *k3d.Node) (*k3d.Registry, error)
- func RegistryGenerateK3sConfig(ctx context.Context, registries []*k3d.Registry) (*k3s.Registry, error)
- func RegistryGenerateLocalRegistryHostingConfigMapYAML(ctx context.Context, runtime runtimes.Runtime, registries []*k3d.Registry) ([]byte, error)
- func RegistryGet(ctx context.Context, runtime runtimes.Runtime, name string) (*k3d.Registry, error)
- func RegistryMergeConfig(ctx context.Context, dest, src *k3s.Registry) error
- func RegistryRun(ctx context.Context, runtime runtimes.Runtime, reg *k3d.Registry) (*k3d.Node, error)
- func SortClusters(clusters []*k3d.Cluster) []*k3d.Cluster
- func UpdateLoadbalancerConfig(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) error
- func ValidateHostname(name string) error
- type WriteKubeConfigOptions
Constants ¶
This section is empty.
Variables ¶
var ClusterGetNoNodesFoundError = errors.New("No nodes found for given cluster")
Functions ¶
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 ClusterCreate ¶
func ClusterCreate(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, clusterCreateOpts *k3d.ClusterCreateOpts) error
ClusterCreate creates a new cluster consisting of - some containerized k3s nodes - a docker network
func ClusterDelete ¶
func ClusterDelete(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, opts k3d.ClusterDeleteOpts) error
ClusterDelete deletes an existing cluster
func ClusterGet ¶
func ClusterGet(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) (*k3d.Cluster, error)
ClusterGet returns an existing cluster with all fields and node lists populated
func ClusterList ¶
ClusterList returns a list of all existing clusters
func ClusterPrep ¶
func ClusterPrep(ctx context.Context, runtime k3drt.Runtime, clusterConfig *config.ClusterConfig) error
ClusterPrep takes care of the steps required before creating/starting the cluster containers
func ClusterPrepImageVolume ¶
func ClusterPrepNetwork ¶
func ClusterPrepNetwork(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, clusterCreateOpts *k3d.ClusterCreateOpts) error
ClusterPrepNetwork creates a new cluster network, if needed or sets everything up to re-use an existing network
func ClusterRun ¶
func ClusterRun(ctx context.Context, runtime k3drt.Runtime, clusterConfig *config.ClusterConfig) error
ClusterRun orchestrates the steps of cluster creation, configuration and starting
func ClusterStart ¶
func ClusterStart(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster, startClusterOpts types.ClusterStartOpts) error
ClusterStart starts a whole cluster (i.e. all nodes of the cluster)
func ClusterStop ¶
ClusterStop stops a whole cluster (i.e. all nodes of the cluster)
func EnableCgroupV2FixIfNeeded ¶ added in v4.4.4
FIXME: FixCgroupV2 - to be removed when fixed upstream
func GenerateClusterToken ¶
func GenerateClusterToken() string
GenerateClusterToken generates a random 20 character string
func GetHostIP ¶
GetHostIP returns the routable IP address to be able to access services running on the host system from inside the cluster. This depends on the Operating System and the chosen Runtime.
func KubeconfigGet ¶
func KubeconfigGet(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster) (*clientcmdapi.Config, error)
KubeconfigGet grabs the kubeconfig file from /output from a server node container, modifies it by updating some fields with cluster-specific information and returns a Config object for further processing
func KubeconfigGetDefaultFile ¶
func KubeconfigGetDefaultFile() (*clientcmdapi.Config, error)
KubeconfigGetDefaultFile loads the default KubeConfig file
func KubeconfigGetDefaultPath ¶
KubeconfigGetDefaultPath returns the path of the default kubeconfig, but errors if the KUBECONFIG env var specifies more than one file
func KubeconfigGetWrite ¶
func KubeconfigGetWrite(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster, output string, writeKubeConfigOptions *WriteKubeConfigOptions) (string, error)
KubeconfigGetWrite ... 1. fetches the KubeConfig from the first server 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 KubeconfigMerge ¶
func KubeconfigMerge(ctx context.Context, newKubeConfig *clientcmdapi.Config, existingKubeConfig *clientcmdapi.Config, outPath string, overwriteConflicting bool, updateCurrentContext bool) error
KubeconfigMerge merges a new kubeconfig into an existing kubeconfig and returns the result
func KubeconfigRemoveCluster ¶
func KubeconfigRemoveCluster(ctx context.Context, cluster *k3d.Cluster, kubeconfig *clientcmdapi.Config) *clientcmdapi.Config
KubeconfigRemoveCluster removes a cluster's details from a given kubeconfig
func KubeconfigRemoveClusterFromDefaultConfig ¶
KubeconfigRemoveClusterFromDefaultConfig removes a cluster's details from the default kubeconfig
func KubeconfigWrite ¶
KubeconfigWrite writes a kubeconfig to a path atomically
func KubeconfigWriteToPath ¶
KubeconfigWriteToPath takes a kubeconfig and writes it to some path, which can be '-' for os.Stdout
func NodeAddToCluster ¶
func NodeAddToCluster(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, cluster *k3d.Cluster, createNodeOpts k3d.NodeCreateOpts) error
NodeAddToCluster adds a node to an existing cluster
func NodeAddToClusterMulti ¶
func NodeAddToClusterMulti(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, cluster *k3d.Cluster, createNodeOpts k3d.NodeCreateOpts) error
NodeAddToClusterMulti adds multiple nodes to a chosen cluster
func NodeCreate ¶
func NodeCreate(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, createNodeOpts k3d.NodeCreateOpts) error
NodeCreate creates a new containerized k3s node
func NodeCreateMulti ¶
func NodeCreateMulti(ctx context.Context, runtime runtimes.Runtime, nodes []*k3d.Node, createNodeOpts k3d.NodeCreateOpts) error
NodeCreateMulti creates a list of nodes
func NodeDelete ¶
func NodeDelete(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, opts k3d.NodeDeleteOpts) error
NodeDelete deletes an existing node
func NodeFilterByRoles ¶
NodeFilterByRoles filters a list of nodes by their roles
func NodeRun ¶
func NodeRun(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, nodeCreateOpts k3d.NodeCreateOpts) error
NodeRun creates and starts a node
func NodeStart ¶
func NodeStart(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, nodeStartOpts k3d.NodeStartOpts) error
NodeStart starts an existing node
func NodeWaitForLogMessage ¶
func NodeWaitForLogMessage(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, message string, since time.Time) error
NodeWaitForLogMessage follows the logs of a node container and returns if it finds a specific line in there (or timeout is reached)
func RegistryConnectClusters ¶
func RegistryConnectClusters(ctx context.Context, runtime runtimes.Runtime, registryNode *k3d.Node, clusters []*k3d.Cluster) error
RegistryConnectClusters connects an existing registry to one or more clusters
func RegistryConnectNetworks ¶
func RegistryConnectNetworks(ctx context.Context, runtime runtimes.Runtime, registryNode *k3d.Node, networks []string) error
RegistryConnectNetworks connects an existing registry to one or more networks
func RegistryCreate ¶
func RegistryCreate(ctx context.Context, runtime runtimes.Runtime, reg *k3d.Registry) (*k3d.Node, error)
RegistryCreate creates a registry node
func RegistryFromNode ¶
RegistryFromNode transforms a node spec to a registry spec
func RegistryGenerateK3sConfig ¶
func RegistryGenerateK3sConfig(ctx context.Context, registries []*k3d.Registry) (*k3s.Registry, error)
RegistryGenerateK3sConfig generates the k3s specific registries.yaml configuration for multiple registries
func RegistryGenerateLocalRegistryHostingConfigMapYAML ¶
func RegistryGenerateLocalRegistryHostingConfigMapYAML(ctx context.Context, runtime runtimes.Runtime, registries []*k3d.Registry) ([]byte, error)
RegistryGenerateLocalRegistryHostingConfigMapYAML generates a ConfigMap used to advertise the registries in the cluster
func RegistryGet ¶
RegistryGet gets a registry node by name and returns it as a registry object
func RegistryMergeConfig ¶
RegistryMergeConfig merges a source registry config into an existing dest registry cofnig
func RegistryRun ¶
func SortClusters ¶
SortClusters : in place sort cluster list by cluster name alphabetical order
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.
Types ¶
type WriteKubeConfigOptions ¶
type WriteKubeConfigOptions struct { UpdateExisting bool UpdateCurrentContext bool OverwriteExisting bool }
WriteKubeConfigOptions provide a set of options for writing a KubeConfig file