Why Is "Error from server (Forbidden)" Displayed When I Use kubectl?
Symptom
When you use kubectl to create or query Kubernetes resources, the following output is returned:
# kubectl get deploy Error from server (Forbidden): deployments.apps is forbidden: User "0c97ac3cb280f4d91fa7c0096739e1f8" cannot list resource "deployments" in API group "apps" in the namespace "default"
Possible Cause
This user has no permissions to operate Kubernetes resources.
Solution
Assign permissions to the user.
- Log in to the CCE console. In the navigation pane, choose Permissions Management.
- On the displayed page, click the Namespace-Level Permissions tab. In the upper right corner of the namespace permissions list, select the cluster that contains the namespace whose access will be managed, and click Add Permissions.
- Confirm the cluster name and select the namespace to assign permissions for. For example, select All namespaces, the target user or user group, and select the permissions, as shown in the following figure.. Figure 1 Configuring namespace permissions
- Click Create.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.