Skip to content

Commit

Permalink
Merge pull request #63691 from detiber/warn_systemd-resolved
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 63673, 63712, 63691, 63684). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

kubeadm - add preflight warning when using systemd-resolved

**What this PR does / why we need it**:

This PR adds a preflight warning when the host is running systemd-resolved.

Newer Ubuntu releases (artful and bionic in particular) run systemd-resolved by default and in the dfeault configuration have an /etc/resolv.conf file that references 127.0.0.53 which is not accessible from containers running on the host. We will now provide a warning to the user to tell them that the kubelet args should include `--resolv-conf=/run/systemd/resolve/resolv.conf`. `/run/systemd/resolve/resolv.conf`. 

**Which issue(s) this PR fixes**:
This does not resolve the following issues, but it does provide better output to the users affected by the issues: kubernetes/kubeadm#273 kubernetes/kubeadm#787

**Release note**:
```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue committed May 11, 2018
2 parents 65f8b88 + 7d7ffdb commit fc28923
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/kubeadm/app/preflight/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ go_library(
"//pkg/kubeapiserver/authorizer/modes:go_default_library",
"//pkg/registry/core/service/ipallocator:go_default_library",
"//pkg/util/initsystem:go_default_library",
"//pkg/util/procfs:go_default_library",
"//pkg/util/version:go_default_library",
"//pkg/version:go_default_library",
"//test/e2e_node/system:go_default_library",
Expand Down
31 changes: 30 additions & 1 deletion cmd/kubeadm/app/preflight/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
authzmodes "k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes"
"k8s.io/kubernetes/pkg/registry/core/service/ipallocator"
"k8s.io/kubernetes/pkg/util/initsystem"
"k8s.io/kubernetes/pkg/util/procfs"
versionutil "k8s.io/kubernetes/pkg/util/version"
kubeadmversion "k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/test/e2e_node/system"
Expand Down Expand Up @@ -813,6 +814,33 @@ func getEtcdVersionResponse(client *http.Client, url string, target interface{})
return err
}

// ResolveCheck tests for potential issues related to the system resolver configuration
type ResolveCheck struct{}

// Name returns label for ResolveCheck
func (ResolveCheck) Name() string {
return "Resolve"
}

// Check validates the system resolver configuration
func (ResolveCheck) Check() (warnings, errors []error) {
glog.V(1).Infoln("validating the system resolver configuration")

warnings = []error{}

// procfs.PidOf only returns an error if the string passed is empty
// or there is an issue compiling the regex, so we can ignore it here
pids, _ := procfs.PidOf("systemd-resolved")
if len(pids) > 0 {
warnings = append(warnings, fmt.Errorf(
"systemd-resolved was detected, for cluster dns resolution to work "+
"properly --resolv-conf=/run/systemd/resolve/resolv.conf must be set "+
"for the kubelet. (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf should be edited for this purpose)\n"))
}

return warnings, errors
}

// RunInitMasterChecks executes all individual, applicable to Master node checks.
func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String) error {
// First, check if we're root separately from the other preflight checks and fail fast
Expand Down Expand Up @@ -951,7 +979,8 @@ func addCommonChecks(execer utilsexec.Interface, cfg kubeadmapi.CommonConfigurat
InPathCheck{executable: "socat", mandatory: false, exec: execer},
InPathCheck{executable: "tc", mandatory: false, exec: execer},
InPathCheck{executable: "touch", mandatory: false, exec: execer},
criCtlChecker)
criCtlChecker,
ResolveCheck{})
}
checks = append(checks,
SystemVerificationCheck{CRISocket: cfg.GetCRISocket()},
Expand Down

0 comments on commit fc28923

Please sign in to comment.