Skip to content

Commit fc28923

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #63691 from detiber/warn_systemd-resolved
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 ```
2 parents 65f8b88 + 7d7ffdb commit fc28923

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

cmd/kubeadm/app/preflight/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ go_library(
5656
"//pkg/kubeapiserver/authorizer/modes:go_default_library",
5757
"//pkg/registry/core/service/ipallocator:go_default_library",
5858
"//pkg/util/initsystem:go_default_library",
59+
"//pkg/util/procfs:go_default_library",
5960
"//pkg/util/version:go_default_library",
6061
"//pkg/version:go_default_library",
6162
"//test/e2e_node/system:go_default_library",

cmd/kubeadm/app/preflight/checks.go

+30-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050
authzmodes "k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes"
5151
"k8s.io/kubernetes/pkg/registry/core/service/ipallocator"
5252
"k8s.io/kubernetes/pkg/util/initsystem"
53+
"k8s.io/kubernetes/pkg/util/procfs"
5354
versionutil "k8s.io/kubernetes/pkg/util/version"
5455
kubeadmversion "k8s.io/kubernetes/pkg/version"
5556
"k8s.io/kubernetes/test/e2e_node/system"
@@ -813,6 +814,33 @@ func getEtcdVersionResponse(client *http.Client, url string, target interface{})
813814
return err
814815
}
815816

817+
// ResolveCheck tests for potential issues related to the system resolver configuration
818+
type ResolveCheck struct{}
819+
820+
// Name returns label for ResolveCheck
821+
func (ResolveCheck) Name() string {
822+
return "Resolve"
823+
}
824+
825+
// Check validates the system resolver configuration
826+
func (ResolveCheck) Check() (warnings, errors []error) {
827+
glog.V(1).Infoln("validating the system resolver configuration")
828+
829+
warnings = []error{}
830+
831+
// procfs.PidOf only returns an error if the string passed is empty
832+
// or there is an issue compiling the regex, so we can ignore it here
833+
pids, _ := procfs.PidOf("systemd-resolved")
834+
if len(pids) > 0 {
835+
warnings = append(warnings, fmt.Errorf(
836+
"systemd-resolved was detected, for cluster dns resolution to work "+
837+
"properly --resolv-conf=/run/systemd/resolve/resolv.conf must be set "+
838+
"for the kubelet. (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf should be edited for this purpose)\n"))
839+
}
840+
841+
return warnings, errors
842+
}
843+
816844
// RunInitMasterChecks executes all individual, applicable to Master node checks.
817845
func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String) error {
818846
// First, check if we're root separately from the other preflight checks and fail fast
@@ -951,7 +979,8 @@ func addCommonChecks(execer utilsexec.Interface, cfg kubeadmapi.CommonConfigurat
951979
InPathCheck{executable: "socat", mandatory: false, exec: execer},
952980
InPathCheck{executable: "tc", mandatory: false, exec: execer},
953981
InPathCheck{executable: "touch", mandatory: false, exec: execer},
954-
criCtlChecker)
982+
criCtlChecker,
983+
ResolveCheck{})
955984
}
956985
checks = append(checks,
957986
SystemVerificationCheck{CRISocket: cfg.GetCRISocket()},

0 commit comments

Comments
 (0)