Skip to content

Commit

Permalink
update to new services-template-helm template
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Aug 16, 2024
1 parent 988f338 commit 9607c31
Show file tree
Hide file tree
Showing 21 changed files with 202 additions and 102 deletions.
17 changes: 8 additions & 9 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 3.4.0
_src_path: gh:epics-containers/ec-services-template
beamline: bl47p
_commit: 0.2.4
_src_path: gh:epics-containers/services-template-helm
cluster_name: pollux
cluster_namespace: p47-iocs
cluster_type: dls_shared
description: beamline bl47p IOC Instances and Services
cluster_namespace: p47-beamline
cluster_type: dls_cluster
description: p47 IOC Instances and Services
git_platform: github.com
github_org: epics-containers
ioc_group: p47
location: bl45p
logging_url: https://graylog2.diamond.ac.uk/search?rangetype=relative&fields=message%2Csource&width=1489&highlightMessage=&relative=172800&q=pod_name%3A{service_name}*
node_type: training-rig
repo_uri: git@github.com:epics-containers/bl47p.git
type: beamline
repo_uri: https://github.com/epics-containers/p47-services
9 changes: 8 additions & 1 deletion .github/workflows/ci_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ do
if [ -n "${image}" ]; then
echo "Validating ${service} with ${image}"

runtime=/tmp/ioc-runtime/$(basename ${service})
mkdir -p ${runtime}

# This will fail and exit if the ioc.yaml is invalid
$docker run --rm --entrypoint bash \
-v ${service}/config:/config ${image} \
-v ${service}/config:/config \
-v ${runtime}:/epics/runtime \
${image} \
-c 'ibek runtime generate /config/ioc.yaml /epics/ibek-defs/*'
# show the startup script we just generated (and verify it exists)
cat ${runtime}/st.cmd

fi
done
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**/*.tz
**/*.tgz
.history
venv*
.venv*
**/Chart.lock
**/charts
**/*.bob
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# beamline bl47p IOC Instances and Services

This repository holds the a definition of beamline bl47p IOC Instances and services. Each sub folder of the `services` directory contains a helm chart for a specific service or IOC.

NOTE: in order to take advantage of version control, you must deploy these services using the edge-containers-cli. This will ensure that the services are deployed from a specific tag of this repository and that the version number is recorded in the cluster.

See https://github.com/epics-containers/edge-containers-cli for more information.
# p47 IOC Instances and Services

This repository holds the a definition of p47 IOC Instances and services. Each sub folder of the `services` directory contains a helm chart for a specific service or IOC.
28 changes: 7 additions & 21 deletions environment.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
#!/bin/bash

# a bash script to source in order to set up your command line to in order
# to work with the bl47p IOCs and Services.
# to work with the p47 IOCs and Services.

# check we are sourced
if [ "$0" = "$BASH_SOURCE" ]; then
echo "ERROR: Please source this script"
exit 1
fi

echo "Loading environment for beamline bl47p IOC Instances and Services ..."
echo "Loading environment for p47 IOC Instances and Services ..."

#### SECTION 1. Environment variables ##########################################

# a mapping between generic IOC repo roots and the related container registry
# use spaces or line breaks to separate multiple mappings by default this
# inlcudes mappings for github and DLS gitlab, add your own here.
export EC_REGISTRY_MAPPING_REGEX='
.*github.com:(.*)\/(.*) ghcr.io/\1/\2
.*gitlab.diamond.ac.uk.*\/(.*) gcr.io/diamond-privreg/controls/prod/ioc/\1
'
# the namespace to use for kubernetes deployments - use local for local docker/podman
export EC_K8S_NAMESPACE=p47-iocs
export EC_CLI_BACKEND="K8S"
# the namespace to use for kubernetes deployments
export EC_TARGET=p47-beamline
# the git repo for this project
export EC_SERVICES_REPO=git@github.com:epics-containers/bl47p.git
export EC_SERVICES_REPO=https://github.com/epics-containers/p47-services
# declare your centralised log server Web UI
export EC_LOG_URL="https://graylog2.diamond.ac.uk/search?rangetype=relative&fields=message%2Csource&width=1489&highlightMessage=&relative=172800&q=pod_name%3A{service_name}*"
# enforce a specific container cli - defaults to whatever is available
# export EC_CONTAINER_CLI=podman
# enable debug output in all 'ec' commands
# export EC_DEBUG=1


#### SECTION 2. Install ec #####################################################

Expand All @@ -47,13 +36,12 @@ source <(ec --show-completion ${SHELL})
#### SECTION 3. Configure Kubernetes Cluster ###################################



# the following configures kubernetes inside DLS.

module unload pollux > /dev/null
module load pollux > /dev/null
# set the default namespace for kubectl and helm (for convenience only)
kubectl config set-context --current --namespace=p47-iocs
kubectl config set-context --current --namespace=p47-beamline
# make sure the user has provided credentials
kubectl version

Expand All @@ -62,5 +50,3 @@ kubectl version
if [ -n "$ZSH_VERSION" ]; then SHELL=zsh; fi
source <(helm completion $(basename ${SHELL}))
source <(kubectl completion $(basename ${SHELL}))


11 changes: 11 additions & 0 deletions services/.ioc_template/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# A Helm Chart for an IOC instance
apiVersion: v2
name: ec-service
version: 1.0.0

type: application

dependencies:
- name: ioc-instance
version: 3.5.2+b11
repository: "oci://ghcr.io/epics-containers"
16 changes: 16 additions & 0 deletions services/.ioc_template/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-template-example/releases/download/3.5.1/ibek.ioc.schema.json

# TODO replace above with the generic IOC schema this IOC is based on
ioc_name: "{{ _global.get_env('IOC_NAME') }}"

description: REPLACE WITH DESCRIPTION

entities:
- type: epics.EpicsEnvSet
name: EPICS_TZ
value: GMT0BST

- type: devIocStats.iocAdminSoft
IOC: "{{ ioc_name | upper }}"

# - todo: Add more entities to make a meaningful IOC
10 changes: 10 additions & 0 deletions services/.ioc_template/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-config
labels:
app: {{ .Release.Name }}
data:

# contents of the ioc instance config folder
{{ (.Files.Glob "config/*").AsConfig | indent 2 }}
21 changes: 21 additions & 0 deletions services/.ioc_template/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service
ioc-instance:
image: REPLACE_WITH_IMAGE_URI

# NOTE: the following are suggestions to help with debugging IOCs
# 1. replace the runtime container with the developer version
# this adds tools and compilers to the container so you
# can experiment in the cluster to fix the issue
#
# image: ghcr.io/epics-containers/ioc-adsimdetector-developer:2024.4.1

# 2. override the entry point to be a sleep infinity
# this means you can now use 'ec exec' to get a shell
# in the container and run /epics/ioc/start.sh.
# If it fails you can see the error and the pod
# will not terminate. In combination with 1. above you
# can experiment with changes until the issue
# is fixed.
#
# startCommand: sleep
# startArgs: infinity
9 changes: 2 additions & 7 deletions services/epics-opis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
apiVersion: v2
name: epics-opis

version: 3.4.0

# When we deploy with the edge-containers-cli we override this on the command line.
# Direct deployment with Helm will use the default beta value.
appVersion: 0.0.1b1
version: 1.0.0

type: application

dependencies:
- name: epics-opis
version: "3.4.0"
#repository: "file:///scratch/hgv27681/work/ec-helm-charts/Charts/epics-opis"
version: 3.5.2+b11
repository: "oci://ghcr.io/epics-containers"
12 changes: 0 additions & 12 deletions services/epics-opis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,3 @@ epics-opis Helm Chart
=====================

Installs the web server that shares the engineering screens published by each IOC. The structure is two deep only: IOC names as folders at the root containing all the IOCs OPI files in a flat list.

Deploy this chart to the cluster by setting up your cluster namespace connection using environment.sh and then executing
the following commands:

```bash
# lists the latest versions of all services
ec list
# deploy the latest version of the epics-pvcs which includes an opis volume
ec deploy epics-pvcs VERSION
# deploy the latest version of the epics-opis service
ec deploy epics-opis VERSION
```
23 changes: 2 additions & 21 deletions services/epics-opis/values.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
epics-opis:


# the beamline name - only set for beamlines
beamline: bl47p
# the location where the IOCs will run - same as beamline for beamlines
ioc_group: bl47p
location: bl45p
# the name of the repository in which the IOC is grouped
location: bl47p

# useAffinity - only run on nodes with label beamline:<beamline-name>
# or location:<location-name>
# Comment out useAffiniity for dedicated cluster, set to true for shared cluster

useAffinity: true


# extra toleration for the shared cluster training rigs
tolerations:
- key: "nodetype"
operator: "Equal"
value: "training-rig"
effect: "NoSchedule"

ioc_group: p47
11 changes: 3 additions & 8 deletions services/epics-pvcs/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
apiVersion: v2
name: epics-pvcs

version: 3.4.0

# When we deploy with the edge-containers-cli we override this on the command line.
# Direct deployment with Helm will use the default beta value.
appVersion: 0.0.1b1
version: 1.0.0

type: application

dependencies:
- name: epics-pvcs
version: "3.4.0"
# repository: "file:///scratch/hgv27681/work/ec-helm-charts/Charts/epics-pvcs"
repository: "oci://ghcr.io/epics-containers"
version: 3.5.2+b11
repository: "oci://ghcr.io/epics-containers"
10 changes: 0 additions & 10 deletions services/epics-pvcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,3 @@ Sets up the PVCs that all IOCs may use. These should be set up once and not dele
- autosave data: for IOCs that support autosave. This is separate from IOC helm charts so that it can survive deletion and re-creation of an IOC.

- opis: all the OPI files for engineering screens that an IOC supplies are saved here. This is stored in a single PVC so that the opis service can publish them over http for access by an OPI client.

Deploy this chart to the cluster by setting up your cluster namespace connection using environment.sh and then executing
the following commands:

```bash
# lists the latest versions of all services
ec list
# deploy the latest version of the epics-pvcs
ec deploy epics-pvcs VERSION
```
9 changes: 3 additions & 6 deletions services/epics-pvcs/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
epics-pvcs:

# the beamline name - only set for beamlines
beamline: bl47p
# the location where the IOCs will run - same as beamline for beamlines
ioc_group: bl47p
# the location where the IOCs will run
location: bl45p
# the name of the repository in which the IOC is grouped
location: bl47p
ioc_group: p47
11 changes: 11 additions & 0 deletions services/p47-ea-test-01/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# A Helm Chart for an IOC instance
apiVersion: v2
name: ec-service
version: 1.0.0

type: application

dependencies:
- name: ioc-instance
version: 3.5.2+b11
repository: "oci://ghcr.io/epics-containers"
26 changes: 26 additions & 0 deletions services/p47-ea-test-01/config/ioc.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
record(calc, "P47:IBEK:SUM") {
field(DESC, "Sum A and B")
field(CALC, "A+B")
field(INPA, "P47:IBEK:A")
field(INPB, "P47:IBEK:B")
}

record(ao, "P47:IBEK:A") {
field(DESC, "A voltage")
field(PREC, "3")
field(EGU, "Volts")
field(DRVL, "-10")
field(DRVH, "+10")
field(VAL, "0.000")
field(FLNK, "P47:IBEK:SUM")
}

record(ao, "P47:IBEK:B") {
field(DESC, "B voltage")
field(PREC, "3")
field(EGU, "Volts")
field(DRVL, "-10")
field(DRVH, "+10")
field(VAL, "0.000")
field(FLNK, "P47:IBEK:SUM")
}
28 changes: 28 additions & 0 deletions services/p47-ea-test-01/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-template/releases/download/2024.1.1/ibek.ioc.schema.json

ioc_name: "{{ __utils__.get_env('IOC_NAME') }}"

description: Generic instance for testing generic IOCs

entities:
- type: epics.EpicsEnvSet
name: EPICS_TZ
value: "GMT0BST"

- type: devIocStats.iocAdminSoft
IOC: "{{ ioc_name | upper }}"

- type: epics.StartupCommand
command: dbLoadRecords("/epics/ioc/config/ioc.db")

- type: epics.dbpf
pv: P47:IBEK:A
value: "2.54"

- type: epics.dbpf
pv: P47:IBEK:B
value: "2.61"

- type: epics.PostStartupCommand
command: |
dbgf P47:IBEK:SUM
10 changes: 10 additions & 0 deletions services/p47-ea-test-01/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-config
labels:
app: {{ .Release.Name }}
data:

# contents of the ioc instance config folder
{{ (.Files.Glob "config/*").AsConfig | indent 2 }}
Loading

0 comments on commit 9607c31

Please sign in to comment.