Unverified Commit 9904bceb authored by Gavin Chappell's avatar Gavin Chappell Committed by GitHub

add optional resource limits to Machinaris Chart on `test` track (#137)

* add optional resource limits to Machinaris Chart on `test` track

* removed question mark

* regex validation of values

* Memory validation comes straight from `k3s-io/k3s` in `vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go`
* CPU validation is home-grown and allows both the fractional representation as well as the "millicore" representation, but because the minimum precision is `1m`, fractions and millicores cannot be used together ([read more](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu))
  * any string containing a period MUST NOT end with an `m` as this must be a fractional representation
  * otherwise any string containing only digits MAY end with an `m` (to represent a number of millicores) or not (to represent one or more entire cores)
parent 8e1b81df
......@@ -14,4 +14,4 @@ keywords:
name: machinaris
sources:
- https://github.com/guydavis/machinaris
version: 1.0.5
version: 1.0.6
......@@ -7,6 +7,8 @@ groups:
description: "Configure Storage for Machinaris"
- name: "Machinaris Environment Variables"
description: "Set the environment that will be visible to the container"
- name: "Resource Limits"
description: "Set CPU/memory limits for Kubernetes Pod"
portals:
web_portal:
......@@ -157,3 +159,22 @@ questions:
label: "Value"
schema:
type: string
- variable: enableResourceLimits
label: "Enable Pod resource limits"
group: "Resource Limits"
schema:
type: boolean
- variable: cpuLimit
label: "CPU limit"
group: "Resource Limits"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^\\d+(?:\\.\\d+(?!.*m$)|m?$)"
- variable: memLimit
label: "Memory limit"
group: "Resource Limits"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"
......@@ -17,6 +17,12 @@ spec:
hostNetwork: true
containers:
- name: {{ .Chart.Name }}
{{ if .Values.enableResourceLimits }}
resources:
limits:
cpu: {{ .Values.cpuLimit }}
memory: {{ .Values.memLimit }}
{{ end }}
tty: true
{{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment