Skip to content

Commit 5245053

Browse files
committed
changes after review01 with Tom
1 parent a566af9 commit 5245053

15 files changed

+184
-159
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"cSpell.words": [
1616
"Beamlines",
1717
"blxxi",
18-
"blxxt"
18+
"blxxt",
19+
"klogout"
1920
]
2021
}

docs/developer/tutorials/dev-install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ requires python 3.8 or later) or to run in a container under `VSCode
4242

4343
.. code::
4444
45-
$ vscode epics-containers.github.io
45+
$ code epics-containers.github.io
4646
# Click on 'Reopen in Container' when prompted
4747
# Open a new terminal
4848

docs/user/explanations/k8s-resources.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/user/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ side-bar.
2222
tutorials/05a_ioc_changes
2323
tutorials/06_generic_ioc
2424
tutorials/07_support_module
25-
tutorials/08_new_support
2625

2726
+++
2827

@@ -59,7 +58,6 @@ side-bar.
5958
explanations/docs-structure
6059
explanations/repositories
6160
explanations/cli-tools
62-
explanations/k8s-resources
6361

6462
+++
6563

@@ -73,6 +71,8 @@ side-bar.
7371

7472
reference/faq
7573
reference/cli
74+
reference/ioc_helm_chart
75+
reference/k8s_resources
7676
../genindex
7777

7878
+++
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
IOC Helm Chart Details
2+
======================
3+
4+
IOC instances are described using a helm chart which in turn generates
5+
a Kubernetes manifest to tell Kubernetes what resources to create in order
6+
to run for the IOC instance.
7+
8+
Here we will look inside the template IOC instance in the template
9+
domain repository blxxi-template.
10+
11+
You can see these files in Github here:
12+
https://github.com/epics-containers/blxxi-template/tree/main/iocs/blxxi-ea-ioc-01
13+
14+
15+
Examine the Example IOC Instance
16+
--------------------------------
17+
18+
Take a look in the folder iocs/blxxi-ea-ioc-01. This contains a helm chart
19+
that defines the example IOC instance. To make new IOC instance you could
20+
copy this folder into your own domain repository's iocs folder. You would then
21+
need to rename it and make a few changes. Below is a description of the files
22+
in this folder and what you would need to change in your new IOC instance:
23+
24+
- ``Chart.yaml`` - this is the helm chart definition file. It contains
25+
metadata about the chart and a list of dependencies. Most of this file
26+
can be left as is for all IOC instances. But you do need to change these
27+
fields:
28+
29+
- ``name`` - the unique name for the chart and the IOC instance it represents.
30+
- ``Description`` - a short description of the IOC instance.
31+
32+
- ``values.yaml`` - this is the helm values file. It contains the values that
33+
are substituted in to the helm templates when the helm chart is built. Most
34+
of the values that go into an IOC instance chart will be drawn from
35+
domain defaults which can be found in the folder ``beamline-chart``. Values
36+
you need to supply here are:
37+
38+
- ``base_image`` - the generic IOC image to use for this IOC instance. A
39+
generic IOC image contains all the necessary support modules for a
40+
given class of device and a compiled IOC binary with all those modules
41+
linked. The IOC instance we are defining in a helm chart provides the startup
42+
script and possibly database that makes this IOC instance unique. In this
43+
case the generic IOC is for the area-detector simulator device.
44+
45+
- ``prefix`` - the EPICS PV prefix for this IOC instance. This will set an
46+
environment variable IOC_PREFIX which declares the prefix for the IOC's
47+
devIOCStats records. You can leave this value out if you use the ioc
48+
name as the prefix, but in this case we have used an uppercase version of
49+
IOC name as the prefix.
50+
51+
- ``templates/ioc.yaml`` this is the master template for this helm chart,
52+
it pulls in all the other templates from our dependencies. This file
53+
has to appear here but is boilerplate and should not need to be changed.
54+
55+
- ``config`` this folder contains any files unique to this IOC instance. At
56+
runtime on the cluster when the generic IOC image is running it will see
57+
these files as mounted into the folder ``/repos/epics/ioc/config``.
58+
In this case we have an EPICS startup script ``st.cmd`` only
59+
and the default behaviour is just to run the IOC binary and pass it
60+
``st.cmd``.
61+
62+
To see how the Generic IOC makes use of the config folder take a look
63+
at `this bash script`_ which runs on Generic IOC startup.
64+
65+
If you want to have completely custom behaviour in your IOC instance,
66+
you can place a bash script called ``start.sh`` in the config folder
67+
this will run in place of the above script.
68+
69+
70+
.. _this bash script: https://github.com/epics-containers/ioc-template/blob/main/ioc/start.sh

docs/user/reference/k8s_resources.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Kubernetes Resources in an IOC Instance
2+
=======================================
3+
4+
Learning about Helm and Kubernetes Manifests
5+
--------------------------------------------
6+
7+
It is instructive to see what helm is doing when you deploy an IOC.
8+
9+
Helm uses templates to generate a Kubernetes Manifest which defines a set
10+
of resources. It applies this manifest to the cluster using kubectl.
11+
12+
To inspect the kubernetes manifest YAML that is created when we deploy the
13+
example IOC you can use the following command from inside of your example
14+
beamline repository:
15+
16+
.. code-block:: bash
17+
18+
ec ioc template iocs/bl01t-ea-ioc-01
19+
20+
This is expanding the local helm chart in the ``iocs/bl01t-ea-ioc-01`` folder and using
21+
its ``templates/ioc.yaml`` plus the templates in ``helm-ioc-lib``. These templates
22+
are expanded using the values in the ``iocs/bl01t-ea-ioc-01/values.yaml`` file and also
23+
``beamline-chart/values.yaml`` and finally the default ``values.yaml`` file
24+
from the helm-ioc-lib.
25+
26+
For a description of the key resources we create in this Kubernetes manifest
27+
see the next heading.
28+
29+
30+
Kubernetes Resources in an IOC Instance
31+
---------------------------------------
32+
33+
TODO - This is a work in progress.
34+
35+
The key resources that we are asking Kubernetes to create are:
36+
37+
- ``Deployment``. Tells Kubernetes to run one and only one generic IOC
38+
container. See deployments:
39+
40+
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

docs/user/tutorials/01_setup_workstation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ EPICS, WSL2 and more.
1919
.. Note::
2020

2121
**DLS Users**: RHEL 8 Workstations at DLS have podman installed by default.
22-
You can access vscode with ``module load vscode``. RHEL 7 Workstations
22+
You can access VSCode with ``module load vscode``. RHEL 7 Workstations
2323
are not supported.
2424

2525
Options

docs/user/tutorials/02_devcontainer.rst

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ container definition is in https://github.com/epics-containers/.devcontainer.
1616
Configure Visual Studio Code
1717
----------------------------
1818

19-
For podman users, you must first tell vscode to use podman instead of docker.
20-
Open a vscode window and hit "ctrl ," (control-comma) to open the user
19+
For podman users, you must first tell VSCode to use podman instead of docker.
20+
Open a VSCode window and hit "ctrl ," (control-comma) to open the user
2121
settings editor and search for
2222
"dev.containers.dockerPath", change its value from "docker" to "podman".
2323

@@ -49,10 +49,10 @@ to reopen the folder in a container. Click on the ``Reopen in Container`` button
4949

5050
reopen in container dialogue
5151

52-
Now all of your vscode terminals and file explorer will be running inside of
52+
Now all of your VSCode terminals and file explorer will be running inside of
5353
the devcontainer and have access to all the tools installed there.
5454

55-
To verify things are working as expected, open a terminal in vscode from
55+
To verify things are working as expected, open a terminal in VSCode from
5656
the menus ``Terminal > New Terminal``. You should see a prompt like this:
5757

5858
.. code-block:: bash
@@ -77,7 +77,8 @@ Things to note:
7777
to ``/root``.
7878

7979
- Podman users are running as root inside the container but files will be
80-
written with your user id and group id.
80+
written with your user id and group id when writing to the mounted
81+
workspace folder (or your home directory).
8182

8283
.. _devcontainer-configure:
8384

@@ -90,79 +91,56 @@ Configuring the Devcontainer
9091
configured for interacting with the test beamline bl01t on the test
9192
cluster Pollux. HOWEVER: for this exercise we will use your personal
9293
GitHub account to avoid clashes with other users of this tutorial.
93-
Therefore follow the instructions below and for the KUBECONFIG setting
94-
use the following:
94+
Therefore follow the instructions below and set KUBECONFIG as follows:
9595

9696
.. code-block:: bash
9797
9898
# point at your cluster configuration file
9999
export KUBECONFIG=/home/${USER}/.kube/config_pollux
100100
101101
To enable access to the pollux cluster, execute the following commands
102-
from outside of the dev container:
102+
from OUTSIDE of the dev container:
103103

104104
.. code-block:: bash
105105
106106
module load pollux
107+
klogout
107108
.devcontainer/dls-copy-k8s-crt.sh # a script in the .devcontainer repo
108109
kubectl get nodes
109110
110-
The last command will ask for your fed-id and password and then show A
111-
list of nodes in the pollux cluster.
111+
The last command will ask for your fed-id and password and then show a
112+
list of nodes in the pollux cluster. Your credentials are cached for a
113+
week after which you will see authentication errors. To fix this
114+
repeat the above steps.
112115

113116
You devcontainer environment is configured by a file called
114117
``.bashrc_dev`` file. The terminals in the devcontainer will source this
115118
file when they start.
116119

117-
You can take a copy of ``.devcontainer/.bashrc_dev`` and place it in your
118-
home folder to customize it.
119-
i.e.:
120-
121-
122-
# IMPORTANT: use /home/$USER not $HOME
123-
cp .devcontainer/.bashrc_dev /home/${USER}/.bashrc_dev
124-
code /home/${USER}/.bashrc_dev
125-
126-
Alternatively you can take a fork of the .devcontainer repo and make your
127-
own version of the .bashrc_dev file in place.
128-
129-
Much of this file is setting up convenience features like prompt and bash
120+
Much of this file is setting up convenience features like the prompt and bash
130121
history. You can change these to suit your own preferences.
131122

132123
The primary configuration options are the environment variables exported by
133124
this script. These are listed below with some recommended values for running
134125
these tutorials. Paste the following into the ``.bashrc_dev`` file and
135-
change GITHUB_ORG to your GitHub organization or user.
126+
add your GitHub organization or user to K8S_HELM_REGISTRY.
136127

137128
.. code-block:: bash
138129
139130
############ REPLACE all environment below with your details ###################
140131
141-
# Github organization or user name
142-
export GITHUB_ORG=<YOUR GITHUB ORGANIZATION OR USER GOES HERE>
143-
144-
# point at your cluster configuration file
132+
# point at your cluster config file
145133
export KUBECONFIG=/home/${USER}/.kube/config
146134
147-
# the default beamline or domain for ec commands
148-
export BEAMLINE=t01 # equivalent to K8S_DOMAIN=bl01t
135+
# the default domain for ec commands (REMOVE if this is supplied by the host)
136+
export K8S_DOMAIN=bl01t
149137
150138
# where to get HELM charts for ec commands
151-
export K8S_HELM_REGISTRY=ghcr.io/${GITHUB_ORG}
139+
export K8S_HELM_REGISTRY=ghcr.io/<YOUR GITHUB USER OR ORGANIZATION>
152140
153-
# where to get container IMAGES for ec commands
154-
export K8S_IMAGE_REGISTRY=ghcr.io/${GITHUB_ORG}
141+
################################################################################
155142
156-
# the URL for the facility logging system
157-
export K8S_LOG_URL='none'
158-
159-
# set this to True to suppress output of commands in 'ec' CLI
160-
unset K8S_QUIET
161-
162-
# extra arguments to supply to containerized CLI commands
163-
export K8S_CLI_ARGS=''
164-
165-
After editing ``/home/$USER/.bashrc_dev`` you will need to close any open terminals and
143+
After editing ``.bashrc_dev`` you will need to close any open terminals and
166144
restart them to pick up the changes.
167145

168146

@@ -177,6 +155,9 @@ restart them to pick up the changes.
177155
In addition, you can alter the system packages installed in the container or make
178156
any other changes to the Dockerfile and regenerate your own container image.
179157

158+
To pick up such changes to ``.devcontainer`` run the ``Rebuild Container``
159+
command from VSCode command pallette (accessed via ctrl-shift-P).
160+
180161
If you wish to persist these changes
181162
then it is suggested that you make your own github repo of .devcontainer and
182163
push the changes there.

docs/user/tutorials/03_setup_k8s.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
Setup a Kubernetes Server
44
=========================
55

6+
.. note::
7+
8+
From this point onward the tutorials assume that you are using
9+
Kubernetes and Helm to deploy your EPICS IOCs.
10+
11+
However:
12+
13+
The approach of creating generic IOC's in containers and then deploying
14+
IOC instances as generic IOC's + some configuration will also work
15+
standalone, or with other orchestration tools. e.g. In `05a_ioc_changes`
16+
we will demonstrate running an IOC locally using podman alone.
17+
18+
If you want to take advantage of containers for IOCs but do not want to
19+
take on Kubernetes then there are some hints as to how to achieve this
20+
here: `../how-to/run_iocs`.
21+
622
Introduction
723
------------
824
This is a very easy set of instructions for setting up an experimental
@@ -12,7 +28,6 @@ ready to test deployment of EPICS IOCs.
1228
Bring Your Own Cluster
1329
----------------------
1430

15-
1631
If you already have a Kubernetes cluster then you can skip this section.
1732
and go straight to `./04_create_beamline`.
1833

docs/user/tutorials/04_create_beamline.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ repo in the future.
9090
sed -i 's/BLXXI/BL01T/g' $(find * -type f)
9191
sed -i 's/blxxi/bl01t/g' $(find * -type f)
9292
93-
#. Add your new repo to your vscode workspace and take a look at what you
93+
#. Add your new repo to your VSCode workspace and take a look at what you
9494
have.
9595

9696
From the VSCode menus: File->Add Folder to Workspace

0 commit comments

Comments
 (0)