Skip to content

Commit

Permalink
Merge pull request #33 from epics-containers/switch-namespace
Browse files Browse the repository at this point in the history
Switch namespace and update all to latest
  • Loading branch information
gilesknap authored Nov 7, 2024
2 parents d6bae33 + e84bccc commit 88813ae
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 63 deletions.
13 changes: 13 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 4.0.1
_src_path: gh:epics-containers/services-template-helm
cluster_name: pollux
cluster_namespace: p45-beamline
cluster_type: dls_cluster
description: p45 IOC Instances and Services
git_platform: github.com
github_org: epics-containers
ioc_group: p45
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}*
repo_uri: https://github.com/epics-containers/p45-services
1 change: 1 addition & 0 deletions .github/workflows/ci_skip_checks
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
daq-nexus
47 changes: 44 additions & 3 deletions .github/workflows/ci_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,45 @@
# other future services that don't use ibek, we will need to add a standard
# entrypoint for validating the config folder mounted at /config.

ROOT=$(realpath $(dirname ${0})/../..)
HERE=$(realpath $(dirname ${0}))
ROOT=$(realpath ${HERE}/../..)
set -xe
rm -rf ${ROOT}/.ci_work/
mkdir -p ${ROOT}/.ci_work

# use docker if available else use podman
if ! docker version &>/dev/null; then docker=podman; else docker=docker; fi

for service in ${ROOT}/services/*
# copy the services to a temporary location to avoid dirtying the repo
cp -r ${ROOT}/services/* ${ROOT}/.ci_work/

for service in ${ROOT}/services/*/ # */ to skip files
do
### Lint each service chart and validate if schema given ###
service_name=$(basename $service)

# skip services appearing in ci_skip_checks
checks=${HERE}/ci_skip_checks
if [[ -f ${checks} ]] && grep -q ${service_name} ${checks}; then
echo "Skipping ${service_name}"
continue
fi

schema=$(cat ${service}/values.yaml | sed -rn 's/^# yaml-language-server: \$schema=(.*)/\1/p')
if [ -n "${schema}" ]; then
echo "{\"\$ref\": \"$schema\"}" > ${ROOT}/.ci_work/$service_name/values.schema.json
fi

$docker run --rm --entrypoint bash \
-v ${ROOT}/.ci_work:/services \
alpine/helm:3.14.3 \
-c "
helm lint /services/$service_name --values /services/values.yaml &&
helm dependency update /services/$service_name &&
rm -rf /services/$service_name/charts
"

### Valiate each ioc config ###
# Skip if subfolder has no config to validate
if [ ! -f "${service}/config/ioc.yaml" ]; then
continue
Expand All @@ -27,10 +58,20 @@ 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

rm -r ${ROOT}/.ci_work
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**/*.tz
**/*.tgz
.history
**/*.bob
edm/bobs
**/*copy
**/charts/*tgz
venv*
.venv*
**/Chart.lock
**/charts
**/*copy
.ci_work
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# beamline bl45p IOC Instances and Services

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

The respository is deployed into the beamline cluster using Argo CD which keeps the cluster namespace bl45p in sync with the contents of this repo.

See apps.yaml for the root app of apps description.
# p45 IOC Instances and Services

This repository holds the a definition of p45 IOC Instances and services. Each sub folder of the `services` directory contains a helm chart for a specific service or IOC.
30 changes: 10 additions & 20 deletions environment.sh
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 bl45p IOCs and Services.
# to work with the p45 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 bl45p IOC Instances and Services ..."
echo "Loading environment for p45 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_NAMESPACE=bl45p
export EC_CLI_BACKEND="K8S"
# the namespace to use for kubernetes deployments
export EC_TARGET=p45-beamline
# the git repo for this project
export EC_SERVICES_REPO=git@github.com:epics-containers/bl45p.git
export EC_SERVICES_REPO=https://github.com/epics-containers/p45-services
# declare your centralised log server Web UI
export EC_LOG_URL="https://graylog.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

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}*"

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

Expand All @@ -46,17 +35,18 @@ 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=bl45p
kubectl config set-context --current --namespace=p45-beamline
# make sure the user has provided credentials
kubectl version


# enable shell completion for k8s tools
if [ -n "$ZSH_VERSION" ]; then SHELL=zsh; fi
source <(helm completion $(basename ${SHELL}))
source <(kubectl completion $(basename ${SHELL}))
source <(kubectl completion $(basename ${SHELL}))
2 changes: 1 addition & 1 deletion services/bl45p-ea-dcam-01/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
# dls-aravis is locally available via symlink in the charts directory
- name: dls-aravis
Expand Down
6 changes: 2 additions & 4 deletions services/bl45p-ea-dcam-01/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Arguments to the shared ioc instance template dls-aravis
# This will make an IOC instance for an aravis camera with a standard set
# of Areadetector plugins.
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/4.1.2/ioc-instance.schema.json

dls-aravis:
P: BL45P-EA-MAP-01
ID: bl45p-ea-detector-01

ioc-instance:
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.7.1
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.11.1
2 changes: 1 addition & 1 deletion services/bl45p-ea-dcam-02/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
# dls-aravis is locally available via symlink in the charts directory
- name: dls-aravis
Expand Down
5 changes: 4 additions & 1 deletion services/bl45p-ea-dcam-02/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/4.1.2/ioc-instance.schema.json

# Arguments to the shared ioc instance template dls-aravis
# This will make an IOC instance for an aravis camera with a standard set
# of Areadetector plugins.
Expand All @@ -7,4 +9,5 @@ dls-aravis:
ID: bl45p-ea-detector-02

ioc-instance:
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.7.1
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.11.1
location: bl45p # TODO remove me when schema is fixed
4 changes: 2 additions & 2 deletions services/bl45p-mo-brick-01/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
7 changes: 5 additions & 2 deletions services/bl45p-mo-brick-01/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-pmac/releases/download/2024.3.1/ibek.ioc.schema.json

# todo update ioc-pmac to latest ibek (__utils__ is old)
ioc_name: "{{ __utils__.get_env('IOC_NAME') }}"
ioc_name: "{{ _global.get_env('IOC_NAME') }}"

description: auto-generated by https://github.com/epics-containers/builder2ibek

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

- type: epics.EpicsCaMaxArrayBytes
max_bytes: 6000000

Expand Down
7 changes: 3 additions & 4 deletions services/bl45p-mo-brick-01/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# yaml-language-server: $schema=https://github.com/marcelldls/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/4.1.2/ioc-instance.schema.json/#/$defs/service

# latest container image for the pmac motion controller
ioc-instance:
image: ghcr.io/epics-containers/ioc-pmac-runtime:2024.5.1


image: ghcr.io/epics-containers/ioc-pmac-runtime:2024.9.1
location: bl45p # TODO remove me when schema is fixed
4 changes: 2 additions & 2 deletions services/bl45p-mo-panda-01/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
5 changes: 3 additions & 2 deletions services/bl45p-mo-panda-01/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# yaml-language-server: $schema=https://github.com/marcelldls/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/4.1.2/ioc-instance.schema.json/#/$defs/service

# latest container image for GigE cameras from the GitHub Container Registry
ioc-instance:
image: ghcr.io/pandablocks/pandablocks-ioc:0.9.0
image: ghcr.io/pandablocks/pandablocks-ioc:0.11.2

# this causes our config folder's start.sh to be mounted over the default
# /epics/ioc/start.sh - thus making the pandaBlocks container image have
# the same entrypoint as ioc-template based images
iocConfig: /epics/ioc
location: bl45p # TODO remove me when schema is fixed
4 changes: 2 additions & 2 deletions services/bl45p-mo-panda-02/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
5 changes: 3 additions & 2 deletions services/bl45p-mo-panda-02/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# yaml-language-server: $schema=https://github.com/marcelldls/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/4.1.2/ioc-instance.schema.json/#/$defs/service

# latest container image for GigE cameras from the GitHub Container Registry
ioc-instance:
image: ghcr.io/pandablocks/pandablocks-ioc:0.9.0
image: ghcr.io/pandablocks/pandablocks-ioc:0.11.2

# this causes our config folder's start.sh to be mounted over the default
# /epics/ioc/start.sh - thus making the pandaBlocks container image have
# the same entrypoint as ioc-template based images
iocConfig: /epics/ioc
location: bl45p # TODO remove me when schema is fixed
6 changes: 5 additions & 1 deletion services/dls-aravis/config/ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ ioc_name: "[[ _global.get_env('IOC_NAME') ]]"
description: shared template for all Aravis cameras on p45

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

- type: epics.EpicsCaMaxArrayBytes
max_bytes: 6000000

Expand All @@ -16,7 +20,7 @@ entities:
IOC: "[[ ioc_name | upper ]]"

- type: ADAravis.aravisCamera
CLASS: {{ .Values.CLASS}}
CLASS: {{ .Values.CLASS }}
ID: {{ .Values.ID }}
P: {{ .Values.P }}
PORT: DET.DET
Expand Down
4 changes: 2 additions & 2 deletions services/p45-ea-test-01/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
16 changes: 13 additions & 3 deletions services/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# shared beamline values for all services
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/4.1.2/ioc-instance.schema.json/#/$defs/service
# shared values for all services

global:
ioc_group: p45
Expand All @@ -9,6 +10,7 @@ ioc-instance:
# useHostNetwork - use host network for IOC - required for Channel Access
# to work outside of the cluster
hostNetwork: true
location: bl45p # TODO remove me when schema is fixed

# affinity and tolerations to get the right nodes on pollux
securityContext:
Expand All @@ -19,7 +21,15 @@ ioc-instance:
pvc: false
hostPath: /dls/p45/data

useAffinity: true
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: beamline
operator: In
values:
- bl45p

tolerations:
- key: beamline
Expand All @@ -33,4 +43,4 @@ ioc-instance:
- key: nodetype
operator: Equal
value: test-rig
effect: NoSchedule
effect: NoSchedule

0 comments on commit 88813ae

Please sign in to comment.