Permissions and policies
Inside your namespace you have a lot of freedom, but not unlimited freedom. Two mechanisms draw the line, and they announce themselves differently:
- RBAC decides which resources you may touch at all. A violation ends in
Forbidden. - Platform rules decide whether a specific manifest is accepted. A violation ends with your
kubectl applybeing rejected.
What RBAC grants
"Full" below means get, list, watch, create, update, patch and delete. Where a row says something narrower, that is the whole grant.
| API group | Resources | Access |
|---|---|---|
apps | deployments, statefulsets, replicasets | Full |
apps | deployments/scale, statefulsets/scale | get, update, patch |
"" (core, objects) | services, configmaps, secrets, serviceaccounts, persistentvolumeclaims | Full |
"" (core, runtime) | pods, pods/log, pods/exec, pods/attach, pods/portforward, events | Full |
"" (core, quotas) | resourcequotas, limitranges | Read-only |
"" (core, endpoints) | endpoints | Read-only |
discovery.k8s.io | endpointslices | Read-only |
coordination.k8s.io | leases | Full |
events.k8s.io | events | Read-only |
batch | jobs, cronjobs | Full |
autoscaling | horizontalpodautoscalers | Full |
autoscaling.k8s.io | verticalpodautoscalers | Full |
policy | poddisruptionbudgets | Full |
gateway.networking.k8s.io | httproutes, grpcroutes | Full |
gateway.nginx.org | clientsettingspolicies | Full |
postgresql.cnpg.io | clusters, backups, scheduledbackups, poolers, databases, publications, subscriptions, imagecatalogs | Full |
barmancloud.cnpg.io | objectstores | Full |
k8s.mariadb.com | mariadbs, databases, users, grants, connections, backups, restores, sqljobs, maxscales | Full |
dragonflydb.io | dragonflies | Full |
keda.sh | scaledobjects, scaledjobs, triggerauthentications | Full |
metrics.k8s.io | pods | get, list |
All of it applies inside your namespace only.
Three consequences of the read-only rows are worth stating outright:
- You cannot change your own quota. You can read it, which is what
kubectl get resourcequotaandkubectl describe resourcequotaare for, but raising it is a plan change, see Billing and quotas. - You cannot change the namespace defaults applied to containers that declare no resources.
- You cannot write endpoints yourself. A Service with a selector gets them automatically, a Service without one has no backends.
Leases are there for leader election and locks. Every PostgreSQL cluster in your namespace keeps one named after itself, which the database relies on, so pick a different name for your own. A pod gets this access only when it runs as your namespace's service account, see Networking.
This table describes what you can do with kubectl. If you deploy by pointing your namespace at a Git repository instead, a few kinds are not accepted through that route even though they appear here, currently vertical pod autoscalers, client settings policies and leases.
Everything else is denied
Anything not in the table is not allowed. That notably covers nodes, namespaces, cluster roles and CRD management. Those commands end in Forbidden, see Access and kubectl.
You cannot list the storage classes
kubectl get storageclass is denied as well, so you cannot discover the available classes from inside the cluster. There are two, and they are named and described under Storage.
Platform rules
On top of RBAC, the platform checks every manifest against a fixed set of rules. They are hard rules: a manifest that breaks one is rejected.
| Rule | What to do instead |
|---|---|
A pod may only use configMap, downwardAPI, emptyDir, ephemeral, persistentVolumeClaim, projected and secret volumes | Request any other storage through a PersistentVolumeClaim |
Services of type NodePort, LoadBalancer and ExternalName are not accepted, and neither is spec.externalIPs | Stay on ClusterIP and publish through an HTTPRoute |
You cannot write Certificate resources yourself | Let the certificate come from the annotation on your HTTPRoute |
| An HTTPRoute must declare at least one hostname | A route with none would attach as a catch-all on the shared gateway |
| Hostnames must be under your namespace subdomain, or added to your namespace in the portal | See Gateway API |
| A pod may not choose its own node, may not tolerate the taint of nodes reserved for the platform, and may not carry a toleration that matches everything | Let the scheduler place it. A blanket operator: Exists toleration without a key counts, so do not copy one in. The refusal begins Tenant pods may not tolerate the 'ci' taint |
A PodDisruptionBudget must select its pods with matchLabels, set maxUnavailable to at least 1 and leave minAvailable unset | Run at least two replicas and let one of them be disrupted, see node maintenance |
| No two PodDisruptionBudgets in a namespace may be able to cover the same pod | Give every budget a matchLabels key that the others also use, with a different value |
A PodDisruptionBudget selector may use at most 8 matchLabels, and at most 4 matchExpressions with at most 8 values each | Select with fewer labels. One matchLabels key that names the workload is usually enough |
| A namespace may hold at most 20 PodDisruptionBudgets, counting the ones operators create for you | Cover each workload with one budget and remove the ones you no longer need |
The disruption budget of a Dragonfly (spec.pdb), MariaDB or MaxScale (spec.podDisruptionBudget) must set maxUnavailable to at least 1 and leave minAvailable unset | See node maintenance |
A pod may not carry the karpenter.sh/do-not-disrupt annotation | Protect it with a PodDisruptionBudget, see node maintenance |
A pod may not tolerate the control-plane taint or the taints of a node under maintenance; node.kubernetes.io/not-ready and node.kubernetes.io/unreachable only with effect: NoExecute | Remove the toleration, see node maintenance |
A pod may not name a priority class other than tenant-default. One that does is refused with the integer value of priority (500000) must not be provided in pod spec; priority admission controller computed 100 from the given PriorityClass name, the number varying with the class | Leave priorityClassName out: the right one is applied for you |
A route may not set or add the X-Real-IP, X-Forwarded-For or Forwarded request headers | Leave them out: the gateway sets the client address, see Gateway API |
A pod may have at most 16 containers and init containers, 32 tolerations, 16 nodeSelector entries, 128 volumes and 8 request and limit entries per container, with image references of at most 512 characters. Some other objects have similar bounds | Stay within them. The refusal names the bound, see The API said no |
A ClientSettingsPolicy may not raise the request body size above 512 MiB, or set it to zero | Set an explicit size within that bound |
| The HTTP scale-to-zero resources are managed for you | Use the itsh.dev/scale-to-zero annotation, see Autoscaling |
On the free tier, nfs-rwx is the only permitted storage class | See Free tier |
A PostgreSQL Cluster may only run images from ghcr.io/cloudnative-pg/. The Cluster is accepted, but its pods are refused | Leave imageName out or pick an image from there, see Databases |
A route on an itsh-apps.dev hostname may not set, add or remove X-Robots-Tag | Leave the header out: it is always noindex, nofollow there, see Free tier |
Sandboxed runtime
Your workloads run in a sandboxed runtime. It is applied automatically and you cannot opt out, and for your own workloads there is nothing to notice: it is set for you even if you say nothing.
It surfaces in one place. Managed PostgreSQL pods are the exception to it, and because kubectl exec is only permitted into sandboxed pods, you cannot get a shell in one. See Databases.
Inline volumes: use a PVC
Volume types defined directly in the pod are rejected, apart from configMap, downwardAPI, emptyDir, ephemeral, persistentVolumeClaim, projected and secret. That explicitly includes an nfs volume in the pod spec:
# Rejected
spec:
volumes:
- name: data
nfs:
server: nfs.example.com
path: /export/dataIf you need shared storage, request it through a PVC on the nfs-rwx class, see Storage:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
spec:
accessModes:
- ReadWriteMany
storageClassName: nfs-rwx
resources:
requests:
storage: 1GiNo NodePort, no LoadBalancer
The way out is exclusively an HTTPRoute on the shared gateway, see Gateway API. A service with type: LoadBalancer or type: NodePort is rejected; ClusterIP is the type you want.
Certificates come from the route
Creating a Certificate resource yourself is rejected. TLS comes from the cert-manager.io/cluster-issuer annotation on your HTTPRoute, without you doing anything else.
Disruption budgets and node maintenance
Your pods are moved off a node through the eviction API, so PodDisruptionBudgets apply. That happens for two reasons:
- Replacement for updates. Every node is replaced about once a week so it runs current security updates. Replacement normally starts between 22:00 and 02:45 UTC. If a budget keeps a pod on its node, that node is replaced separately, at any time of day: a pod still on it after 15 minutes, because its budget allows no disruption or because it is still shutting down, is deleted with at most one more minute to stop. Without that limit, a budget with a pod that never becomes ready would keep its node from ever being patched.
- Repacking. Between 18:00 and 02:45 and between 07:15 and 10:00 UTC, pods are also moved so that they fit onto fewer or cheaper nodes. Repacking never starts on a node with a pod its budget holds.
To get through both without an interruption, run at least two replicas, label their pods, and set the budget so that one of them may be disrupted:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: web
template:
metadata:
labels:
app.kubernetes.io/name: web
spec:
containers:
- name: web
image: registry.example.com/web:1.0.0
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: webThe platform sets unhealthyPodEvictionPolicy: AlwaysAllow on every budget you create, so a pod that is not ready can always be moved. An accepted budget can still hold a node for a while: as long as one of its pods is not ready, the others stay where they are.
Each pod should be covered by one budget only. A pod covered by two budgets blocks node replacement, so two budgets in a namespace are accepted only when a matchLabels key appears in both with different values. matchExpressions do not count for this. If a running pod still ends up covered by two budgets, for example because both were created at the same moment, the platform keeps only the most recently created budget and deletes the others. It checks for this every ten minutes. The examples on this site all use app.kubernetes.io/name, so they can sit side by side in one namespace.
A budget is the supported way to protect a workload during maintenance. These are rejected:
- A PodDisruptionBudget that does not select its pods with
matchLabels, or whosematchLabelsare empty (an empty selector covers every pod in the namespace). - A PodDisruptionBudget that sets
minAvailable, sets nomaxUnavailable, or setsmaxUnavailableto zero (0or0%). - A PodDisruptionBudget that can cover the same pods as another budget in the namespace, as described above.
- A PodDisruptionBudget whose selector uses more than 8
matchLabels, more than 4matchExpressions, or more than 8 values in one expression. - A new PodDisruptionBudget in a namespace that already holds 20. Budgets that operators create for your databases count toward the limit too. A
MariaDBorMaxScalewhose budget cannot be created showsexceeded quotain its Ready condition; aDragonflyshows no message, so check the count before adding one. - The disruption budget of a
Dragonfly(spec.pdb) or of aMariaDBorMaxScale(spec.podDisruptionBudget), when it setsminAvailable, sets nomaxUnavailable, or setsmaxUnavailableto zero. - The
karpenter.sh/do-not-disruptannotation, on a pod or in the pod template of a Deployment, StatefulSet, Job or CronJob. - Tolerations for the taints that keep pods off the control-plane nodes and off nodes that are under maintenance, still starting up or under resource pressure:
node-role.kubernetes.io/control-plane,node-role.kubernetes.io/master,node.kubernetes.io/unschedulable,karpenter.sh/disrupted,itsh.dev/rotation-avoid,karpenter.sh/unregistered,node.cloudprovider.kubernetes.io/uninitialized,node.cilium.io/agent-not-ready,node.kubernetes.io/network-unavailable,node.kubernetes.io/memory-pressure,node.kubernetes.io/disk-pressureandnode.kubernetes.io/pid-pressure.node.kubernetes.io/not-readyandnode.kubernetes.io/unreachableare permitted only witheffect: NoExecute, the form Kubernetes adds to every pod on its own.
The last two rules also cover the resources an operator turns into pods for you: a PostgreSQL Cluster or Pooler, a Dragonfly, a MariaDB or MaxScale, a MariaDB Backup, Restore or SqlJob, and a ScaledJob. Their tolerations and pod metadata are checked when you apply them, not when the pods start. A nodeName in the pod template of a Pooler or ScaledJob is rejected at that point too.
What a rejection looks like
When a manifest breaks one of the rules, kubectl apply usually answers in this shape; the size bounds answer in a second one, shown under The API said no:
Error from server: error when creating "app.yaml": admission webhook "<webhook>" denied the request:
resource <Kind>/<your-namespace>/<name> was blocked due to the following policies
<policy>:
<rule>: <the rule that fired, and why>Two real examples are on Gateway API, for a hostname that is not yours, and on Databases, for exec into a PostgreSQL pod.
The exact wording depends on the rule. What matters is the difference from a syntax error: denied the request means your YAML is fine and a rule fired. There is nothing to fix in the manifest, you need a different approach, and the reason that follows tells you which rule it was.
What's next
- The API said no if something was refused
- Gateway API for the hostname rules in full