diff --git a/config/operator/rbac/role.yaml b/config/operator/rbac/role.yaml index 77a32d2a..c7a58178 100644 --- a/config/operator/rbac/role.yaml +++ b/config/operator/rbac/role.yaml @@ -12,18 +12,6 @@ rules: - get - list - watch -- apiGroups: - - "" - resources: - - persistentvolumeclaims - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - "" resources: diff --git a/pkg/operator/controller/instance_controller.go b/pkg/operator/controller/instance_controller.go index 617019ba..3faa0c91 100644 --- a/pkg/operator/controller/instance_controller.go +++ b/pkg/operator/controller/instance_controller.go @@ -16,7 +16,6 @@ package controller import ( "context" "fmt" - "path/filepath" "reflect" "time" @@ -24,7 +23,6 @@ import ( corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -67,7 +65,6 @@ type InstanceReconciler struct { // +kubebuilder:rbac:groups=clusterlink.net,resources=instances,verbs=list;get;watch;update;patch // +kubebuilder:rbac:groups=clusterlink.net,resources=instances/status,verbs=get;update;patch // +kubebuilder:rbac:groups=clusterlink.net,resources=instances/finalizers,verbs=update -// +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=list;get;watch;create;update;patch;delete // +kubebuilder:rbac:groups="",resources=services;serviceaccounts,verbs=list;get;watch;create;update;patch;delete // +kubebuilder:rbac:groups="",resources=nodes,verbs=list;get;watch // +kubebuilder:rbac:groups="",resources=pods,verbs=list;get;watch @@ -190,10 +187,6 @@ func (r *InstanceReconciler) applyClusterLink(ctx context.Context, instance *clu instance.Spec.ContainerRegistry += "/" } // Create controlplane components - if err := r.createPVC(ctx, ControlPlaneName, instance.Spec.Namespace); err != nil { - return err - } - if err := r.createAccessControl(ctx, ControlPlaneName, instance.Spec.Namespace); err != nil { return err } @@ -241,14 +234,6 @@ func (r *InstanceReconciler) applyControlplane(ctx context.Context, instance *cl }, }, }, - { - Name: ControlPlaneName, - VolumeSource: corev1.VolumeSource{ - PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ - ClaimName: ControlPlaneName, - }, - }, - }, }, Containers: []corev1.Container{ { @@ -280,10 +265,6 @@ func (r *InstanceReconciler) applyControlplane(ctx context.Context, instance *cl SubPath: "key", ReadOnly: true, }, - { - Name: ControlPlaneName, - MountPath: filepath.Dir(cpapp.StoreFile), - }, }, Env: []corev1.EnvVar{ { @@ -408,27 +389,6 @@ func (r *InstanceReconciler) createService(ctx context.Context, name, namespace return r.createResource(ctx, service) } -// createPVC sets up k8s a persistent volume claim for the. -func (r *InstanceReconciler) createPVC(ctx context.Context, name, namespace string) error { - // Create the PVC for cl-controlplane - controlplanePVC := &corev1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - }, - Spec: corev1.PersistentVolumeClaimSpec{ - AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, - Resources: corev1.VolumeResourceRequirements{ - Requests: corev1.ResourceList{ - corev1.ResourceStorage: resource.MustParse("100Mi"), - }, - }, - }, - } - - return r.createResource(ctx, controlplanePVC) -} - // createAccessControl sets up k8s ClusterRule and ClusterRoleBinding for the controlplane. func (r *InstanceReconciler) createAccessControl(ctx context.Context, name, namespace string) error { // Create ServiceAccount object @@ -607,10 +567,6 @@ func (r *InstanceReconciler) deleteClusterLink(ctx context.Context, namespace st return err } - if err := r.deleteResource(ctx, &corev1.PersistentVolumeClaim{ObjectMeta: cpObj}); err != nil { - return err - } - if err := r.deleteResource(ctx, &rbacv1.ClusterRole{ObjectMeta: cpObj}); err != nil { return err } diff --git a/pkg/operator/controller/instance_controller_test.go b/pkg/operator/controller/instance_controller_test.go index 534b20b6..87b160a6 100644 --- a/pkg/operator/controller/instance_controller_test.go +++ b/pkg/operator/controller/instance_controller_test.go @@ -143,7 +143,7 @@ func TestClusterLinkController(t *testing.T) { } cpID := types.NamespacedName{Name: controller.ControlPlaneName, Namespace: controller.InstanceNamespace} - cpResource := []client.Object{&appsv1.Deployment{}, &corev1.Service{}, &corev1.PersistentVolumeClaim{}} + cpResource := []client.Object{&appsv1.Deployment{}, &corev1.Service{}} roleID := types.NamespacedName{ Name: controller.ControlPlaneName + controller.InstanceNamespace, Namespace: controller.InstanceNamespace,