|
2 | 2 | [[jkube-volume-permission]] |
3 | 3 | ==== jkube-volume-permission |
4 | 4 |
|
5 | | -Enricher which fixes the permission of persistent volume mount with the help of an init container. |
| 5 | +Enricher which automatically adds an init container to fix permissions on persistent volume mounts. |
| 6 | + |
| 7 | +When your application uses PersistentVolumeClaims, this enricher detects them and adds an init container that runs `chmod` to ensure the mounted volumes have the correct permissions before your application starts. |
| 8 | + |
| 9 | +**Behavior:** |
| 10 | + |
| 11 | +* Automatically triggered when PersistentVolumeClaims are detected in your Pod specification |
| 12 | +* Creates an init container named `jkube-volume-permission` that runs before your application containers |
| 13 | +* Mounts all PersistentVolumeClaims and applies the specified permissions (default: `777`) |
| 14 | + |
| 15 | +ifeval::["{plugin-type}" == "maven"] |
| 16 | +===== Disabling the enricher |
| 17 | + |
| 18 | +If you don't need automatic permission fixing, you can exclude this enricher in your `pom.xml`: |
| 19 | + |
| 20 | +[source,xml,indent=0,subs="verbatim,quotes,attributes"] |
| 21 | +---- |
| 22 | +<plugin> |
| 23 | + <groupId>org.eclipse.jkube</groupId> |
| 24 | + <artifactId>{plugin}</artifactId> |
| 25 | + <configuration> |
| 26 | + <enricher> |
| 27 | + <excludes> |
| 28 | + <exclude>jkube-volume-permission</exclude> |
| 29 | + </excludes> |
| 30 | + </enricher> |
| 31 | + </configuration> |
| 32 | +</plugin> |
| 33 | +---- |
| 34 | + |
| 35 | +NOTE: Enricher excludes cannot be configured via Maven properties. You must use the XML configuration above. |
| 36 | +endif::[] |
| 37 | + |
| 38 | +ifeval::["{plugin-type}" == "gradle"] |
| 39 | +===== Disabling the enricher |
| 40 | + |
| 41 | +If you don't need automatic permission fixing, you can exclude this enricher in your `build.gradle`: |
| 42 | + |
| 43 | +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] |
| 44 | +---- |
| 45 | +{task-prefix} { |
| 46 | + enricher { |
| 47 | + excludes = ["jkube-volume-permission"] |
| 48 | + } |
| 49 | +} |
| 50 | +---- |
| 51 | + |
| 52 | +NOTE: Enricher excludes cannot be configured via `gradle.properties`. You must use the DSL configuration above in your `build.gradle` file. |
| 53 | +endif::[] |
| 54 | + |
| 55 | +===== Configuration |
6 | 56 |
|
7 | 57 | .Supported properties |
8 | 58 | [cols="1,6,1"] |
9 | 59 | |=== |
10 | 60 | | Option | Description | Property |
11 | 61 |
|
12 | 62 | | *imageName* |
13 | | -| Image name for PersistentVolume init container |
| 63 | +| Image name for the init container. |
| 64 | + |
| 65 | + Useful when the default `quay.io/quay/busybox` is not accessible (e.g., corporate registries with restricted access). |
14 | 66 |
|
15 | 67 | Defaults to `quay.io/quay/busybox`. |
16 | 68 |
|
17 | 69 | | `jkube.enricher.jkube-volume-permission.imageName` |
18 | 70 |
|
19 | 71 | | *permission* |
20 | | -| PersistentVolume init container access mode |
| 72 | +| Unix permission mode to apply to mounted volumes (e.g., `755`, `777`). |
21 | 73 |
|
22 | | -Defaults to `777`. |
| 74 | + Defaults to `777`. |
23 | 75 | | `jkube.enricher.jkube-volume-permission.permission` |
24 | 76 |
|
25 | 77 | | *cpuLimit* |
26 | | -| Set PersistentVolume *initContainer*'s `.resources` CPU limit |
| 78 | +| CPU limit for the init container (e.g., `100m`, `0.5`). |
27 | 79 | | `jkube.enricher.jkube-volume-permission.cpuLimit` |
28 | 80 |
|
29 | 81 | | *memoryLimit* |
30 | | -| Set PersistentVolume *initContainer*'s `.resources` memory limit |
| 82 | +| Memory limit for the init container (e.g., `64Mi`, `128Mi`). |
31 | 83 | | `jkube.enricher.jkube-volume-permission.memoryLimit` |
32 | 84 |
|
33 | 85 | | *cpuRequest* |
34 | | -| Set PersistentVolume *initContainer*'s `.resources` CPU request |
| 86 | +| CPU request for the init container (e.g., `50m`, `0.1`). |
35 | 87 | | `jkube.enricher.jkube-volume-permission.cpuRequest` |
36 | 88 |
|
37 | 89 | | *memoryRequest* |
38 | | -| Set PersistentVolume *initContainer*'s `.resources` memory request |
| 90 | +| Memory request for the init container (e.g., `32Mi`, `64Mi`). |
39 | 91 | | `jkube.enricher.jkube-volume-permission.memoryRequest` |
40 | 92 | |=== |
| 93 | + |
| 94 | +ifeval::["{plugin-type}" == "maven"] |
| 95 | +===== Examples |
| 96 | + |
| 97 | +====== Using a custom image |
| 98 | + |
| 99 | +If your environment blocks access to `quay.io/quay/busybox` (e.g., corporate firewall restrictions), specify an alternative image. |
| 100 | + |
| 101 | +**Option 1: Plugin configuration (pom.xml)** |
| 102 | +[source,xml,indent=0,subs="verbatim,quotes,attributes"] |
| 103 | +---- |
| 104 | +<plugin> |
| 105 | + <groupId>org.eclipse.jkube</groupId> |
| 106 | + <artifactId>{plugin}</artifactId> |
| 107 | + <configuration> |
| 108 | + <enricher> |
| 109 | + <config> |
| 110 | + <jkube-volume-permission> |
| 111 | + <imageName>your-registry.com/busybox:latest</imageName> |
| 112 | + <permission>755</permission> |
| 113 | + </jkube-volume-permission> |
| 114 | + </config> |
| 115 | + </enricher> |
| 116 | + </configuration> |
| 117 | +</plugin> |
| 118 | +---- |
| 119 | + |
| 120 | +**Option 2: Maven properties (pom.xml)** |
| 121 | +[source,xml,indent=0,subs="verbatim,quotes,attributes"] |
| 122 | +---- |
| 123 | +<properties> |
| 124 | + <jkube.enricher.jkube-volume-permission.imageName>your-registry.com/busybox:latest</jkube.enricher.jkube-volume-permission.imageName> |
| 125 | + <jkube.enricher.jkube-volume-permission.permission>755</jkube.enricher.jkube-volume-permission.permission> |
| 126 | +</properties> |
| 127 | +---- |
| 128 | + |
| 129 | +**Option 3: Command line** |
| 130 | +[source,bash,indent=0,subs="verbatim,quotes,attributes"] |
| 131 | +---- |
| 132 | +mvn {goal-prefix}:resource \ |
| 133 | + -Djkube.enricher.jkube-volume-permission.imageName=your-registry.com/busybox:latest \ |
| 134 | + -Djkube.enricher.jkube-volume-permission.permission=755 |
| 135 | +---- |
| 136 | + |
| 137 | +====== Setting resource limits |
| 138 | + |
| 139 | +Control the resource consumption of the init container: |
| 140 | + |
| 141 | +**Using plugin configuration:** |
| 142 | +[source,xml,indent=0,subs="verbatim,quotes,attributes"] |
| 143 | +---- |
| 144 | +<enricher> |
| 145 | + <config> |
| 146 | + <jkube-volume-permission> |
| 147 | + <cpuLimit>100m</cpuLimit> |
| 148 | + <memoryLimit>64Mi</memoryLimit> |
| 149 | + <cpuRequest>50m</cpuRequest> |
| 150 | + <memoryRequest>32Mi</memoryRequest> |
| 151 | + </jkube-volume-permission> |
| 152 | + </config> |
| 153 | +</enricher> |
| 154 | +---- |
| 155 | + |
| 156 | +**Using Maven properties:** |
| 157 | +[source,xml,indent=0,subs="verbatim,quotes,attributes"] |
| 158 | +---- |
| 159 | +<properties> |
| 160 | + <jkube.enricher.jkube-volume-permission.cpuLimit>100m</jkube.enricher.jkube-volume-permission.cpuLimit> |
| 161 | + <jkube.enricher.jkube-volume-permission.memoryLimit>64Mi</jkube.enricher.jkube-volume-permission.memoryLimit> |
| 162 | +</properties> |
| 163 | +---- |
| 164 | +endif::[] |
| 165 | + |
| 166 | +ifeval::["{plugin-type}" == "gradle"] |
| 167 | +===== Examples |
| 168 | + |
| 169 | +====== Using a custom image |
| 170 | + |
| 171 | +If your environment blocks access to `quay.io/quay/busybox` (e.g., corporate firewall restrictions), specify an alternative image. |
| 172 | + |
| 173 | +**Option 1: Gradle DSL (build.gradle)** |
| 174 | +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] |
| 175 | +---- |
| 176 | +{task-prefix} { |
| 177 | + enricher { |
| 178 | + config { |
| 179 | + "jkube-volume-permission" { |
| 180 | + imageName = "your-registry.com/busybox:latest" |
| 181 | + permission = "755" |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | +} |
| 186 | +---- |
| 187 | + |
| 188 | +**Option 2: Gradle properties (gradle.properties)** |
| 189 | +[source,properties,indent=0,subs="verbatim,quotes,attributes"] |
| 190 | +---- |
| 191 | +jkube.enricher.jkube-volume-permission.imageName=your-registry.com/busybox:latest |
| 192 | +jkube.enricher.jkube-volume-permission.permission=755 |
| 193 | +---- |
| 194 | + |
| 195 | +**Option 3: Command line** |
| 196 | +[source,bash,indent=0,subs="verbatim,quotes,attributes"] |
| 197 | +---- |
| 198 | +gradle {task-prefix}Resource \ |
| 199 | + -Pjkube.enricher.jkube-volume-permission.imageName=your-registry.com/busybox:latest \ |
| 200 | + -Pjkube.enricher.jkube-volume-permission.permission=755 |
| 201 | +---- |
| 202 | + |
| 203 | +====== Setting resource limits |
| 204 | + |
| 205 | +Control the resource consumption of the init container: |
| 206 | + |
| 207 | +**Using Gradle DSL:** |
| 208 | +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] |
| 209 | +---- |
| 210 | +{task-prefix} { |
| 211 | + enricher { |
| 212 | + config { |
| 213 | + "jkube-volume-permission" { |
| 214 | + cpuLimit = "100m" |
| 215 | + memoryLimit = "64Mi" |
| 216 | + cpuRequest = "50m" |
| 217 | + memoryRequest = "32Mi" |
| 218 | + } |
| 219 | + } |
| 220 | + } |
| 221 | +} |
| 222 | +---- |
| 223 | + |
| 224 | +**Using gradle.properties:** |
| 225 | +[source,properties,indent=0,subs="verbatim,quotes,attributes"] |
| 226 | +---- |
| 227 | +jkube.enricher.jkube-volume-permission.cpuLimit=100m |
| 228 | +jkube.enricher.jkube-volume-permission.memoryLimit=64Mi |
| 229 | +jkube.enricher.jkube-volume-permission.cpuRequest=50m |
| 230 | +jkube.enricher.jkube-volume-permission.memoryRequest=32Mi |
| 231 | +---- |
| 232 | +endif::[] |
0 commit comments