|
@@ -435,26 +435,11 @@ kubectl exec -it <pod-name> -- curl localhost:8080/actuator/health
|
|
|
|
|
|
|
|
## 安全最佳实践
|
|
## 安全最佳实践
|
|
|
|
|
|
|
|
-### 1. 使用私有镜像仓库
|
|
|
|
|
-
|
|
|
|
|
-```bash
|
|
|
|
|
-# 创建镜像拉取Secret
|
|
|
|
|
-kubectl create secret docker-registry regcred \
|
|
|
|
|
- --docker-server=your-registry \
|
|
|
|
|
- --docker-username=username \
|
|
|
|
|
- --docker-password=password \
|
|
|
|
|
- --docker-email=email@example.com
|
|
|
|
|
-
|
|
|
|
|
-# 在values.yaml中引用
|
|
|
|
|
-imagePullSecrets:
|
|
|
|
|
- - name: regcred
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-### 2. 配置资源限制
|
|
|
|
|
|
|
+### 1. 配置资源限制
|
|
|
|
|
|
|
|
始终为容器设置CPU和内存限制,防止资源耗尽。
|
|
始终为容器设置CPU和内存限制,防止资源耗尽。
|
|
|
|
|
|
|
|
-### 3. 安全上下文配置
|
|
|
|
|
|
|
+### 2. 安全上下文配置
|
|
|
|
|
|
|
|
```yaml
|
|
```yaml
|
|
|
securityContext:
|
|
securityContext:
|
|
@@ -463,11 +448,11 @@ securityContext:
|
|
|
readOnlyRootFilesystem: true
|
|
readOnlyRootFilesystem: true
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-### 4. RBAC配置
|
|
|
|
|
|
|
+### 3. RBAC配置
|
|
|
|
|
|
|
|
为应用创建最小权限的Service Account。
|
|
为应用创建最小权限的Service Account。
|
|
|
|
|
|
|
|
-### 5. 敏感信息管理
|
|
|
|
|
|
|
+### 4. 敏感信息管理
|
|
|
|
|
|
|
|
- 使用Kubernetes Secrets存储密码和API Key
|
|
- 使用Kubernetes Secrets存储密码和API Key
|
|
|
- 不要在ConfigMap中存储敏感信息
|
|
- 不要在ConfigMap中存储敏感信息
|