Chuyển đến nội dung
Skillpedia
Bảo mật35k · #8097

implementing-pod-security-admission-controller

Skill này làm gì

Tính năng này giúp cấu hình và quản lý bộ kiểm soát Pod Security Admission (PSA) của Kubernetes. Nó bảo đảm ứng dụng của bạn chạy an toàn theo các tiêu chuẩn đã định.

Khi nào nên dùng

  • ✓Khi lần đầu thiết lập bảo mật pod trên một cụm Kubernetes.
  • ✓Khi muốn đặt quy tắc bảo mật mặc định cho toàn bộ cụm.
  • ✓Khi cần kiểm tra vì sao một pod bị chặn hoặc vì sao bảo mật không hoạt động như mong đợi.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-pod-security-admission-controller/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-pod-security-admission-controller/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

“Làm thế nào để đặt mức bảo mật “restricted” cho namespace “production”?”

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

Cách hoạt động

Bạn định nghĩa quy tắc bảo mật bằng cách gắn nhãn cụ thể cho namespace hoặc cấu hình một tệp trung tâm cho toàn bộ cụm. Điều này cho Kubernetes biết mỗi namespace phải tuân theo tiêu chuẩn bảo mật nào.

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 Pod Security Admission Controller

Overview

Pod Security Admission (PSA) is a built-in Kubernetes admission controller (stable since v1.25) that enforces Pod Security Standards at the namespace level. It replaces the deprecated PodSecurityPolicy (PSP) and provides three security profiles: Privileged, Baseline, and Restricted, with three enforcement modes: enforce, audit, and warn.

When to Use

  • Wiring PSA up on a cluster for the first time
  • Setting cluster-wide default enforcement via AdmissionConfiguration
  • Exempting system namespaces, service accounts, or runtime classes from enforcement
  • Debugging why a pod was rejected, or why enforcement is silently not firing
  • Staging a safe rollout: warn and audit first, enforce once violations reach zero
  • Pulling PSA violations out of the kube-apiserver audit log

Not this skill: deciding which profile a workload should run under, or what securityContext changes Restricted demands. Use implementing-kubernetes-pod-security-standards.

Prerequisites

  • Kubernetes v1.25+ (PSA is stable/GA)
  • kubectl with cluster-admin access
  • No dependency on external tools - PSA is built into kube-apiserver

Pod Security Standards

Privileged Profile

  • Unrestricted - No restrictions applied
  • Use case: System-level pods (kube-system, monitoring)

Baseline Profile

  • Minimally restrictive - Prevents known privilege escalation
  • Blocks: privileged containers, hostPID, hostIPC, hostNetwork, hostPorts, certain volume types, adding capabilities beyond runtime defaults

Restricted Profile

  • Heavily restricted - Follows security best practices
  • Requires: non-root, drop ALL capabilities, seccomp RuntimeDefault, read-only root filesystem considerations
  • Blocks: Everything in Baseline plus running as root, privilege escalation, non-approved volume types

Enforcement Modes

Mode Behavior Use Case
enforce Reject pods violating policy Production enforcement
audit Log violations to audit log Pre-enforcement assessment
warn Show warnings to user Developer feedback

Implementation

Apply to Namespace via Labels

# Restricted enforcement with audit and warn
apiVersion: v1
kind: Namespace
metadata:
  name: production
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: v1.28
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/audit-version: v1.28
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: v1.28
# Baseline enforcement for staging
apiVersion: v1
kind: Namespace
metadata:
  name: staging
  labels:
    pod-security.kubernetes.io/enforce: baseline
    pod-security.kubernetes.io/enforce-version: v1.28
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/audit-version: v1.28
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: v1.28
# Privileged for system namespaces
apiVersion: v1
kind: Namespace
metadata:
  name: kube-system
  labels:
    pod-security.kubernetes.io/enforce: privileged

Apply Labels with kubectl

# Set restricted enforcement
kubectl label namespace production \
  pod-security.kubernetes.io/enforce=restricted \
  pod-security.kubernetes.io/enforce-version=v1.28 \
  pod-security.kubernetes.io/audit=restricted \
  pod-security.kubernetes.io/warn=restricted

# Set baseline enforcement
kubectl label namespace staging \
  pod-security.kubernetes.io/enforce=baseline \
  pod-security.kubernetes.io/audit=restricted \
  pod-security.kubernetes.io/warn=restricted

# Check current labels
kubectl get namespace production -o jsonpath='{.metadata.labels}' | jq .

Dry-Run Testing

# Test what would happen with restricted policy on a namespace
kubectl label --dry-run=server --overwrite namespace staging \
  pod-security.kubernetes.io/enforce=restricted

# Output shows existing pods that would violate the policy
# Warning: existing pods in namespace "staging" violate the new PodSecurity enforce level "restricted:latest"

Cluster-Wide Defaults (AdmissionConfiguration)

# /etc/kubernetes/psa-config.yaml
apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
  - name: PodSecurity
    configuration:
      apiVersion: pod-security.admission.config.k8s.io/v1

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

Có những mức bảo mật nào?

Có ba mức: “Privileged” (không hạn chế), “Baseline” (hạn chế tối thiểu) và “Restricted” (hạn chế cao, theo các thực hành tốt nhất).

Các chế độ thực thi là gì?

Gồm “enforce” (chặn pod vi phạm), “audit” (ghi nhật ký vi phạm) và “warn” (cảnh báo người dùng về vi phạm).

Tôi có cần cài thêm gì không?

Không. Bộ kiểm soát Pod Security Admission (PSA) đã được tích hợp sẵn trong các phiên bản Kubernetes gần đây (v1.25 trở lên).

Chi tiết

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

Configures and operates the Kubernetes Pod Security Admission (PSA) controller that enforces Pod Security Standards: namespace enforce/audit/warn labels, cluster-wide defaults via AdmissionConfiguration, exemptions for usernames, runtime classes and namespaces, version pinning, and troubleshooting pods the controller rejected. Use when wiring PSA up on a cluster, setting cluster-wide default enfor

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#8097
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ự