|
| 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 |
0 commit comments