Skip to content

Commit

Permalink
update to copier template 4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 6, 2024
1 parent d6bae33 commit 839b707
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 35 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
35 changes: 33 additions & 2 deletions .github/workflows/ci_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,33 @@

ROOT=$(realpath $(dirname ${0})/../..)
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/*
for service in ${ROOT}/services/*/ # */ to skip files
do

### Lint each service chart and validate if schema given ###
service_name=$(basename $service)
cp -r $service ${ROOT}/.ci_work/$service_name
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/$service_name:/services/$service_name \
alpine/helm:3.14.3 \
-c "helm dependency update /services/$service_name"
$docker run --rm --entrypoint bash \
-v ${ROOT}/.ci_work/$service_name:/services/$service_name \
-v ${ROOT}/services/values.yaml:/services/values.yaml \
alpine/helm:3.14.3 \
-c "helm lint /services/$service_name --values /services/values.yaml"

### Valiate each ioc config ###
# Skip if subfolder has no config to validate
if [ ! -f "${service}/config/ioc.yaml" ]; then
continue
Expand All @@ -27,10 +48,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}))
4 changes: 2 additions & 2 deletions services/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# shared beamline values for all services
# shared values for all services

global:
ioc_group: p45
Expand Down Expand Up @@ -33,4 +33,4 @@ ioc-instance:
- key: nodetype
operator: Equal
value: test-rig
effect: NoSchedule
effect: NoSchedule

0 comments on commit 839b707

Please sign in to comment.