File tree Expand file tree Collapse file tree 2 files changed +88
-0
lines changed
Expand file tree Collapse file tree 2 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ <!-- markdownlint-disable MD007 -->
2+ <!-- markdownlint-disable MD041 -->
3+
4+ - [ TiDB on Kubernetes 文档] ( https://docs.pingcap.com/zh/tidb-in-kubernetes/dev )
5+ - 关于 TiDB Operator
6+ - 部署
7+ - 自托管的 Kubernetes
8+ - 监控与告警
9+ - 数据迁移
10+ - 从 MySQL 迁移
11+ - 运维管理
12+ - 安全
13+ - [ 以非 root 用户运行] ( containers-run-as-non-root-user.md )
14+ - 升级
15+ - 升级 TiDB Operator
16+ - 备份与恢复
17+ - 使用 Amazon S3 兼容的存储
18+ - 使用 Google Cloud Storage
19+ - 使用 Azure Blob Storage
20+ - 使用持久卷
21+ - 基于快照的备份和恢复
22+ - 运维
23+ - 为 TiDB 集群更换节点
24+ - 灾难恢复
25+ - 故障诊断
26+ - 参考
27+ - 架构
28+ - 工具
29+ - 配置
Original file line number Diff line number Diff line change 1+ ---
2+ title : 以非 root 用户运行容器
3+ summary : 了解如何在 Kubernetes 环境中以非 root 用户运行容器。
4+ ---
5+
6+ # 以非 root 用户运行容器
7+
8+ 在某些 Kubernetes 环境中,容器无法以 root 用户身份运行。出于安全考虑,建议在生产环境中以非 root 用户运行容器,以降低潜在攻击带来的安全风险。本文介绍如何通过配置 [ ` securityContext ` ] ( https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod ) 实现以非 root 用户运行容器。
9+
10+ ## 配置 TiDB Operator 相关的容器
11+
12+ 对于 TiDB Operator 相关的容器,可以在 Helm 的 ` values.yaml ` 文件中配置安全上下文 (` securityContext ` )。
13+
14+ 以下是一个配置示例:
15+
16+ ``` yaml
17+ controllerManager :
18+ securityContext :
19+ runAsUser : 1000
20+ runAsGroup : 2000
21+ fsGroup : 2000
22+ ` ` `
23+
24+ ## 配置按照 CR 生成的容器
25+
26+ 对于按照 Custom Resource (CR) 生成的容器,可以在任意一种 CR(例如 ` PDGroup`、`TiDBGroup`、`TiKVGroup`、`TiFlashGroup`、`TiCDCGroup`、`Backup`、`CompactBackup`、`BackupSchedule`、`Restore`)中配置安全上下文 (`securityContext`)。
27+
28+ - 对于 `PDGroup`、`TiDBGroup`、`TiKVGroup`、`TiFlashGroup`、`TiCDCGroup` 等 CR,可以通过 Overlay 的方式配置安全上下文。配置 `PDGroup` CR 的示例如下:
29+
30+ ` ` ` yaml
31+ apiVersion: core.pingcap.com/v1alpha1
32+ kind: PDGroup
33+ metadata:
34+ name: pd
35+ spec:
36+ template:
37+ spec:
38+ overlay:
39+ pod:
40+ spec:
41+ securityContext:
42+ runAsUser: 1000
43+ runAsGroup: 2000
44+ fsGroup: 2000
45+ ` ` `
46+
47+ - 对于 `Backup`、`CompactBackup`、`BackupSchedule`、`Restore` 等 CR,可以在 `spec` 中配置 `podSecurityContext`。配置 `Backup` CR 的示例如下:
48+
49+ ` ` ` yaml
50+ apiVersion: br.pingcap.com/v1alpha1
51+ kind: Backup
52+ metadata:
53+ name: backup
54+ spec:
55+ podSecurityContext:
56+ runAsUser: 1000
57+ runAsGroup: 2000
58+ fsGroup: 2000
59+ ` ` `
You can’t perform that action at this time.
0 commit comments