¿Por qué se muestra "Error from server (Forbidden)" cuando utilizo kubectl?
Síntoma
Cuando usa kubectl para crear o consultar recursos de Kubernetes, se devuelve el siguiente resultado:
# 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"
Causa posible
Este usuario no tiene permisos para utilizar los recursos de Kubernetes.
Solución
Asigne permisos al usuario.
- Log in to the CCE console. In the navigation pane, choose Permissions.
- Select a cluster for which you want to add permissions from the drop-down list on the right.
- Click Add Permissions in the upper right corner.
- 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.
If you do not have IAM permissions, you cannot select users or user groups when configuring permissions for other users or user groups. In this case, you can enter a user ID or user group ID.
Figura 1 Configuring namespace permissions
Permissions can be customized as required. After selecting Custom for Permission Type, click Add Custom Role on the right of the Custom parameter. In the dialog box displayed, enter a name and select a rule. After the custom rule is created, you can select a value from the Custom drop-down list box.
Figura 2 Custom permission
- Click Create.