1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00
Add relative path for local kube config

Add default cluster yaml config name
This commit is contained in:
galal-hussein
2017-11-15 03:12:33 +02:00
parent c59f5e4d07
commit 703a4fd812
21 changed files with 179 additions and 39 deletions

View File

@@ -3,6 +3,7 @@ package cluster
import (
"fmt"
"net"
"path/filepath"
"github.com/rancher/rke/hosts"
"github.com/rancher/rke/pki"
@@ -15,6 +16,8 @@ import (
type Cluster struct {
v1.RancherKubernetesEngineConfig `yaml:",inline"`
ConfigPath string `yaml:"config_path"`
LocalKubeConfigPath string
EtcdHosts []hosts.Host
WorkerHosts []hosts.Host
ControlPlaneHosts []hosts.Host
@@ -28,6 +31,7 @@ type Cluster struct {
const (
X509AuthenticationProvider = "x509"
DefaultClusterConfig = "cluster.yml"
StateConfigMapName = "cluster-state"
UpdateStateTimeout = 30
GetStateTimeout = 30
@@ -69,6 +73,10 @@ func ParseConfig(clusterFile string) (*Cluster, error) {
c.ClusterDomain = c.Services.Kubelet.ClusterDomain
c.ClusterCIDR = c.Services.KubeController.ClusterCIDR
c.ClusterDNSServer = c.Services.Kubelet.ClusterDNSServer
if len(c.ConfigPath) == 0 {
c.ConfigPath = DefaultClusterConfig
}
c.LocalKubeConfigPath = GetLocalKubeConfig(c.ConfigPath)
return c, nil
}
@@ -100,3 +108,10 @@ func parseClusterFile(clusterFile string) (*Cluster, error) {
}
return &kubeCluster, nil
}
func GetLocalKubeConfig(configPath string) string {
baseDir := filepath.Dir(configPath)
fileName := filepath.Base(configPath)
baseDir += "/"
return fmt.Sprintf("%s%s%s", baseDir, pki.KubeAdminConfigPrefix, fileName)
}