diff --git a/.copier-answers.yml b/.copier-answers.yml new file mode 100644 index 0000000..b75dd85 --- /dev/null +++ b/.copier-answers.yml @@ -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 diff --git a/.github/workflows/ci_verify.sh b/.github/workflows/ci_verify.sh index 2b71890..077b6c8 100755 --- a/.github/workflows/ci_verify.sh +++ b/.github/workflows/ci_verify.sh @@ -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 @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 842d6fc..7777862 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ +**/*.tz +**/*.tgz .history -**/*.bob -edm/bobs -**/*copy -**/charts/*tgz +venv* +.venv* **/Chart.lock +**/charts +**/*copy +.ci_work \ No newline at end of file diff --git a/README.md b/README.md index e9297ce..f94e8b4 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/environment.sh b/environment.sh index a1f6109..09096b4 100644 --- a/environment.sh +++ b/environment.sh @@ -1,7 +1,7 @@ #!/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 @@ -9,28 +9,17 @@ if [ "$0" = "$BASH_SOURCE" ]; then 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 ##################################################### @@ -46,12 +35,13 @@ 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 @@ -59,4 +49,4 @@ 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})) \ No newline at end of file +source <(kubectl completion $(basename ${SHELL})) diff --git a/services/values.yaml b/services/values.yaml index dee3839..0a91840 100644 --- a/services/values.yaml +++ b/services/values.yaml @@ -1,4 +1,4 @@ -# shared beamline values for all services +# shared values for all services global: ioc_group: p45 @@ -33,4 +33,4 @@ ioc-instance: - key: nodetype operator: Equal value: test-rig - effect: NoSchedule \ No newline at end of file + effect: NoSchedule