checks_linux.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // +build linux
  2. /*
  3. Copyright 2019 The Kubernetes Authors.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. package preflight
  15. import (
  16. "github.com/pkg/errors"
  17. "k8s.io/kubernetes/cmd/kubeadm/app/util"
  18. "k8s.io/kubernetes/pkg/proxy/ipvs"
  19. "k8s.io/utils/exec"
  20. utilipset "k8s.io/kubernetes/pkg/util/ipset"
  21. )
  22. // Check validates if Docker is setup to use systemd as the cgroup driver.
  23. func (idsc IsDockerSystemdCheck) Check() (warnings, errorList []error) {
  24. warnings = []error{}
  25. driver, err := util.GetCgroupDriverDocker(exec.New())
  26. if err != nil {
  27. errorList = append(errorList, err)
  28. return nil, errorList
  29. }
  30. if driver != util.CgroupDriverSystemd {
  31. err = errors.Errorf("detected %q as the Docker cgroup driver. "+
  32. "The recommended driver is %q. "+
  33. "Please follow the guide at https://kubernetes.io/docs/setup/cri/",
  34. driver,
  35. util.CgroupDriverSystemd)
  36. warnings = append(warnings, err)
  37. }
  38. return warnings, nil
  39. }
  40. // Check determines if IPVS proxier can be used or not
  41. func (ipvspc IPVSProxierCheck) Check() (warnings, errors []error) {
  42. ipsetInterface := utilipset.New(ipvspc.exec)
  43. kernelHandler := ipvs.NewLinuxKernelHandler()
  44. if _, err := ipvs.CanUseIPVSProxier(kernelHandler, ipsetInterface); err != nil {
  45. return nil, append(errors, err)
  46. }
  47. return nil, nil
  48. }