Allow virtual-kubelet to use cluster domain

This allows `--cluster-domain` to be passed to virtual kubelet like a
traditional kublet, and use this to generate search-domains for
`/etc/resolv.conf`

* Set default `cluster-domain` to `cluster-local` to match current kubelet

Related: #641

Signed-off-by: Graham Hayes <gr@ham.ie>
This commit is contained in:
Graham Hayes
2019-06-19 17:22:21 +01:00
parent 77069e63e5
commit 6b6798865e
4 changed files with 17 additions and 6 deletions

View File

@@ -60,6 +60,7 @@ func (mv mapVar) Type() string {
func installFlags(flags *pflag.FlagSet, c *Opts) {
flags.StringVar(&c.KubeConfigPath, "kubeconfig", c.KubeConfigPath, "kube config file to use for connecting to the Kubernetes API server")
flags.StringVar(&c.KubeNamespace, "namespace", c.KubeNamespace, "kubernetes namespace (default is 'all')")
flags.StringVar(&c.KubeClusterDomain, "cluster-domain", c.KubeClusterDomain, "kubernetes cluster-domain (default is 'cluster.local')")
flags.StringVar(&c.NodeName, "nodename", c.NodeName, "kubernetes node name")
flags.StringVar(&c.OperatingSystem, "os", c.OperatingSystem, "Operating System (Linux/Windows)")
flags.StringVar(&c.Provider, "provider", c.Provider, "cloud provider")

View File

@@ -34,6 +34,7 @@ const (
DefaultListenPort = 10250 // TODO(cpuguy83)(VK1.0): Change this to an addr instead of just a port.. we should not be listening on all interfaces.
DefaultPodSyncWorkers = 10
DefaultKubeNamespace = corev1.NamespaceAll
DefaultKubeClusterDomain = "cluster.local"
DefaultTaintEffect = string(corev1.TaintEffectNoSchedule)
DefaultTaintKey = "virtual-kubelet.io/provider"
@@ -49,6 +50,9 @@ type Opts struct {
KubeConfigPath string
// Namespace to watch for pods and other resources
KubeNamespace string
// Domain suffix to append to search domains for the pods created by virtual-kubelet
KubeClusterDomain string
// Sets the port to listen for requests from the Kubernetes API server
ListenPort int32
@@ -127,6 +131,10 @@ func SetDefaultOpts(c *Opts) error {
c.KubeNamespace = DefaultKubeNamespace
}
if c.KubeClusterDomain == "" {
c.KubeClusterDomain = DefaultKubeClusterDomain
}
if c.TaintKey == "" {
c.TaintKey = DefaultTaintKey
}

View File

@@ -126,6 +126,7 @@ func runRootCommand(ctx context.Context, s *providers.Store, c Opts) error {
ResourceManager: rm,
DaemonPort: int32(c.ListenPort),
InternalIP: os.Getenv("VKUBELET_POD_IP"),
KubeClusterDomain: c.KubeClusterDomain,
}
pInit := s.Get(c.Provider)