Skip to content

Commit 533a08b

Browse files
authored
Merge pull request #40542 from kmuto/tutorials/security/ns-level-pss
[ja] add Japanese translation for /docs/tutorials/security/ns-level-pss
2 parents 31bb79f + 52ef5de commit 533a08b

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "セキュリティ"
3+
weight: 40
4+
---
5+
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
title: 名前空間レベルでのPodセキュリティの標準の適用
3+
content_type: チュートリアル
4+
weight: 20
5+
---
6+
7+
{{% alert title="Note" %}}
8+
このチュートリアルは、新しいクラスターにのみ適用されます。
9+
{{% /alert %}}
10+
11+
Podセキュリティアドミッション(PSA)は、[ベータへ進み](/blog/2021/12/09/pod-security-admission-beta/)、v1.23以降でデフォルトで有効になっています。
12+
Podセキュリティアドミッションは、Podが作成される際に、[Podセキュリティの標準](/ja/docs/concepts/security/pod-security-standards/)の適用の認可を制御するものです。
13+
このチュートリアルでは、一度に1つの名前空間で`baseline` Podセキュリティ標準を強制します。
14+
15+
Podセキュリティの標準を複数の名前空間に一度にクラスターレベルで適用することもできます。やり方については[クラスターレベルでのPodセキュリティの標準の適用](/docs/tutorials/security/cluster-level-pss/)を参照してください。
16+
17+
## {{% heading "prerequisites" %}}
18+
19+
ワークステーションに以下をインストールしてください:
20+
21+
- [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
22+
- [kubectl](/ja/docs/tasks/tools/)
23+
24+
## クラスターの作成
25+
26+
1. 以下のように`KinD`クラスターを作成します。
27+
28+
```shell
29+
kind create cluster --name psa-ns-level
30+
```
31+
32+
出力は次のようになります:
33+
34+
```
35+
Creating cluster "psa-ns-level" ...
36+
✓ Ensuring node image (kindest/node:v{{< skew currentPatchVersion >}}) 🖼
37+
✓ Preparing nodes 📦
38+
✓ Writing configuration 📜
39+
✓ Starting control-plane 🕹️
40+
✓ Installing CNI 🔌
41+
✓ Installing StorageClass 💾
42+
Set kubectl context to "kind-psa-ns-level"
43+
You can now use your cluster with:
44+
45+
kubectl cluster-info --context kind-psa-ns-level
46+
47+
Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/
48+
```
49+
50+
1. kubectl のコンテキストを新しいクラスターにセットします:
51+
52+
```shell
53+
kubectl cluster-info --context kind-psa-ns-level
54+
```
55+
出力は次のようになります:
56+
57+
```
58+
Kubernetes control plane is running at https://127.0.0.1:50996
59+
CoreDNS is running at https://127.0.0.1:50996/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
60+
61+
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
62+
```
63+
64+
## 名前空間の作成
65+
66+
`example`と呼ぶ新しい名前空間を作成します:
67+
68+
```shell
69+
kubectl create ns example
70+
```
71+
72+
出力は次のようになります:
73+
74+
```
75+
namespace/example created
76+
```
77+
78+
## 名前空間へのPodセキュリティの標準チェックの有効化
79+
80+
1. ビルトインのPod Security Admissionでサポートされているラベルを使って、この名前空間のPodセキュリティの標準を有効にします。
81+
このステップでは、_baseline_ Podセキュリティの標準の最新バージョンに合わないPodについて警告するチェックを設定します。
82+
83+
```shell
84+
kubectl label --overwrite ns example \
85+
pod-security.kubernetes.io/warn=baseline \
86+
pod-security.kubernetes.io/warn-version=latest
87+
```
88+
89+
2. ラベルを使って、任意の名前空間に対して複数のPodセキュリティの標準チェックを設定できます。
90+
以下のコマンドは、`baseline` Podセキュリティの標準を`enforce`(強制)としますが、`restricted` Podセキュリティの標準には最新バージョンに準じて`warn`(警告)および`audit`(監査)とします(デフォルト値)。
91+
92+
```shell
93+
kubectl label --overwrite ns example \
94+
pod-security.kubernetes.io/enforce=baseline \
95+
pod-security.kubernetes.io/enforce-version=latest \
96+
pod-security.kubernetes.io/warn=restricted \
97+
pod-security.kubernetes.io/warn-version=latest \
98+
pod-security.kubernetes.io/audit=restricted \
99+
pod-security.kubernetes.io/audit-version=latest
100+
```
101+
102+
## Podセキュリティの標準の強制の実証
103+
104+
1. `example`名前空間内に`baseline` Podを作成します:
105+
106+
```shell
107+
kubectl apply -n example -f https://k8s.io/examples/security/example-baseline-pod.yaml
108+
```
109+
Podは正常に起動しますが、出力には警告が含まれています。例えば:
110+
111+
```
112+
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
113+
pod/nginx created
114+
```
115+
116+
1. `default`名前空間内に`baseline` Podを作成します:
117+
118+
```shell
119+
kubectl apply -n default -f https://k8s.io/examples/security/example-baseline-pod.yaml
120+
```
121+
出力は次のようになります:
122+
123+
```
124+
pod/nginx created
125+
```
126+
127+
`example`名前空間にだけ、Podセキュリティの標準のenforceと警告の設定が適用されました。
128+
`default`名前空間内では、警告なしに同じPodを作成できました。
129+
130+
## 後片付け
131+
132+
では、上記で作成したクラスターを、以下のコマンドを実行して削除します:
133+
134+
```shell
135+
kind delete cluster --name psa-ns-level
136+
```
137+
138+
## {{% heading "whatsnext" %}}
139+
140+
- 前出の一連の手順を一度に全て行うために[シェルスクリプト](/examples/security/kind-with-namespace-level-baseline-pod-security.sh)を実行します。
141+
142+
1. KinDクラスターを作成します。
143+
2. 新しい名前空間を作成します。
144+
3. `enforce`モードでは`baseline` Podセキュリティの標準を適用し、`warn`および`audit`モードでは`restricted` Podセキュリティの標準を適用します。
145+
4. これらのPodセキュリティの標準を適用した新しいPodを作成します。
146+
147+
- [Podのセキュリティアドミッション](/ja/docs/concepts/security/pod-security-admission/)
148+
- [Podセキュリティの標準](/ja/docs/concepts/security/pod-security-standards/)
149+
- [クラスターレベルでのPodセキュリティの標準の適用](/ja/docs/tutorials/security/cluster-level-pss/)

0 commit comments

Comments
 (0)