From 0eb2fa12d4abfeff265c7b9d5c9ba5a887cfc337 Mon Sep 17 00:00:00 2001 From: f41gh7 Date: Wed, 3 Jul 2024 15:43:28 +0200 Subject: [PATCH] removes psp RBAC --- .../operator/factory/k8stools/version.go | 9 ------ .../operator/factory/k8stools/version_test.go | 32 ------------------- .../controller/operator/vmagent_controller.go | 1 - 3 files changed, 42 deletions(-) diff --git a/internal/controller/operator/factory/k8stools/version.go b/internal/controller/operator/factory/k8stools/version.go index 9dcc13a2..13845c09 100644 --- a/internal/controller/operator/factory/k8stools/version.go +++ b/internal/controller/operator/factory/k8stools/version.go @@ -41,15 +41,6 @@ func SetKubernetesVersionWithDefaults(vi *version.Info, defaultMinor, defaultMaj return nil } -// IsPSPSupported check if PodSecurityPolicy is supported by kubernetes API server -// https://kubernetes.io/docs/reference/using-api/deprecation-guide/#psp-v125 -func IsPSPSupported() bool { - if ServerMajorVersion == 1 && ServerMinorVersion <= 24 { - return true - } - return false -} - // IsPDBV1APISupported check if new v1 API is supported by kubernetes API server // deprecated since 1.21 // https://kubernetes.io/docs/reference/using-api/deprecation-guide/#poddisruptionbudget-v125 diff --git a/internal/controller/operator/factory/k8stools/version_test.go b/internal/controller/operator/factory/k8stools/version_test.go index 964a9793..689f43ca 100644 --- a/internal/controller/operator/factory/k8stools/version_test.go +++ b/internal/controller/operator/factory/k8stools/version_test.go @@ -1,33 +1 @@ package k8stools - -import "testing" - -func TestIsPSPSupported(t *testing.T) { - tests := []struct { - name string - want bool - major uint64 - minor uint64 - }{ - { - name: "yes", - major: 1, - minor: 22, - want: true, - }, - { - name: "no", - major: 1, - minor: 25, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ServerMinorVersion = tt.minor - ServerMajorVersion = tt.major - if got := IsPSPSupported(); got != tt.want { - t.Errorf("IsPSPSupported() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/internal/controller/operator/vmagent_controller.go b/internal/controller/operator/vmagent_controller.go index e0719760..ae394318 100644 --- a/internal/controller/operator/vmagent_controller.go +++ b/internal/controller/operator/vmagent_controller.go @@ -66,7 +66,6 @@ type VMAgentReconciler struct { // +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;watch;list // +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=clusterrolebindings,verbs=get;create,update;list // +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=clusterroles,verbs=get;create,update;list -// +kubebuilder:rbac:groups="policy",resources=podsecuritypolicies,verbs=get;create,update;list // +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;create,update;list func (r *VMAgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) { reqLogger := r.Log.WithValues("vmagent", req.NamespacedName)