Kubernetes Security & RBAC
RBAC, ServiceAccounts, Pod Security Standards, NetworkPolicies, and certificate management
Secure your cluster: Role-Based Access Control (RBAC), ServiceAccounts, Pod Security Standards, NetworkPolicies, image security, and certificate management.
# RBAC - Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
# RBAC - RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
subjects:
- kind: ServiceAccount
name: default
namespace: default
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
# NetworkPolicy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
# Check permissions
kubectl auth can-i get pods --as system:serviceaccount:default:my-sa