Security Quiz
Quiz
automountServiceAccountToken: false in a ServiceAccount or Pod spec prevents automatic token mounting, reducing credential exposure risk.automountServiceAccountToken: false in a ServiceAccount or Pod spec prevents automatic token mounting, reducing credential exposure risk.kubectl auth can-i create pods --as=system:serviceaccount:default:my-sakubectl auth can-i command with --as flag simulates permission checking for a specific user or service account without actually performing the action.kubectl auth can-i command with --as flag simulates permission checking for a specific user or service account without actually performing the action.Role: Namespace-scoped - permissions apply only within a single namespace.
ClusterRole: Cluster-scoped - permissions apply across the entire cluster.
Hybrid use: A ClusterRole can be bound with a RoleBinding to reuse cluster-defined roles in specific namespaces.
Did you get it right?
capabilities:
drop:
- _____drop: [ALL] removes all Linux capabilities from the container. You can then selectively add back only the capabilities needed using the add field.drop: [ALL] removes all Linux capabilities from the container. You can then selectively add back only the capabilities needed using the add field.seccompProfile field in a Pod’s security context?IRSA (IAM Roles for Service Accounts) allows Kubernetes ServiceAccounts to assume AWS IAM roles.
Benefits:
- Separate IAM role per service account
- Fine-grained AWS permissions
- Automatic credential rotation
- No hardcoded AWS secrets in pods
Pods annotated with eks.amazonaws.com/role-arn automatically receive temporary AWS credentials.
Did you get it right?
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restrictedreadOnlyRootFilesystem: true means the container cannot write to any filesystem location.WHO: Subjects - User, Group, or ServiceAccount
WHAT: Verbs - get, list, create, delete, update, patch, watch, etc.
WHICH: Resources - pods, services, deployments, secrets, etc.
WHERE: Scope - Namespace-scoped (Role) or Cluster-wide (ClusterRole)
RoleBindings connect WHO to WHAT+WHICH+WHERE by linking subjects to roles.
Did you get it right?
securityContext:
_____: 1000
runAsNonRoot: truerunAsUser field specifies the UID to run the container process. Combined with runAsNonRoot: true, it ensures the container runs as a non-root user.runAsUser field specifies the UID to run the container process. Combined with runAsNonRoot: true, it ensures the container runs as a non-root user.