This issue can occur when the default AccessRole and AccessRoleBinding have either been modified in an overly restrictive manner or do not exist.
If you do not have another user with a different AccessRole/AccessRoleBinding associated you will need to modify the webhook to unblock yourself.
Note: As always, it is important to test this process in lower environments before attempting in production.
-
IMPORTANT: Backup the existing webhook config before proceeding
kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io kong-mesh-validating-webhook-configuration -oyaml > webhook.yaml
-
Delete the webhook
-
Re-create the AccessRole and/or AccessRoleBinding (depending on what is missing)
AccessRole
echo "
apiVersion: v1
items:
- apiVersion: kuma.io/v1alpha1
kind: AccessRole
metadata:
name: admin
spec:
rules:
- access:
- CREATE
- UPDATE
- DELETE
- GENERATE_DATAPLANE_TOKEN
- GENERATE_USER_TOKEN
- GENERATE_ZONE_CP_TOKEN
- GENERATE_ZONE_TOKEN
- VIEW_CONFIG_DUMP
- VIEW_STATS
- VIEW_CLUSTERS
kind: List
metadata:
resourceVersion: ''
" | kubectl apply -f -
AccessRoleBinding
echo "
apiVersion: v1
items:
- apiVersion: kuma.io/v1alpha1
kind: AccessRoleBinding
metadata:
name: default
spec:
roles:
- admin
subjects:
- name: mesh-system:authenticated
type: Group
- name: mesh-system:unauthenticated
type: Group
- name: system:authenticated
type: Group
- name: system:unauthenticated
type: Group
kind: List
metadata:
resourceVersion: ''
" | kubectl apply -f -
-
Re-create the webhook
kubectl apply -f webhook.yaml
-
Confirm you can now remove resources
kubectl delete mesh gruber
mesh.kuma.io "gruber" deleted