yaml
28 lines · 1 tab
Kai Nakamura
Apr 2026
1 tab
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-reader
namespace: production
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: metrics-reader
namespace: production
rules:
- apiGroups: ['']
resources: ['pods', 'services']
verbs: ['get', 'list', 'watch']
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: metrics-reader
namespace: production
subjects:
- kind: ServiceAccount
name: metrics-reader
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: metrics-reader
1 file · yaml
Explain with highlit
I avoid handing broad cluster access to workloads just because it is convenient during setup. Service accounts should have the minimum verbs and resources needed for the job, nothing more. Over-permissioned cluster identities make post-exploitation much easier than it needs to be.
Related snips
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
Least privilege IAM policy for an application on AWS
aws
iam
least-privilege
by Kai Nakamura
1 tab
ruby
require "timeout"
module HealthCheck
class Probe
Result = Struct.new(:name, :status, :latency_ms, :critical, :error, keyword_init: true) do
def healthy?
Health Check Endpoint with Dependency Probes
rails
reliability
health-check
by codesnips
3 tabs
javascript
// Express app with health checks and graceful shutdown
const express = require('express');
const { createServer } = require('http');
const app = express();
const server = createServer(app);
Container health checks and graceful shutdown patterns
docker
kubernetes
health-checks
by Ryan Nakamura
1 tab
yaml
# Headless Service for stable DNS
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: production
Kubernetes StatefulSets for stateful workloads
kubernetes
k8s
statefulsets
by Ryan Nakamura
1 tab
yaml
# === One-off Job: Database migration ===
apiVersion: batch/v1
kind: Job
metadata:
name: db-migrate
namespace: production
Kubernetes Jobs and CronJobs for batch workloads
kubernetes
cronjob
batch
by Ryan Nakamura
1 tab
yaml
# ClusterIP Service (internal only)
apiVersion: v1
kind: Service
metadata:
name: web-app
namespace: production
Kubernetes Services and Ingress for traffic routing
kubernetes
k8s
services
by Ryan Nakamura
2 tabs
Share this code
Here's the card — post it anywhere.