Skip to content

Commit cd376f0

Browse files
authored
Merge pull request #4 from DiamondLightSource/helm-chart2
Add Run in cluster Capability
2 parents 897a60d + a9f9645 commit cd376f0

File tree

10 files changed

+202
-106
lines changed

10 files changed

+202
-106
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
if: always()
2020
uses: ./.github/workflows/_container.yml
2121
with:
22-
publish: ${{ needs.test.result == 'success' }}
22+
# publish is always true as there is no tests for dev-c7 at present
23+
publish: true
2324
permissions:
2425
contents: read
2526
packages: write

Charts/dev-c7/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ version: 0.1.0
1111

1212
# This is the version number of the application being deployed. It implies the
1313
# the version tag of the container image.
14-
appVersion: 2025.5.1
14+
appVersion: 2025.9.1-beta.2

Charts/dev-c7/templates/deployment.yaml

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{{- /*
2+
Default the derivable substitution values.
3+
4+
This keeps the length of the values.txt file for each individual IOC
5+
to a minimum
6+
*/ -}}
7+
{{- $location := default .Values.global.location .Values.location | required "ERROR - You must supply location or global.location" -}}
8+
{{- $ioc_group := default .Values.global.ioc_group .Values.ioc_group | required "ERROR - You must supply ioc_group or global.ioc_group" -}}
9+
{{- $image := .Values.image | required "ERROR - You must supply image." -}}
10+
11+
{{- $enabled := eq .Values.global.enabled false | ternary false true -}}
12+
13+
apiVersion: apps/v1
14+
kind: StatefulSet
15+
metadata:
16+
name: {{ .Release.Name }}
17+
labels:
18+
app: {{ .Release.Name }}
19+
location: {{ $location }}
20+
ioc_group: {{ $ioc_group }}
21+
enabled: {{ $enabled | quote }}
22+
is_ioc: "true"
23+
spec:
24+
replicas: {{ $enabled | ternary 1 0 }}
25+
selector:
26+
matchLabels:
27+
app: {{ .Release.Name }}
28+
template:
29+
metadata:
30+
{{- with .Values.podAnnotations }}
31+
annotations:
32+
{{- toYaml . | nindent 8 }}
33+
{{- end }}
34+
labels:
35+
app: {{ .Release.Name }}
36+
location: {{ $location }}
37+
ioc_group: {{ $ioc_group }}
38+
is_ioc: "true"
39+
spec:
40+
hostNetwork: {{ .Values.hostNetwork }}
41+
{{- with .Values.imagePullSecrets }}
42+
imagePullSecrets:
43+
{{- toYaml . | nindent 8 }}
44+
{{- end }}
45+
terminationGracePeriodSeconds: 2
46+
{{- with .Values.podSecurityContext }}
47+
securityContext:
48+
{{- toYaml . | nindent 8 }}
49+
{{- end }}
50+
containers:
51+
- name: {{ .Chart.Name }}
52+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
53+
command:
54+
{{- .Values.command | toYaml | nindent 12 }}
55+
stdin: true
56+
tty: true
57+
{{- $domain := (.Values.ioc_domain | default $location) | upper }}
58+
{{- $ioc_name := (.Values.ioc_name | default .Release.Name) | upper }}
59+
{{ $workingDir := "" }} {{- /* create the variable in global scope before setting in if/else!!! */ -}}
60+
{{- if .Values.ioc_path }}
61+
{{- $workingDir = printf "%s/%s" .Values.ioc_path $ioc_name }}
62+
{{- else }}
63+
{{- $workingDir = printf "/dls_sw/prod/%s/ioc/%s/%s/%s" .Values.epics_version $domain $ioc_name .Values.ioc_version }}
64+
{{- end }}
65+
workingDir: {{ $workingDir }}
66+
{{- with .Values.securityContext }}
67+
securityContext:
68+
{{- toYaml . | nindent 12 }}
69+
{{- end }}
70+
env:
71+
# psuedo home sets up epics module etc.
72+
- name: HOME
73+
value: /epics_home
74+
imagePullPolicy: {{ .Values.image.pullPolicy }}
75+
{{- with .Values.livenessProbe }}
76+
livenessProbe:
77+
{{- toYaml . | nindent 12 }}
78+
{{- end }}
79+
{{- with .Values.readinessProbe }}
80+
readinessProbe:
81+
{{- toYaml . | nindent 12 }}
82+
{{- end }}
83+
{{- with .Values.resources }}
84+
resources:
85+
{{- toYaml . | nindent 12 }}
86+
{{- end }}
87+
{{- with .Values.volumeMounts }}
88+
volumeMounts:
89+
{{- toYaml . | nindent 12 }}
90+
{{- end }}
91+
{{- with .Values.volumes }}
92+
volumes:
93+
{{- toYaml . | nindent 8 }}
94+
{{- end }}
95+
{{- with .Values.nodeSelector }}
96+
nodeSelector:
97+
{{- toYaml . | nindent 8 }}
98+
{{- end }}
99+
{{- with .Values.affinity }}
100+
affinity:
101+
{{- toYaml . | nindent 8 }}
102+
{{- end }}
103+
{{- with .Values.tolerations }}
104+
tolerations:
105+
{{- toYaml . | nindent 8 }}
106+
{{- end }}

Charts/dev-c7/values.schema.json

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/affinity.json",
99
"type": "object"
1010
},
11+
"command": {
12+
"description": "container entry point command",
13+
"type": "array",
14+
"items": {
15+
"type": "string"
16+
}
17+
},
18+
"epics_version": {
19+
"description": "the EPICS version, used to generate the /dls_sw/prod path to ioc_name",
20+
"type": "string"
21+
},
1122
"fullnameOverride": {
1223
"type": "string"
1324
},
@@ -38,6 +49,22 @@
3849
"imagePullSecrets": {
3950
"type": "array"
4051
},
52+
"ioc_domain": {
53+
"description": "the IOC domain (e.g. BL16I FE02J SR03C)",
54+
"type": "string"
55+
},
56+
"ioc_name": {
57+
"description": "the folder name for the compiled IOC, defaults to ucase of the services folder name",
58+
"type": "string"
59+
},
60+
"ioc_path": {
61+
"description": "overrides the parent folder for ioc_name to any path in /dls_sw/work or /dls_sw/prod",
62+
"type": "string"
63+
},
64+
"ioc_version": {
65+
"description": "the IOC release, used to generate the /dls_sw/prod path to ioc_name",
66+
"type": "string"
67+
},
4168
"nameOverride": {
4269
"type": "string"
4370
},
@@ -57,10 +84,6 @@
5784
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/securityContext",
5885
"type": "object"
5986
},
60-
"replicaCount": {
61-
"description": "Set to 0 to stop the IOC, 1 to run the IOC",
62-
"type": "integer"
63-
},
6487
"resources": {
6588
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/resources",
6689
"type": "object"
@@ -73,12 +96,6 @@
7396
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/tolerations",
7497
"type": "array"
7598
},
76-
"userId": {
77-
"type": "integer"
78-
},
79-
"userName": {
80-
"type": "string"
81-
},
8299
"volumeMounts": {
83100
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/volumeMounts",
84101
"type": "array",

Charts/dev-c7/values.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@
88
# With annotations for building the schema using:
99
# https://github.com/losisin/helm-values-schema-json.git
1010

11+
# @schema description: the folder name for the compiled IOC, defaults to ucase of the services folder name
12+
ioc_name: ""
13+
# @schema description: the IOC release, used to generate the /dls_sw/prod path to ioc_name
14+
ioc_version: ""
15+
# @schema description: the IOC domain (e.g. BL16I FE02J SR03C)
16+
ioc_domain: ""
17+
# @schema description: the EPICS version, used to generate the /dls_sw/prod path to ioc_name
18+
epics_version: R3.14.12.7
19+
20+
# @schema description: overrides the parent folder for ioc_name to any path in /dls_sw/work or /dls_sw/prod
21+
ioc_path: ""
22+
1123
# @schema description: shared values for all services
1224
# @schema additionalProperties: true
1325
global: {}
1426

15-
# @schema description: Set to 0 to stop the IOC, 1 to run the IOC
16-
replicaCount: 1
17-
1827
# @schema description: container image URI
1928
image:
2029
repository: ghcr.io/diamondlightsource/dev-c7
@@ -23,9 +32,11 @@ image:
2332
# Overrides the image tag whose default is the chart appVersion.
2433
tag: ""
2534

26-
# these must be filled
27-
userId: 1200288
28-
userName: hgv27681
35+
# @schema description: container entry point command
36+
command:
37+
- bash
38+
- -lc
39+
- stdio-expose ./bin/linux-x86_64/st*.sh
2940

3041
# @schema description: enable host networking for the pod
3142
hostNetwork: false
@@ -72,9 +83,6 @@ volumes:
7283
- name: etc
7384
hostPath:
7485
path: /dls_sw/etc
75-
- name: home
76-
hostPath:
77-
path: /home/hgv27681
7886

7987
# volumeMounts for the Deployment.
8088
# @schema $ref: $k8s/container.json#/properties/volumeMounts
@@ -97,8 +105,6 @@ volumeMounts:
97105
- name: etc
98106
mountPath: /dls_sw/etc
99107
readOnly: true
100-
- name: home
101-
mountPath: /home/hgv27681
102108

103109
# @schema $ref: $k8s/podspec.json#/properties/tolerations
104110
tolerations: []

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,20 @@ RUN yum remove -y git git-core && \
7474
# change the nobody account and group IDs to match RedHat
7575
RUN sed -i 's/99:99/65534:65534/' /etc/passwd && \
7676
sed -i 's/:99:/:65534:/' /etc/group
77+
78+
# Install uv using the official image
79+
# See https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
80+
COPY --from=ghcr.io/astral-sh/uv:0.8 /uv /uvx /bin/
81+
WORKDIR /opt
82+
83+
ENV UV_PYTHON_INSTALL_DIR=/python
84+
ENV PATH="${PATH}:/opt/.venv/bin"
85+
86+
# Add in stdio socket for sharing the epics console
87+
RUN uv venv --managed-python --python 3.12 && \
88+
uv pip install stdio-socket && \
89+
chmod -R a+rwX /opt/.venv
90+
91+
# Make a psuedo home directory for running in cluster
92+
COPY epics_home /epics_home
93+
RUN chmod a+rws /epics_home

epics_home/.bashrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
3+
# Source global definitions
4+
if [ -f /etc/bashrc ]; then
5+
. /etc/bashrc
6+
fi
7+
8+
# Source global definitions
9+
if [ -f ~/bashrc_local ]; then
10+
. ~/.bashrc_local
11+
fi
12+
13+
module load epics/3.14.12.7
14+
15+
alias console=/opt/.venv/bin/console

epics_home/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# epics_home
2+
3+
This is a psuedo home directory for launching EPICS IOCs in-cluster using dev-c7.
4+
5+
It allows us to have a writeable home directory and also to set up the module system with .bashrc. This in turn lets us load the epics module and gives access to caRepeater amoungst other things.

schemas/dev-c7.service.schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"properties": {
5+
"dev-c7": {
6+
"$ref": "dev-c7.values.schema.json",
7+
"type": "object",
8+
"additionalProperties": false
9+
}
10+
},
11+
"additionalProperties": false
12+
}

0 commit comments

Comments
 (0)