Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)35k · #8067

implementing-kubernetes-pod-security-standards

Skill này làm gì

Công cụ này giúp bạn đặt và áp dụng quy tắc bảo mật cho các ứng dụng chạy trên Kubernetes. Nó đảm bảo ứng dụng tuân theo thực hành bảo mật tốt nhất bằng cách chọn một trong ba mức: “Privileged” (không hạn chế), “Baseline” (ngăn các rủi ro đã biết) và “Restricted” (an toàn nhất, nhiều hạn chế).

Khi nào nên dùng

  • ✓Khi quyết định áp dụng mức bảo mật nào cho một nhóm ứng dụng (namespace).
  • ✓Để kiểm tra ứng dụng nào có thể gặp vấn đề nếu áp dụng quy tắc chặt hơn.
  • ✓Khi lên kế hoạch cập nhật các quy tắc bảo mật cũ sang quy tắc mới.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-kubernetes-pod-security-standards/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-kubernetes-pod-security-standards/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi cần thay đổi gì ở một ứng dụng để nó có thể chạy với hồ sơ “Restricted”?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ dùng các thiết lập gọi là “Pod Security Standards” (PSS) áp dụng cho các nhóm ứng dụng (namespace). Các thiết lập này xác định những gì được phép hoặc bị cấm khi ứng dụng chạy, đảm bảo chúng không có quyền quá mức hoặc lỗ hổng đã biết.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Implementing Kubernetes Pod Security Standards

Overview

Pod Security Standards (PSS) define three levels of security policies -- Privileged, Baseline, and Restricted -- enforced by the Pod Security Admission (PSA) controller built into Kubernetes 1.25+. PSA replaces the deprecated PodSecurityPolicy and provides namespace-level enforcement with three modes: enforce, audit, and warn.

When to Use

  • Deciding whether a namespace or workload belongs at Privileged, Baseline, or Restricted
  • Auditing which existing workloads would be rejected if Restricted were enforced today
  • Translating a "must meet Restricted" requirement into concrete securityContext changes
  • Planning a PodSecurityPolicy migration and predicting what will break before it does
  • Mapping pod security posture to a compliance control (NIST PR.PS-01, CIS Kubernetes)

Not this skill: configuring the controller that enforces these profiles — namespace labels, AdmissionConfiguration, exemptions, or debugging a pod PSA rejected. Use implementing-pod-security-admission-controller.

Prerequisites

  • Kubernetes cluster 1.25+ (PSA GA)
  • kubectl configured with cluster-admin access
  • Understanding of Linux capabilities and security contexts

Core Concepts

Three Security Profiles

Profile Purpose Restrictions
Privileged Unrestricted, system workloads None
Baseline Prevents known escalations No hostNetwork, hostPID, hostIPC, privileged containers, dangerous capabilities
Restricted Hardened best practices Non-root, drop ALL caps, seccomp required, read-only rootfs recommended

Three Enforcement Modes

Mode Behavior
enforce Rejects pods that violate the policy
audit Logs violations in audit log but allows pod
warn Returns warning to user but allows pod

Workflow

Step 1: Label Namespaces for PSA

# Restricted namespace - production workloads
apiVersion: v1
kind: Namespace
metadata:
  name: production
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: latest
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/audit-version: latest
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: latest
# Baseline namespace - general workloads
apiVersion: v1
kind: Namespace
metadata:
  name: staging
  labels:
    pod-security.kubernetes.io/enforce: baseline
    pod-security.kubernetes.io/enforce-version: latest
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/audit-version: latest
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: latest
# Privileged namespace - system components only
apiVersion: v1
kind: Namespace
metadata:
  name: kube-system
  labels:
    pod-security.kubernetes.io/enforce: privileged
    pod-security.kubernetes.io/enforce-version: latest

Step 2: Apply Labels to Existing Namespaces

# Apply restricted enforcement to production
kubectl label namespace production \
  pod-security.kubernetes.io/enforce=restricted \
  pod-security.kubernetes.io/audit=restricted \
  pod-security.kubernetes.io/warn=restricted \
  --overwrite

# Apply baseline to staging with restricted warnings
kubectl label namespace staging \
  pod-security.kubernetes.io/enforce=baseline \
  pod-security.kubernetes.io/audit=restricted \
  pod-security.kubernetes.io/warn=restricted \
  --overwrite

# Check labels on all namespaces
kubectl get namespaces -L pod-security.kubernetes.io/enforce

Step 3: Create Compliant Pod Specs

# Restricted-compliant deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: secure-app
  namespace: production
spec:
  replicas: 3
  selector:
    matchLabels:
      app: secure-app
  template:
    metadata:
      labels:
        app: secure-app
    spec:
      automountServiceAccountToken: false
      securityContext:
        runAsNonRoot: true
        runAsUser: 65534
        runAsGroup: 65534
        fsGroup: 65534
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: app
          image: myregistry.com/myapp:v1.0.0@sha256:abc123
          ports:
            - containerPort: 8080
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false

…
Câu hỏi thường gặp

Các hồ sơ Privileged, Baseline và Restricted là gì?

Privileged không có hạn chế. Baseline ngăn ứng dụng gây ra các vấn đề bảo mật đã biết. Restricted là mức an toàn nhất, yêu cầu ứng dụng chạy không có đặc quyền thừa và với cấu hình an toàn hơn.

Làm sao biết ứng dụng của tôi có chạy được với quy tắc mới không?

Bạn có thể thử nghiệm quy tắc ở chế độ “audit” hoặc “warn” trước khi bắt buộc. Điều này cho bạn thấy ứng dụng nào vi phạm mà không chặn chúng, nhờ đó bạn có thời gian sửa.

“securityContext” là gì?

Đây là thiết lập trong Kubernetes xác định quyền và đặc điểm bảo mật của ứng dụng đang chạy, như có được chạy với quyền quản trị không, dùng những khả năng hệ thống nào, v.v.

Chi tiết

Mô tả gốc của tác giả

Chooses and applies the correct Kubernetes Pod Security Standard (Privileged, Baseline, Restricted) for a workload: what each profile forbids, how to map existing workloads to a profile, which securityContext fields must change, and how to plan a PodSecurityPolicy-to-PSS migration without breaking running pods. Use when deciding which pod security profile a namespace or workload should run under,

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#8067
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự