Use when implementing Kubernetes security best practices including RBAC, pod security policies, and network policies.
View on GitHubTheBushidoCollective/han
jutsu-kubernetes
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-kubernetes/skills/kubernetes-security/SKILL.md -a claude-code --skill kubernetes-securityInstallation paths:
.claude/skills/kubernetes-security/# Kubernetes Security
Security best practices for Kubernetes deployments.
## Pod Security
### Run as Non-Root
```yaml
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 1000
```
### Read-Only Root Filesystem
```yaml
spec:
containers:
- name: app
securityContext:
readOnlyRootFilesystem: true
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
```
### Drop Capabilities
```yaml
spec:
containers:
- name: app
securityContext:
capabilities:
drop:
- ALL
add:
- NET_BIND_SERVICE
```
### Prevent Privilege Escalation
```yaml
spec:
containers:
- name: app
securityContext:
allowPrivilegeEscalation: false
privileged: false
```
## Network Security
### Network Policies
```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: api-allow
spec:
podSelector:
matchLabels:
app: api
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: frontend
ports:
- protocol: TCP
port: 8080
egress:
- to:
- podSelector:
matchLabels:
app: database
ports:
- protocol: TCP
port: 5432
```
## RBAC
### ServiceAccount
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: app-sa
namespace: default
```
### Role
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list"]
```
### RoleBinding
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
subjects:
- kind: ServiceAccount
name: app-sa
namespace: default
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
```
## Secrets Management
### Encrypt at Rest
Enable encryption for secrets at rest in etcd.
### External Secrets
Use external secret management:
```yaml
a