I’m trying to use Encrypted Volume feature in Portworx enterprise with OpenShift Container Platform v4.6.16. Anyone can help to take a look at this problem? or any advice ?
thanks . it think your OCP cluster missing this permissions as per our docs page. 1. Prepare your platform
Mainly it might be missing this portworx-pvc-controller-account permission as per above posted error message. apply below commands and recreate your pods again with encrypted pvc. and keep me post the out come.
Add the Portworx service accounts to the privileged security context
Portworx runs as a privileged container. Hence you need to add the Portworx service accounts to the privileged security context.
I have ran those command in my environment, but I still run into same problem. Have you any other advice?
BTW: I don’t have seen those service account in my env.
# oc get sa px-account -n kube-system
Error from server (NotFound): serviceaccounts "px-account" not found
# oc get sa portworx-pvc-controller-account -n kube-system
Error from server (NotFound): serviceaccounts "portworx-pvc-controller-account" not found
# oc get sa px-lh-account -n kube-system
Error from server (NotFound): serviceaccounts "px-lh-account" not found
# oc get sa default -n default
NAME SECRETS AGE
default 2 19h
# oc get sa px-csi-account -n kube-system
Error from server (NotFound): serviceaccounts "px-csi-account" not found
# oc get sa -n kube-system | egrep -E 'px|portworx'
portworx 2 3h9m
portworx-operator 2 3h10m
Assuming the page in Encrypting PVCs using annotations with Kubernetes Secrets has misleading information in Step 1: Create cluster wide secret key in which the cluster wide secret key will be created in portworx namespace. It is key point that why I received the error message after deploy PVC.
I tried to create the cluster wide secret key in kube-system namespace in which StorageCluster object was also created. After deploy new PVC, the PVC can be created successfully.
@sensre would you help to confirm which one is correct step for create cluster wide secret key? If my assuming is correct, I think the topic can be closed.
By default, Portworx has permissions to read secrets under portworx namespace. If your secrets are stored in some other namespace, then you need to give Portworx permissions to read the secrets. To grant Portworx permission to read vol-secrets secret, under the example namespace, do the following:
cat <<EOF | kubectl apply -f -
# Role to access 'vol-secrets' secret under 'example' namespace
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: px-vol-enc-role
namespace: example
rules:
- apiGroups: [""]
verbs: ["get"]
resources: ["secrets"]
resourceNames: ["vol-secrets"]
---
# Allow portworx service account to access the secret
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: px-vol-enc-role-binding
namespace: example
subjects:
- kind: ServiceAccount
name: px-account
namespace: kube-system
roleRef:
kind: Role
name: px-vol-enc-role
apiGroup: rbac.authorization.k8s.io
EOF```
I tried Marc_Pango solution and it worked.
I also tried yours and it still not work until I did what Marc_Pango has suggested.
One thing not very clear to me is that who created that Portworx namespace. When I installed the operator, I don’t see that as prerequisite?