Merge pull request #3433 from chaunceyjiang/prefix-namespace

feat: allows users to propagate resources under the Kubernetes reserved namespace.
This commit is contained in:
karmada-bot 2023-04-21 10:52:07 +08:00 committed by GitHub
commit b118a73ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 14 deletions

View File

@ -185,8 +185,9 @@ func (o *Options) AddFlags(flags *pflag.FlagSet, allControllers, disabledByDefau
"<group> for skip resources with a specific API group(e.g. networking.k8s.io),\n"+
"<group>/<version> for skip resources with a specific API version(e.g. networking.k8s.io/v1beta1),\n"+
"<group>/<version>/<kind>,<kind> for skip one or more specific resource(e.g. networking.k8s.io/v1beta1/Ingress,IngressClass) where the kinds are case-insensitive.")
flags.StringSliceVar(&o.SkippedPropagatingNamespaces, "skipped-propagating-namespaces", []string{},
"Comma-separated namespaces that should be skipped from propagating in addition to the default skipped namespaces(karmada-system, karmada-cluster, namespaces prefixed by kube- and karmada-es-).")
flags.StringSliceVar(&o.SkippedPropagatingNamespaces, "skipped-propagating-namespaces", []string{"kube-.*"},
"Comma-separated namespaces that should be skipped from propagating.\n"+
"Note: 'karmada-system', 'karmada-cluster' and 'karmada-es-.*' are Karmada reserved namespaces that will always be skipped.")
flags.StringVar(&o.ClusterAPIContext, "cluster-api-context", "", "Name of the cluster context in cluster-api management cluster kubeconfig file.")
flags.StringVar(&o.ClusterAPIKubeconfig, "cluster-api-kubeconfig", "", "Path to the cluster-api management cluster kubeconfig file.")
flags.Float32Var(&o.ClusterAPIQPS, "cluster-api-qps", 40.0, "QPS to use while talking with cluster kube-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")

View File

@ -11,11 +11,6 @@ import (
)
const (
// KubernetesReservedNSPrefix is the prefix of namespace which reserved by Kubernetes system, such as:
// - kube-system
// - kube-public
// - kube-node-lease
KubernetesReservedNSPrefix = "kube-"
// NamespaceKarmadaSystem is reserved namespace
NamespaceKarmadaSystem = "karmada-system"
// NamespaceKarmadaCluster is reserved namespace
@ -137,8 +132,7 @@ func GenerateEstimatorDeploymentName(clusterName string) string {
func IsReservedNamespace(namespace string) bool {
return namespace == NamespaceKarmadaSystem ||
namespace == NamespaceKarmadaCluster ||
strings.HasPrefix(namespace, ExecutionSpacePrefix) ||
strings.HasPrefix(namespace, KubernetesReservedNSPrefix)
strings.HasPrefix(namespace, ExecutionSpacePrefix)
}
// GenerateImpersonationSecretName generates the secret name of impersonation secret.

View File

@ -353,11 +353,6 @@ func TestIsReservedNamespace(t *testing.T) {
namespace: NamespaceKarmadaCluster,
expected: true,
},
{
name: "kube-",
namespace: KubernetesReservedNSPrefix,
expected: true,
},
{
name: "karmada-es-",
namespace: ExecutionSpacePrefix,