Skip to content

Commit c19a1ba

Browse files
committed
Add admission policy documentation (#416)
add VAP/MAP doc
1 parent d28c1a3 commit c19a1ba

File tree

2 files changed

+258
-0
lines changed

2 files changed

+258
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
+++
2+
title = "Admission Policy"
3+
4+
date = 2025-09-18
5+
lastmod = 2025-09-18
6+
7+
draft = false # Is this a draft? true/false
8+
toc = true # Show table of contents? true/false
9+
type = "docs" # Do not modify.
10+
11+
# Add menu entry to sidebar.
12+
linktitle = "Admission Policy"
13+
[menu.docs]
14+
parent = "concepts"
15+
weight = 7
16+
+++
17+
18+
## Introduction
19+
Volcano supports Validating Admission Policy (VAP) and Mutating Admission Policy (MAP) to validate and automatically modify Volcano resources like Jobs, Pods, Queues, and PodGroups when they are created or updated. These policies work alongside existing Volcano admission webhooks, providing additional validation and mutation capabilities using Kubernetes native admission policies.
20+
21+
> **Note**: VAP and MAP are **not enabled by default**. You must explicitly enable them during installation.
22+
23+
## Installation and Configuration
24+
### Prerequisites
25+
- Kubernetes 1.30+ for ValidatingAdmissionPolicy (stable)
26+
- Kubernetes 1.32+ for MutatingAdmissionPolicy (beta)
27+
28+
### Enable VAP and MAP
29+
30+
#### Option 1: Helm Installation
31+
Configure the following values when installing Volcano:
32+
33+
```bash
34+
# Install Volcano with VAP and MAP enabled
35+
helm install volcano volcano/volcano --namespace volcano-system --create-namespace \
36+
--set custom.vap_enable=true \
37+
--set custom.map_enable=true
38+
39+
# Or upgrade existing installation
40+
helm upgrade volcano volcano/volcano --namespace volcano-system \
41+
--set custom.vap_enable=true \
42+
--set custom.map_enable=true
43+
```
44+
45+
Alternatively, you can set these values in your `values.yaml`:
46+
47+
```yaml
48+
custom:
49+
vap_enable: true # Enable Validating Admission Policy
50+
map_enable: true # Enable Mutating Admission Policy
51+
```
52+
53+
#### Option 2: YAML Installation
54+
You can also install Volcano directly using YAML manifests. Choose the appropriate file based on your requirements:
55+
56+
```bash
57+
# Install Volcano without VAP/MAP (default)
58+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development.yaml
59+
60+
# Install Volcano with VAP only
61+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development-vap.yaml
62+
63+
# Install Volcano with both VAP and MAP
64+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development-vap-map.yaml
65+
```
66+
67+
68+
## Key Configuration Fields
69+
70+
### vap_enable
71+
`vap_enable` enables Validating Admission Policy. When enabled, Volcano will validate all Volcano resources before they are created or updated.
72+
73+
### map_enable
74+
`map_enable` enables Mutating Admission Policy. When enabled, Volcano will automatically set default values for Jobs, Pods, and other resources.
75+
76+
> **Important**: MAP provides partial functionality compared to existing webhooks. It handles job-level defaults but has limitations with task-level modifications. The existing webhook system continues to work alongside MAP.
77+
78+
## Usage
79+
80+
### Verify Policies are Active
81+
After installation, check that the policies are running:
82+
83+
```bash
84+
# Check ValidatingAdmissionPolicies
85+
kubectl get validatingadmissionpolicy | grep volcano
86+
87+
# Check MutatingAdmissionPolicies
88+
kubectl get mutatingadmissionpolicy | grep volcano
89+
90+
# Verify policy bindings
91+
kubectl get validatingadmissionpolicybinding | grep volcano
92+
kubectl get mutatingadmissionpolicybinding | grep volcano
93+
```
94+
95+
### Test Validation
96+
Try creating an invalid job to see validation in action:
97+
98+
```bash
99+
# This will be rejected due to duplicate task names
100+
kubectl apply -f - <<EOF
101+
apiVersion: batch.volcano.sh/v1alpha1
102+
kind: Job
103+
metadata:
104+
name: invalid-job
105+
spec:
106+
tasks:
107+
- name: worker
108+
replicas: 1
109+
template:
110+
spec:
111+
containers:
112+
- image: nginx
113+
name: nginx
114+
- name: worker # Duplicate name - will be rejected
115+
replicas: 1
116+
template:
117+
spec:
118+
containers:
119+
- image: nginx
120+
name: nginx
121+
EOF
122+
```
123+
124+
## Notes
125+
- VAP and MAP work alongside existing Volcano webhooks, providing additional validation and mutation capabilities
126+
- MAP has some limitations with task-level modifications due to technical constraints
127+
- ValidatingAdmissionPolicy requires Kubernetes 1.30+ (stable since 1.30)
128+
- MutatingAdmissionPolicy requires Kubernetes 1.32+ (beta since 1.32)
129+
- If policies are not working, verify your Kubernetes version meets the minimum requirements
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
+++
2+
title = "准入策略"
3+
4+
date = 2025-09-18
5+
lastmod = 2025-09-18
6+
7+
draft = false # Is this a draft? true/false
8+
toc = true # Show table of contents? true/false
9+
type = "docs" # Do not modify.
10+
11+
# Add menu entry to sidebar.
12+
linktitle = "准入策略"
13+
[menu.docs]
14+
parent = "concepts"
15+
weight = 7
16+
+++
17+
18+
## 介绍
19+
Volcano 支持验证准入策略(VAP)和变更准入策略(MAP),用于在创建或更新 Volcano 资源(如 Jobs、Pods、Queues、PodGroups)时进行验证和自动修改。这些策略与现有的 Volcano 准入 webhook 协同工作,使用 Kubernetes 原生准入策略提供额外的验证和变更功能。
20+
21+
> **注意**:VAP 和 MAP **默认未启用**。您必须在安装时明确启用它们。
22+
23+
## 安装和配置
24+
### 前置条件
25+
- ValidatingAdmissionPolicy 需要 Kubernetes 1.30+(1.30 版本稳定)
26+
- MutatingAdmissionPolicy 需要 Kubernetes 1.32+(1.32 版本测试)
27+
28+
### 启用 VAP 和 MAP
29+
30+
#### 方式一:Helm 安装
31+
安装 Volcano 时配置以下值:
32+
33+
```bash
34+
# 启用 VAP 和 MAP 安装 Volcano
35+
helm install volcano volcano/volcano --namespace volcano-system --create-namespace \
36+
--set custom.vap_enable=true \
37+
--set custom.map_enable=true
38+
39+
# 或升级现有安装
40+
helm upgrade volcano volcano/volcano --namespace volcano-system \
41+
--set custom.vap_enable=true \
42+
--set custom.map_enable=true
43+
```
44+
45+
或者在 `values.yaml` 中设置这些值:
46+
47+
```yaml
48+
custom:
49+
vap_enable: true # 启用验证准入策略
50+
map_enable: true # 启用变更准入策略
51+
```
52+
53+
#### 方式二:YAML 安装
54+
您也可以直接使用 YAML 清单安装 Volcano。根据需求选择相应的文件:
55+
56+
```bash
57+
# 安装不启用 VAP/MAP 的 Volcano(默认)
58+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development.yaml
59+
60+
# 安装仅启用 VAP 的 Volcano
61+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development-vap.yaml
62+
63+
# 安装同时启用 VAP 和 MAP 的 Volcano
64+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development-vap-map.yaml
65+
```
66+
67+
68+
## 关键字段
69+
70+
### vap_enable
71+
`vap_enable` 启用验证准入策略。启用后,Volcano 将在创建或更新所有 Volcano 资源前进行验证。
72+
73+
### map_enable
74+
`map_enable` 启用变更准入策略。启用后,Volcano 将自动为 Jobs、Pods 和其他资源设置默认值。
75+
76+
> **重要**:相比现有 webhook,MAP 提供部分功能。它处理作业级默认值,但在任务级修改方面有限制。现有的 webhook 系统将继续与 MAP 协同工作。
77+
78+
## 使用
79+
80+
### 验证策略是否生效
81+
安装后,检查策略是否运行:
82+
83+
```bash
84+
# 检查验证准入策略
85+
kubectl get validatingadmissionpolicy | grep volcano
86+
87+
# 检查变更准入策略
88+
kubectl get mutatingadmissionpolicy | grep volcano
89+
90+
# 验证策略绑定
91+
kubectl get validatingadmissionpolicybinding | grep volcano
92+
kubectl get mutatingadmissionpolicybinding | grep volcano
93+
```
94+
95+
### 测试验证
96+
尝试创建无效作业以查看验证效果:
97+
98+
```bash
99+
# 这将因重复任务名称被拒绝
100+
kubectl apply -f - <<EOF
101+
apiVersion: batch.volcano.sh/v1alpha1
102+
kind: Job
103+
metadata:
104+
name: invalid-job
105+
spec:
106+
tasks:
107+
- name: worker
108+
replicas: 1
109+
template:
110+
spec:
111+
containers:
112+
- image: nginx
113+
name: nginx
114+
- name: worker # 重复名称 - 将被拒绝
115+
replicas: 1
116+
template:
117+
spec:
118+
containers:
119+
- image: nginx
120+
name: nginx
121+
EOF
122+
```
123+
124+
## 注意事项
125+
- VAP 和 MAP 与现有 Volcano webhook 协同工作,提供额外的验证和变更能力
126+
- 由于技术限制,MAP 在任务级修改方面有一些限制
127+
- ValidatingAdmissionPolicy 需要 Kubernetes 1.30+(1.30 版本起稳定)
128+
- MutatingAdmissionPolicy 需要 Kubernetes 1.32+(1.32 版本起测试)
129+
- 如果策略不工作,请验证您的 Kubernetes 版本是否满足最低要求

0 commit comments

Comments
 (0)