diff --git a/k3d b/k3d-v3.0.0-dev-20191016-0-1-g6b148ae.tar old mode 100755 new mode 100644 similarity index 60% rename from k3d rename to k3d-v3.0.0-dev-20191016-0-1-g6b148ae.tar index 927a463e..82cb0d9e Binary files a/k3d and b/k3d-v3.0.0-dev-20191016-0-1-g6b148ae.tar differ diff --git a/pkg/cluster/kubeconfig.go b/pkg/cluster/kubeconfig.go new file mode 100644 index 00000000..03dc2a0d --- /dev/null +++ b/pkg/cluster/kubeconfig.go @@ -0,0 +1,41 @@ +/* +Copyright © 2019 Thorsten Klein + +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. +*/ +package cluster + +import ( + "github.com/rancher/k3d/pkg/runtimes" + k3d "github.com/rancher/k3d/pkg/types" + log "github.com/sirupsen/logrus" +) + +func GetKubeconfig(runtime runtimes.Runtime, cluster *k3d.Cluster) error { + masterNodes, err := runtime.GetNodesByLabel(map[string]string{"k3d.cluster": cluster.Name, "k3d.role": string(k3d.MasterRole)}) + if err != nil { + log.Errorln("Failed to get masternodes") + return err + } + if err := runtime.GetKubeconfig(masterNodes[0]); err != nil { + log.Errorf("Failed to get kubeconfig from node '%s'", masterNodes[0].Name) + return err + } + return nil +} diff --git a/pkg/runtimes/containerd/kubeconfig.go b/pkg/runtimes/containerd/kubeconfig.go new file mode 100644 index 00000000..2c662506 --- /dev/null +++ b/pkg/runtimes/containerd/kubeconfig.go @@ -0,0 +1,32 @@ +/* +Copyright © 2019 Thorsten Klein + +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. +*/ + +package containerd + +import ( + k3d "github.com/rancher/k3d/pkg/types" +) + +// GetKubeconfig grabs the kubeconfig from inside a k3d node +func (d Containerd) GetKubeconfig(node *k3d.Node) error { + return nil +} diff --git a/pkg/runtimes/docker/kubeconfig.go b/pkg/runtimes/docker/kubeconfig.go new file mode 100644 index 00000000..2b5a4c24 --- /dev/null +++ b/pkg/runtimes/docker/kubeconfig.go @@ -0,0 +1,32 @@ +/* +Copyright © 2019 Thorsten Klein + +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. +*/ + +package docker + +import ( + k3d "github.com/rancher/k3d/pkg/types" +) + +// GetKubeconfig grabs the kubeconfig from inside a k3d node +func (d Docker) GetKubeconfig(node *k3d.Node) error { + return nil +} diff --git a/pkg/runtimes/runtime.go b/pkg/runtimes/runtime.go index 3e5beab5..1e9ac010 100644 --- a/pkg/runtimes/runtime.go +++ b/pkg/runtimes/runtime.go @@ -41,6 +41,7 @@ type Runtime interface { DeleteNode(*k3d.Node) error GetNodesByLabel(map[string]string) ([]*k3d.Node, error) CreateNetworkIfNotPresent(name string) (string, error) + GetKubeconfig(*k3d.Node) error // StartContainer() error // ExecContainer() error // StopContainer() error