Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions ctriface/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"syscall"
"time"
Expand Down Expand Up @@ -340,24 +338,6 @@ func (o *Orchestrator) getImage(ctx context.Context, imageName string) (*contain
return o.imageManager.GetImage(ctx, imageName, o.snapshotter != "proxy")
}

func getK8sDNS() []string {
//using googleDNS as a backup
dnsIPs := []string{"8.8.8.8"}
//get k8s DNS clusterIP
cmd := exec.Command(
"kubectl", "get", "service", "-n", "kube-system", "kube-dns", "-o=custom-columns=:.spec.clusterIP", "--no-headers",
)
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
log.Warnf("Failed to Fetch k8s dns clusterIP %v\n%s\n", err, stdoutStderr)
log.Warnf("Using google dns %s\n", dnsIPs[0])
} else {
//adding k8s DNS clusterIP to the list
dnsIPs = []string{strings.TrimSpace(string(stdoutStderr)), dnsIPs[0]}
}
return dnsIPs
}

func (o *Orchestrator) getVMConfig(vm *misc.VM) *proto.CreateVMRequest {
kernelArgs := "ro noapic reboot=k panic=1 pci=off nomodules systemd.log_color=false systemd.unit=firecracker.target init=/sbin/overlay-init tsc=reliable quiet 8250.nr_uarts=0 ipv6.disable=1"

Expand All @@ -377,7 +357,7 @@ func (o *Orchestrator) getVMConfig(vm *misc.VM) *proto.CreateVMRequest {
IPConfig: &proto.IPConfiguration{
PrimaryAddr: vm.GetPrimaryAddr(),
GatewayAddr: vm.GetGatewayAddr(),
Nameservers: getK8sDNS(),
Nameservers: o.dns,
},
},
}},
Expand Down
22 changes: 22 additions & 0 deletions ctriface/orch.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package ctriface
import (
"encoding/json"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
Expand Down Expand Up @@ -104,6 +105,7 @@ type Orchestrator struct {
snapshotsDir string
isMetricsMode bool
netPoolSize int
dns []string

vethPrefix string
clonePrefix string
Expand All @@ -123,6 +125,8 @@ func NewOrchestrator(snapshotter, hostIface string, opts ...OrchestratorOption)
o.vethPrefix = "172.17"
o.clonePrefix = "172.18"

o.dns = getK8sDNS()

for _, opt := range opts {
opt(o)
}
Expand Down Expand Up @@ -166,6 +170,24 @@ func NewOrchestrator(snapshotter, hostIface string, opts ...OrchestratorOption)
return o
}

func getK8sDNS() []string {
//using googleDNS as a backup
dnsIPs := []string{"8.8.8.8"}
//get k8s DNS clusterIP
cmd := exec.Command(
"kubectl", "get", "service", "-n", "kube-system", "kube-dns", "-o=custom-columns=:.spec.clusterIP", "--no-headers",
)
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
log.Warnf("Failed to Fetch k8s dns clusterIP %v\n%s\n", err, stdoutStderr)
log.Warnf("Using google dns %s\n", dnsIPs[0])
} else {
//adding k8s DNS clusterIP to the list
dnsIPs = []string{strings.TrimSpace(string(stdoutStderr)), dnsIPs[0]}
}
return dnsIPs
}

func (o *Orchestrator) setupCloseHandler() {
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
Expand Down
Loading