mirror of
https://github.com/rancher/rke.git
synced 2025-08-28 11:21:31 +00:00
Revert "Merge pull request #3132 from jiaqiluo/check-psp"
This reverts commit0e4d5b6f26
, reversing changes made tofc16be2c65
.
This commit is contained in:
parent
b3499c5920
commit
8cef861581
@ -7,7 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/blang/semver"
|
"github.com/blang/semver"
|
||||||
"github.com/rancher/rke/k8s"
|
|
||||||
"github.com/rancher/rke/log"
|
"github.com/rancher/rke/log"
|
||||||
"github.com/rancher/rke/metadata"
|
"github.com/rancher/rke/metadata"
|
||||||
"github.com/rancher/rke/pki"
|
"github.com/rancher/rke/pki"
|
||||||
@ -675,30 +674,6 @@ func validatePodSecurityPolicy(c *Cluster) error {
|
|||||||
return errors.New("PodSecurityPolicy has been removed and can not be enabled since k8s v1.25")
|
return errors.New("PodSecurityPolicy has been removed and can not be enabled since k8s v1.25")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if there is any PSP resource when upgrading a cluster to k8s v1.25 and above
|
|
||||||
if parsedRangeAtLeast125(parsedVersion) {
|
|
||||||
kubeClient, err := k8s.NewClient(c.LocalKubeConfigPath, c.K8sWrapTransport)
|
|
||||||
if err != nil {
|
|
||||||
// we can not tell this is invoked when creating a new cluster or updating an existing one, so skip this check
|
|
||||||
logrus.Debugf("Skip the check for PSP resource due to the failure of initializing the kubernetes client")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
pspList, _ := k8s.GetPSPList(kubeClient)
|
|
||||||
// ignore the error because the "no such resource type" error is definitely returned in k8s v1.25 and above
|
|
||||||
items := pspList.Items
|
|
||||||
if len(items) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// a PSP "psp.flannel.unprivileged" from old Flannel templates is created when using Flannel as the network plugin
|
|
||||||
// we should ignore it if it is the only PSP in the cluster
|
|
||||||
if len(items) == 1 && items[0].Name == "psp.flannel.unprivileged" && c.Network.Plugin == FlannelNetworkPlugin {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
msg := fmt.Sprintf("PodSecurityPolicy(PSP) resource is detected in the cluster, "+
|
|
||||||
"please remove them before upgrading the cluster version to %s", c.Version)
|
|
||||||
return errors.New(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,3 @@ func updatePodSecurityPolicy(k8sClient *kubernetes.Clientset, p interface{}) err
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPSPList returns the PodSecurityPolicyList containing all PSPs in the cluster and an error.
|
|
||||||
// The list could be empty if there is no PSP in the cluster.
|
|
||||||
func GetPSPList(k8sClient *kubernetes.Clientset) (*v1beta1.PodSecurityPolicyList, error) {
|
|
||||||
return k8sClient.PolicyV1beta1().PodSecurityPolicies().List(context.TODO(), metav1.ListOptions{})
|
|
||||||
}
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2023 Rancher Labs, Inc.
|
Copyright 2022 Rancher Labs, Inc.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -296,7 +296,7 @@ type KubeAPIService struct {
|
|||||||
// Enabled/Disable PodSecurityPolicy
|
// Enabled/Disable PodSecurityPolicy
|
||||||
PodSecurityPolicy bool `yaml:"pod_security_policy" json:"podSecurityPolicy,omitempty"`
|
PodSecurityPolicy bool `yaml:"pod_security_policy" json:"podSecurityPolicy,omitempty"`
|
||||||
// setting the default configuration for PodSecurityAdmission
|
// setting the default configuration for PodSecurityAdmission
|
||||||
PodSecurityConfiguration string `yaml:"pod_security_configuration" json:"podSecurityConfiguration,omitempty"`
|
PodSecurityConfiguration string `yaml:"pod_security_configuration" json:"podSecurityConfiguration,omitempty" norman:"default=privileged"`
|
||||||
// Enable/Disable AlwaysPullImages admissions plugin
|
// Enable/Disable AlwaysPullImages admissions plugin
|
||||||
AlwaysPullImages bool `yaml:"always_pull_images" json:"alwaysPullImages,omitempty"`
|
AlwaysPullImages bool `yaml:"always_pull_images" json:"alwaysPullImages,omitempty"`
|
||||||
// Secrets encryption provider config
|
// Secrets encryption provider config
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2023 Rancher Labs, Inc.
|
Copyright 2022 Rancher Labs, Inc.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
Loading…
Reference in New Issue
Block a user