diff --git a/bitnami/wildfly/Chart.yaml b/bitnami/wildfly/Chart.yaml index 6d1949f91c..58f691c130 100644 --- a/bitnami/wildfly/Chart.yaml +++ b/bitnami/wildfly/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: wildfly -version: 3.0.0 +version: 3.1.0 appVersion: 17.0.1 description: Chart for Wildfly keywords: diff --git a/bitnami/wildfly/README.md b/bitnami/wildfly/README.md index 05311a35ed..3a40daba87 100644 --- a/bitnami/wildfly/README.md +++ b/bitnami/wildfly/README.md @@ -45,34 +45,40 @@ The command removes all the Kubernetes components associated with the chart and The following tables lists the configurable parameters of the WildFly chart and their default values. -| Parameter | Description | Default | -|---------------------------------|----------------------------------------|------------------------------------------------------------| -| `global.imageRegistry` | Global Docker image registry | `nil` | -| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | -| `image.registry` | WildFly image registry | `docker.io` | -| `image.repository` | WildFly Image name | `bitnami/wildfly` | -| `image.tag` | WildFly Image tag | `{TAG_NAME}` | -| `image.pullPolicy` | WildFly image pull policy | `IfNotPresent` | -| `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | -| `nameOverride` | String to partially override wildfly.fullname template with a string (will prepend the release name) | `nil` | -| `fullnameOverride` | String to fully override wildfly.fullname template with a string | `nil` | -| `wildflyUsername` | WildFly admin user | `user` | -| `wildflyPassword` | WildFly admin password | _random 10 character alphanumeric string_ | -| `securityContext.enabled` | Enable security context | `true` | -| `securityContext.fsGroup` | Group ID for the container | `1001` | -| `securityContext.runAsUser` | User ID for the container | `1001` | -| `service.type` | Kubernetes Service type | `LoadBalancer` | -| `service.port` | Service HTTP port | `80` | -| `service.mgmtPort` | Service Management port | `9990` | -| `service.nodePorts.http` | Kubernetes http node port | `""` | -| `service.nodePorts.mgmt` | Kubernetes management node port | `""` | -| `service.externalTrafficPolicy` | Enable client source IP preservation | `Cluster` | -| `service.loadBalancerIP` | LoadBalancer service IP address | `""` | -| `persistence.enabled` | Enable persistence using PVC | `true` | -| `persistence.storageClass` | PVC Storage Class for WildFly volume | `nil` (uses alpha storage class annotation) | -| `persistence.accessMode` | PVC Access Mode for WildFly volume | `ReadWriteOnce` | -| `persistence.size` | PVC Storage Request for WildFly volume | `8Gi` | -| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` | +| Parameter | Description | Default | +| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | +| `global.imageRegistry` | Global Docker image registry | `nil` | +| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | +| `image.registry` | WildFly image registry | `docker.io` | +| `image.repository` | WildFly Image name | `bitnami/wildfly` | +| `image.tag` | WildFly Image tag | `{TAG_NAME}` | +| `image.pullPolicy` | WildFly image pull policy | `IfNotPresent` | +| `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | +| `nameOverride` | String to partially override wildfly.fullname template with a string (will prepend the release name) | `nil` | +| `fullnameOverride` | String to fully override wildfly.fullname template with a string | `nil` | +| `volumePermissions.enabled` | Enable init container that changes volume permissions in the data directory (for cases where the default k8s `runAsUser` and `fsUser` values do not work) | `false` | +| `volumePermissions.image.registry` | Init container volume-permissions image registry | `docker.io` | +| `volumePermissions.image.repository` | Init container volume-permissions image name | `bitnami/minideb` | +| `volumePermissions.image.tag` | Init container volume-permissions image tag | `latest` | +| `volumePermissions.image.pullPolicy` | Init container volume-permissions image pull policy | `Always` | +| `volumePermissions.resources` | Init container resource requests/limit | `nil` | +| `wildflyUsername` | WildFly admin user | `user` | +| `wildflyPassword` | WildFly admin password | _random 10 character alphanumeric string_ | +| `securityContext.enabled` | Enable security context | `true` | +| `securityContext.fsGroup` | Group ID for the container | `1001` | +| `securityContext.runAsUser` | User ID for the container | `1001` | +| `service.type` | Kubernetes Service type | `LoadBalancer` | +| `service.port` | Service HTTP port | `80` | +| `service.mgmtPort` | Service Management port | `9990` | +| `service.nodePorts.http` | Kubernetes http node port | `""` | +| `service.nodePorts.mgmt` | Kubernetes management node port | `""` | +| `service.externalTrafficPolicy` | Enable client source IP preservation | `Cluster` | +| `service.loadBalancerIP` | LoadBalancer service IP address | `""` | +| `persistence.enabled` | Enable persistence using PVC | `true` | +| `persistence.storageClass` | PVC Storage Class for WildFly volume | `nil` (uses alpha storage class annotation) | +| `persistence.accessMode` | PVC Access Mode for WildFly volume | `ReadWriteOnce` | +| `persistence.size` | PVC Storage Request for WildFly volume | `8Gi` | +| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` | The above parameters map to the env variables defined in [bitnami/wildfly](http://github.com/bitnami/bitnami-docker-wildfly). For more information please refer to the [bitnami/wildfly](http://github.com/bitnami/bitnami-docker-wildfly) image documentation. @@ -107,6 +113,15 @@ The [Bitnami WildFly](https://github.com/bitnami/bitnami-docker-wildfly) image s Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube. See the [Configuration](#configuration) section to configure the PVC or to disable persistence. +### Adjust permissions of persistent volume mountpoint + +As the image run as non-root by default, it is necessary to adjust the ownership of the persistent volume so that the container can write data into it. + +By default, the chart is configured to use Kubernetes Security Context to automatically change the ownership of the volume. However, this feature does not work in all Kubernetes distributions. +As an alternative, this chart supports using an initContainer to change the ownership of the volume before mounting it in the final destination. + +You can enable this initContainer by setting `volumePermissions.enabled` to `true`. + ## Upgrading ### To 2.1.0 diff --git a/bitnami/wildfly/templates/_helpers.tpl b/bitnami/wildfly/templates/_helpers.tpl index 4b362f4c83..ff7ffed1c0 100644 --- a/bitnami/wildfly/templates/_helpers.tpl +++ b/bitnami/wildfly/templates/_helpers.tpl @@ -61,16 +61,45 @@ imagePullSecrets: {{- range .Values.global.imagePullSecrets }} - name: {{ . }} {{- end }} -{{- else if .Values.image.pullSecrets }} +{{- else if or .Values.image.pullSecrets .Values.volumePermissions.image.pullSecrets }} imagePullSecrets: {{- range .Values.image.pullSecrets }} - name: {{ . }} {{- end }} +{{- range .Values.volumePermissions.image.pullSecrets }} + - name: {{ . }} +{{- end }} {{- end -}} -{{- else if .Values.image.pullSecrets }} +{{- else if or .Values.image.pullSecrets .Values.volumePermissions.image.pullSecrets }} imagePullSecrets: {{- range .Values.image.pullSecrets }} - name: {{ . }} {{- end }} +{{- range .Values.volumePermissions.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- end -}} + +{{/* +Return the proper image name (for the init container volume-permissions image) +*/}} +{{- define "wildfly.volumePermissions.image" -}} +{{- $registryName := .Values.volumePermissions.image.registry -}} +{{- $repositoryName := .Values.volumePermissions.image.repository -}} +{{- $tag := .Values.volumePermissions.image.tag | toString -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. +Also, we can't use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} + {{- if .Values.global.imageRegistry }} + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} + {{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} + {{- end -}} +{{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} {{- end -}} {{- end -}} diff --git a/bitnami/wildfly/templates/deployment.yaml b/bitnami/wildfly/templates/deployment.yaml index 6dc9ef5e03..55efb8566b 100644 --- a/bitnami/wildfly/templates/deployment.yaml +++ b/bitnami/wildfly/templates/deployment.yaml @@ -25,6 +25,19 @@ spec: runAsUser: {{ .Values.securityContext.runAsUser }} {{- end }} {{- include "wildfly.imagePullSecrets" . | indent 6 }} + {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }} + initContainers: + - name: volume-permissions + image: "{{ template "wildfly.volumePermissions.image" . }}" + imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }} + command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "/bitnami/wildfly"] + securityContext: + runAsUser: 0 + resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 -}} + volumeMounts: + - name: data + mountPath: /bitnami/wildfly + {{- end }} containers: - name: wildlfy image: "{{ template "wildfly.image" . }}" @@ -59,10 +72,10 @@ spec: resources: {{ toYaml .Values.resources | indent 10 }} volumeMounts: - - name: wildfly-data + - name: data mountPath: /bitnami/wildfly volumes: - - name: wildfly-data + - name: data {{- if .Values.persistence.enabled }} persistentVolumeClaim: claimName: {{ template "wildfly.fullname" . }} diff --git a/bitnami/wildfly/values.yaml b/bitnami/wildfly/values.yaml index 87787969f8..65b30fa161 100644 --- a/bitnami/wildfly/values.yaml +++ b/bitnami/wildfly/values.yaml @@ -34,6 +34,24 @@ image: ## # fullnameOverride: +## Init containers parameters: +## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section. +## +volumePermissions: + enabled: false + image: + registry: docker.io + repository: bitnami/minideb + tag: latest + pullPolicy: Always + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## + # pullSecrets: + # - myRegistryKeySecretName + resources: {} + ## Specify a imagePullPolicy ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ##