Skip to content

Commit

Permalink
Allow virtual-kubelet to use cluster domain
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
grahamhayes committed Jun 19, 2019
1 parent 77069e6 commit 3bdc74f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/virtual-kubelet/commands/root/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions cmd/virtual-kubelet/commands/root/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -127,6 +131,10 @@ func SetDefaultOpts(c *Opts) error {
c.KubeNamespace = DefaultKubeNamespace
}

if c.KubeClusterDomain == "" {
c.KubeClusterDomain = DefaultKubeClusterDomain
}

if c.TaintKey == "" {
c.TaintKey = DefaultTaintKey
}
Expand Down
1 change: 1 addition & 0 deletions cmd/virtual-kubelet/commands/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3bdc74f

Please sign in to comment.