diff --git a/Charts/README.md b/Charts/README.md index 8d08d850..bb0ad9b6 100644 --- a/Charts/README.md +++ b/Charts/README.md @@ -59,7 +59,7 @@ These features will be accessed via `ec`. See https://github.com/epics-container This script will: -- Inspect the values of `editable` and `autostart` in the `values.yaml` file of the specified IOC (TODO: at present it uses the p47-services source code to do so but this should be determined from the cluster in future). +- Inspect the values of `editable` and `autostart` in the `values.yaml` file of the specified service (TODO: at present it uses the p47-services source code to do so but this should be determined from the cluster in future). - Port forward the debugpy port (5678) from the pod to localhost. - If editable is true, it will mount the PVC locally using pv-mounter and open VSCode to the /workspaces/xxx folder. - If autostart is false, it will exec into the container and launch debugpy to run the main program. diff --git a/Charts/fastcs/extra.values.yaml b/Charts/fastcs/extra.values.yaml index 49e115d1..44d13af6 100644 --- a/Charts/fastcs/extra.values.yaml +++ b/Charts/fastcs/extra.values.yaml @@ -13,3 +13,12 @@ extraContainers: - command - arg1 - arg2 + +global: + env: + - name: example + value: example + +env: + - name: example + value: example diff --git a/Charts/fastcs/templates/pvcs.yaml b/Charts/fastcs/templates/pvcs.yaml index 1a2ce373..53b1ffc0 100644 --- a/Charts/fastcs/templates/pvcs.yaml +++ b/Charts/fastcs/templates/pvcs.yaml @@ -1,7 +1,7 @@ # PVC for debugging volume {{ if .Values.editable }} -{{- $location := default .Values.global.location .Values.location | required "ERROR - You must supply location or global.location" -}} -{{- $ioc_group := default .Values.global.ioc_group .Values.ioc_group | required "ERROR - You must supply ioc_group or global.ioc_group" -}} +{{- $location := default .Values.global.location .Values.location | default "" -}} +{{- $ioc_group := default .Values.global.ioc_group .Values.ioc_group | default "" -}} kind: PersistentVolumeClaim apiVersion: v1 @@ -10,7 +10,9 @@ metadata: labels: app: {{ .Release.Name }} location: {{ $location }} + with: {{ $ioc_group }} ioc_group: {{ $ioc_group }} + {{- end }} spec: accessModes: - ReadWriteMany diff --git a/Charts/fastcs/templates/service.yaml b/Charts/fastcs/templates/service.yaml index 4073818f..bce0effa 100644 --- a/Charts/fastcs/templates/service.yaml +++ b/Charts/fastcs/templates/service.yaml @@ -6,8 +6,10 @@ metadata: {{- include "fastcs.labels" . | nindent 4 }} app: {{ .Release.Name }} location: {{ .Values.global.location }} + {{- with .Values.global.ioc_group }} ioc_group: {{ .Values.global.ioc_group }} - is_ioc: "true" + {{- end }} + is_ioc: {{ .Values.is_ioc | quote }} spec: selector: app: {{ .Release.Name }} diff --git a/Charts/fastcs/templates/statefulset.yaml b/Charts/fastcs/templates/statefulset.yaml index 4a3170d9..98db632c 100644 --- a/Charts/fastcs/templates/statefulset.yaml +++ b/Charts/fastcs/templates/statefulset.yaml @@ -4,24 +4,27 @@ Default the derivable substitution values. This keeps the length of the values.txt file for each individual IOC to a minimum */ -}} -{{- $location := default .Values.global.location .Values.location | required "ERROR - You must supply location or global.location" -}} -{{- $ioc_group := default .Values.global.ioc_group .Values.ioc_group | required "ERROR - You must supply ioc_group or global.ioc_group" -}} +{{- $location := default .Values.global.location .Values.location | default "" -}} +# for epics-containers services repos, ioc_group is set in services/values.yaml +{{- $ioc_group := default .Values.global.ioc_group .Values.ioc_group | default "" -}} +# for epics-containers services repos, opisClaim is named after the ioc_group in services/values.yaml +# for non-epics-containers services repos, opisClaim should be set in the service values.yaml {{- $opisClaim := default (print $ioc_group "-opi-claim") .Values.opisClaim -}} -{{- $runtimeClaim := default (print $ioc_group "-runtime-claim") .Values.runtimeClaim -}} -{{- $autosaveClaim := default (print $ioc_group "-autosave-claim") .Values.autosaveClaim -}} {{- $image := .Values.image | required "ERROR - You must supply image." -}} -{{- $enabled := eq .Values.global.enabled false | ternary false true -}} +{{- $enabled := eq .Values.global.enabled false | ternary false true }} apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ .Release.Name }} labels: - location: {{ $location }} + location: {{ $location | quote }} + {{- with $ioc_group }} ioc_group: {{ $ioc_group }} + {{- end }} enabled: {{ $enabled | quote }} - is_ioc: "true" + is_ioc: {{ .Values.is_ioc | quote }} {{- include "fastcs.labels" . | nindent 4 }} spec: replicas: {{ $enabled | ternary 1 0 }} @@ -35,10 +38,12 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - location: {{ $location }} + location: {{ $location | quote }} + {{- with $ioc_group }} ioc_group: {{ $ioc_group }} + {{- end }} enabled: {{ $enabled | quote }} - is_ioc: "true" + is_ioc: {{ .Values.is_ioc | quote }} {{- include "fastcs.labels" . | nindent 8 }} {{- with .Values.podLabels }} {{- toYaml . | nindent 8 }} @@ -78,6 +83,19 @@ spec: - name: {{ .name }} image: {{ .image }} imagePullPolicy: {{ $.Values.image.pullPolicy }} + # a writable place to have cwd + workingDir: /tmp + env: + - name: HOME + value: /tmp + - name: TERM + value: xterm-256color + {{- with $.Values.env }} + {{- toYaml . | nindent 12}} + {{- end }} + {{- with $.Values.global.env }} + {{- toYaml . | nindent 12}} + {{- end }} {{- with $.Values.securityContext }} securityContext: {{- toYaml . | nindent 12 }} @@ -90,11 +108,13 @@ spec: {{- with $.Values.volumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} + {{- with $.Values.opisMountPoint }} - name: opis-volume - mountPath: /epics/opi - subPath: "{{ $.Release.Name }}" + mountPath: {{ . }} + subPath: {{ $.Release.Name }} + {{- end }} - name: config-volume - mountPath: {{ $.Values.iocConfig }} + mountPath: {{ $.Values.configFolder }} {{- if $.Values.editable }} - name: {{ $.Release.Name }}-develop mountPath: /dest @@ -103,6 +123,19 @@ spec: - name: {{ .Chart.Name }} image: '{{ .Values.image.repository }}{{ ternary "-debug" "" .Values.editable }}:{{ .Values.image.tag }}' {{- with .Values.securityContext }} + # a writable place to have cwd + workingDir: /tmp + env: + - name: HOME + value: /tmp + - name: TERM + value: xterm-256color + {{- with $.Values.env }} + {{- toYaml . | nindent 12}} + {{- end }} + {{- with $.Values.global.env }} + {{- toYaml . | nindent 12}} + {{- end }} securityContext: {{- toYaml . | nindent 12 }} {{- end }} @@ -138,11 +171,13 @@ spec: {{- with .Values.volumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} + {{- with $.Values.opisMountPoint }} - name: opis-volume - mountPath: /epics/opi - subPath: "{{ .Release.Name }}" + mountPath: {{ . }} + subPath: {{ $.Release.Name }} + {{- end }} - name: config-volume - mountPath: {{ .Values.iocConfig }} + mountPath: {{ .Values.configFolder }} {{- if .Values.editable }} - name: {{ .Release.Name }}-develop mountPath: /workspaces @@ -155,9 +190,15 @@ spec: {{- with .Values.volumes }} {{- toYaml . | nindent 8 }} {{- end }} + # if a mount point has been specified, claim a PVC to mount + # the PVC name will be ixx-epics-opis for IOCs (created in $opisClaim above) + # the PVC name must be specified in values.yaml for non-IOC services + {{- if .Values.opisMountPoint | default false }} - name: opis-volume persistentVolumeClaim: - claimName: {{ $opisClaim }} + # use the supplied claim name or default to one based on ioc_group + claimName: {{ $.Values.opisClaimName | default $opisClaim }} + {{- end }} - name: config-volume configMap: name: {{ .Release.Name }}-config diff --git a/Charts/fastcs/values.schema.json b/Charts/fastcs/values.schema.json index 88c13160..3abb884b 100644 --- a/Charts/fastcs/values.schema.json +++ b/Charts/fastcs/values.schema.json @@ -34,6 +34,10 @@ "description": "command to run for the production container", "type": "array" }, + "configFolder": { + "description": "path to the location of config folder", + "type": "string" + }, "debugCommand": { "description": "command to run for the debugging (non- autostart) container", "type": "array", @@ -45,6 +49,21 @@ "description": "editable and autostart are used for debugging and development in-cluster", "type": "boolean" }, + "env": { + "description": "Add environment to individual services", + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + }, "extraContainers": { "description": "Add arbitrary containers to the pod", "type": "array", @@ -71,6 +90,23 @@ "global": { "description": "shared values for all services", "type": "object", + "properties": { + "env": { + "description": "Add environment to all services", + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + }, "additionalProperties": true }, "hostNetwork": { @@ -99,9 +135,9 @@ "type": "string" } }, - "iocConfig": { - "description": "path to the location of config folder (defaults to be the same as C++ IOCs)", - "type": "string" + "is_ioc": { + "description": "set to true of IOCs in services repos", + "type": "boolean" }, "livenessProbe": { "$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/livenessProbe", @@ -111,6 +147,14 @@ "$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/nodeSelector", "type": "object" }, + "opisClaim": { + "description": "name of the PVC to use to store opi files, leave blank for IOCs - will then default to ixx-epics-opis", + "type": "string" + }, + "opisMountPoint": { + "description": "where to mount the opis volume inside the container", + "type": "string" + }, "podAnnotations": { "description": "Add annotations to the pod", "type": "object" diff --git a/Charts/fastcs/values.yaml b/Charts/fastcs/values.yaml index 9ade52dc..b4d597c6 100644 --- a/Charts/fastcs/values.yaml +++ b/Charts/fastcs/values.yaml @@ -10,7 +10,12 @@ # @schema description: shared values for all services # @schema additionalProperties: true -global: {} +global: + # @schema description: Add environment to all services + env: [] + +# @schema description: Add environment to individual services +env: [] # @schema description: container image URI image: @@ -62,8 +67,17 @@ editable: false # true: entrypoint is command above autostart: true -# @schema description: path to the location of config folder (defaults to be the same as C++ IOCs) -iocConfig: /epics/ioc/config +# @schema description: path to the location of config folder +configFolder: /config + +# @schema description: name of the PVC to use to store opi files, leave blank for IOCs - will then default to ixx-epics-opis +opisClaim: "" + +# @schema description: where to mount the opis volume inside the container +opisMountPoint: "" + +# @schema description: set to true of IOCs in services repos +is_ioc: false # @schema description: service port for Channel Access ca_server_port: 5064