mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-22 17:51:28 +00:00
Remove RootlessControlPlane feature gate
This commit is contained in:
@@ -29,11 +29,9 @@ import (
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/errors"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/initsystem"
|
||||
utilruntime "k8s.io/kubernetes/cmd/kubeadm/app/util/runtime"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/users"
|
||||
)
|
||||
|
||||
// NewCleanupNodePhase creates a kubeadm workflow phase that cleanup the node
|
||||
@@ -119,17 +117,6 @@ func runCleanupNode(c workflow.RunData) error {
|
||||
}
|
||||
resetConfigDir(kubeadmconstants.KubernetesDir, dirsToClean, r.DryRun())
|
||||
|
||||
if r.Cfg() != nil && features.Enabled(r.Cfg().FeatureGates, features.RootlessControlPlane) {
|
||||
if !r.DryRun() {
|
||||
klog.V(1).Infoln("[reset] Removing users and groups created for rootless control-plane")
|
||||
if err := users.RemoveUsersAndGroups(); err != nil {
|
||||
klog.Warningf("[reset] Failed to remove users and groups: %v\n", err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("[dryrun] Would remove users and groups created for rootless control-plane")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,6 @@ const (
|
||||
// PublicKeysECDSA is expected to be alpha in v1.19
|
||||
PublicKeysECDSA = "PublicKeysECDSA"
|
||||
|
||||
// RootlessControlPlane is expected to be in alpha in v1.22
|
||||
RootlessControlPlane = "RootlessControlPlane"
|
||||
|
||||
// WaitForAllControlPlaneComponents is expected to be alpha in v1.30
|
||||
WaitForAllControlPlaneComponents = "WaitForAllControlPlaneComponents"
|
||||
)
|
||||
@@ -57,10 +54,6 @@ var InitFeatureGates = FeatureList{
|
||||
DeprecationMessage: "The PublicKeysECDSA feature gate is deprecated and will be removed when v1beta3 is removed." +
|
||||
" v1beta4 supports a new option 'ClusterConfiguration.EncryptionAlgorithm'.",
|
||||
},
|
||||
RootlessControlPlane: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha},
|
||||
DeprecationMessage: "Deprecated in favor of the core kubelet feature UserNamespacesSupport which is beta since 1.30." +
|
||||
" Once UserNamespacesSupport graduates to GA, kubeadm will start using it and RootlessControlPlane will be removed.",
|
||||
},
|
||||
WaitForAllControlPlaneComponents: {FeatureSpec: featuregate.FeatureSpec{Default: true, PreRelease: featuregate.GA, LockToDefault: true}},
|
||||
ControlPlaneKubeletLocalMode: {FeatureSpec: featuregate.FeatureSpec{Default: true, PreRelease: featuregate.Beta}},
|
||||
NodeLocalCRISocket: {FeatureSpec: featuregate.FeatureSpec{Default: true, PreRelease: featuregate.Beta}},
|
||||
|
||||
@@ -31,13 +31,11 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/images"
|
||||
certphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/errors"
|
||||
staticpodutil "k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/users"
|
||||
)
|
||||
|
||||
// CreateInitStaticPodManifestFiles will write all static pod manifest files needed to bring up the control plane.
|
||||
@@ -125,19 +123,6 @@ func CreateStaticPodFiles(manifestDir, patchesDir string, cfg *kubeadmapi.Cluste
|
||||
klog.V(1).Infoln("[control-plane] getting StaticPodSpecs")
|
||||
specs := GetStaticPodSpecs(cfg, endpoint, nil)
|
||||
|
||||
var usersAndGroups *users.UsersAndGroups
|
||||
var err error
|
||||
if features.Enabled(cfg.FeatureGates, features.RootlessControlPlane) {
|
||||
if isDryRun {
|
||||
fmt.Printf("[control-plane] Would create users and groups for %+v to run as non-root\n", componentNames)
|
||||
} else {
|
||||
usersAndGroups, err = staticpodutil.GetUsersAndGroups()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create users and groups")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// creates required static pod specs
|
||||
for _, componentName := range componentNames {
|
||||
// retrieves the StaticPodSpec for given component
|
||||
@@ -151,18 +136,6 @@ func CreateStaticPodFiles(manifestDir, patchesDir string, cfg *kubeadmapi.Cluste
|
||||
klog.V(2).Infof("[control-plane] adding volume %q for component %q", v.Name, componentName)
|
||||
}
|
||||
|
||||
if features.Enabled(cfg.FeatureGates, features.RootlessControlPlane) {
|
||||
if isDryRun {
|
||||
fmt.Printf("[control-plane] Would update static pod manifest for %q to run run as non-root\n", componentName)
|
||||
} else {
|
||||
if usersAndGroups != nil {
|
||||
if err := staticpodutil.RunComponentAsNonRoot(componentName, &spec, usersAndGroups, cfg); err != nil {
|
||||
return errors.Wrapf(err, "failed to run component %q as non-root", componentName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if patchesDir is defined, patch the static Pod manifest
|
||||
if patchesDir != "" {
|
||||
patchedSpec, err := staticpodutil.PatchStaticPod(&spec, patchesDir, os.Stdout)
|
||||
|
||||
@@ -35,14 +35,12 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/images"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
dryrunutil "k8s.io/kubernetes/cmd/kubeadm/app/util/dryrun"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/errors"
|
||||
etcdutil "k8s.io/kubernetes/cmd/kubeadm/app/util/etcd"
|
||||
staticpodutil "k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/users"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -302,26 +300,6 @@ func prepareAndWriteEtcdStaticPod(manifestDir string, patchesDir string, cfg *ku
|
||||
// gets etcd StaticPodSpec, actualized for the current ClusterConfiguration and the new list of etcd members
|
||||
spec := GetEtcdPodSpec(cfg, endpoint, nodeName, initialCluster)
|
||||
|
||||
var usersAndGroups *users.UsersAndGroups
|
||||
var err error
|
||||
if features.Enabled(cfg.FeatureGates, features.RootlessControlPlane) {
|
||||
if isDryRun {
|
||||
fmt.Printf("[etcd] Would create users and groups for %q to run as non-root\n", kubeadmconstants.Etcd)
|
||||
fmt.Printf("[etcd] Would update static pod manifest for %q to run run as non-root\n", kubeadmconstants.Etcd)
|
||||
} else {
|
||||
usersAndGroups, err = staticpodutil.GetUsersAndGroups()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create users and groups")
|
||||
}
|
||||
// usersAndGroups is nil on non-linux.
|
||||
if usersAndGroups != nil {
|
||||
if err := staticpodutil.RunComponentAsNonRoot(kubeadmconstants.Etcd, &spec, usersAndGroups, cfg); err != nil {
|
||||
return errors.Wrapf(err, "failed to run component %q as non-root", kubeadmconstants.Etcd)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if patchesDir is defined, patch the static Pod manifest
|
||||
if patchesDir != "" {
|
||||
patchedSpec, err := staticpodutil.PatchStaticPod(&spec, patchesDir, os.Stdout)
|
||||
|
||||
Reference in New Issue
Block a user