Skip to content

Commit 0f81100

Browse files
authored
Merge pull request #15 from epics-containers/dev
added tutorial 05
2 parents 8b5f79b + ce19861 commit 0f81100

File tree

7 files changed

+169
-19
lines changed

7 files changed

+169
-19
lines changed

docs/user/how-to/run_iocs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ thing as the above podman command:
4848

4949
.. code-block:: bash
5050
51-
ec ioc-launch iocs/bl01t-ea-ioc-01 --tag 23.3.3
51+
ec dev ioc-launch iocs/bl01t-ea-ioc-01 --tag 23.3.3
5252
5353
That is because ``ioc-launch`` is intended for locally testing an IOC instance
5454
that is destined for Kubernetes.

docs/user/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ side-bar.
1919
tutorials/03_setup_k8s
2020
tutorials/04_create_beamline
2121
tutorials/05_deploy_example
22-
tutorials/05a_ioc_changes
23-
tutorials/06_generic_ioc
24-
tutorials/07_support_module
22+
tutorials/06_ioc_changes
23+
tutorials/07_generic_ioc
24+
tutorials/08_support_module
2525

2626
+++
2727

docs/user/tutorials/03_setup_k8s.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Setup a Kubernetes Server
1212

1313
The approach of creating generic IOC's in containers and then deploying
1414
IOC instances as generic IOC's + some configuration will also work
15-
standalone, or with other orchestration tools. e.g. In `05a_ioc_changes`
15+
standalone, or with other orchestration tools. e.g. In `06_ioc_changes`
1616
we will demonstrate running an IOC locally using podman alone.
1717

1818
If you want to take advantage of containers for IOCs but do not want to

docs/user/tutorials/05a_ioc_changes.rst

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
Testing Changes to IOC Instances
2+
================================
3+
4+
5+
Types of Changes
6+
----------------
7+
8+
Containerized IOCs can be modified in 3 distinct places:
9+
10+
#. The IOC instance: this means making changes to the IOC instance helm chart
11+
which appears in the ``iocs`` folder of a beamline or accelerator domain
12+
source repository. This includes things like:
13+
14+
- changing the EPICS DB (or files that generate it)
15+
- altering the iocShell boot script (or files that generate it)
16+
- changing parameters in the values file for the chart - e.g. increasing
17+
the memory limit for the IOC container
18+
19+
#. The Generic IOC - alter the details of how the Generic IOC container image
20+
is built. This means making changes to an ``ioc-XXX`` source repo and
21+
publishing a new version of the Generic IOC container image.
22+
This includes things like:
23+
24+
- changing the EPICS base version
25+
- changing the versions of EPICS support modules compiled into the IOC binary
26+
- adding new support modules
27+
- altering the system dependencies installed into the container image
28+
29+
#. The dependencies - Support modules used by the generic IOC. Changes to support
30+
module repos. This means publishing a new release of the support module.
31+
32+
As far as possible the epics-containers approach to all of the above allows
33+
local testing of the changes before publishing. This allows us to have a
34+
fast 'inner loop' of development and testing.
35+
36+
Also, epics-containers provides a mechanism for creating a separate workspace for
37+
working on all of the above elements in one place.
38+
39+
Changing the IOC Instance
40+
-------------------------
41+
42+
This tutorial will make a very simple change to the example IOC ``bl01t-ea-ioc-01``.
43+
This is a type 1. change from the above list, types 2, 3 will be covered in the
44+
following 2 tutorials.
45+
46+
We are going to add a hand crafted EPICS DB file to the IOC instance. This will
47+
be a simple record that we will be able to query to verify that the change
48+
is working.
49+
50+
Make the following changes in your test IOC config folder
51+
(``bl01t/iocs/bl01t-ea-ioc-01/config``):
52+
53+
1. Add a file called ``extra.db`` with the following contents:
54+
55+
.. code-block:: text
56+
57+
record(ai, "BL01T-EA-IOC-01:TEST") {
58+
field(DESC, "Test record")
59+
field(DTYP, "Soft Channel")
60+
field(SCAN, "Passive")
61+
field(VAL, "1")
62+
}
63+
64+
2. Add the following line to the ``st.cmd`` file after the last ``dbLoadRecords``
65+
line:
66+
67+
.. code-block:: text
68+
69+
dbLoadRecords(config/extra.db)
70+
71+
Locally Testing Your changes
72+
----------------------------
73+
74+
You can immediately test your changes by running the IOC locally. The following
75+
command will run the IOC locally using the config files in your test IOC config
76+
folder:
77+
78+
.. code-block:: bash
79+
80+
ec dev ioc-launch iocs/bl01t-ea-ioc-01 --tag 23.3.4
81+
82+
The ``--tag`` option specifies the version of the Generic IOC container to use
83+
and this means it will be pulled from the container registry (or come from
84+
the cache if it has already been pulled).
85+
If you do not supply a tag then ``ec`` will look for a local copy of the
86+
container to use, we will cover this in `07_generic_ioc`.
87+
88+
If all is well you should see your iocShell prompt and you can test your change
89+
from another terminal (VSCode menus -> Terminal -> New Terminal) like so:
90+
91+
.. code-block:: bash
92+
93+
caget BL01T-EA-IOC-01:TEST
94+
95+
If you see the value 1 then your change is working.
96+
97+
Note you can see your running IOC in podman using this command:
98+
99+
.. code-block:: bash
100+
101+
podman ps
102+
103+
You should see a container named bl01t-ea-ioc-01 and also a another one with a
104+
random name and an image called ``localhost/vsc-work...``. The latter is the
105+
container that is running your developer environment.
106+
107+
If you would like to take a look inside the container you can run a bash shell
108+
in the container like this:
109+
110+
.. code-block:: bash
111+
112+
podman exec -it bl01t-ea-ioc-01 bash
113+
114+
When you type exit on the iocShell the container will stop and and be removed.
115+
116+
Deploying a Beta IOC Instance to The Cluster
117+
============================================
118+
119+
In ``05_deploy_example`` we deployed a tagged version of the IOC instance to
120+
the cluster. This the correct way to deploy a production IOC instance as it
121+
means there is a record of version of the IOC instance in the Helm Chart
122+
OCI registry and you can always roll back to that version if needed.
123+
124+
However, it is also possible to directly deploy a version of the IOC instance
125+
from your local machine to the cluster.
126+
This is useful for testing changes to the IOC instance
127+
before publishing a new version. In this case
128+
your IOC will be given a beta tag in the cluster, indicating that it has
129+
not yet been released.
130+
131+
To deploy your changes direct to the cluster use the following command:
132+
133+
.. code-block:: bash
134+
135+
ec ioc deploy-local iocs/bl01t-ea-ioc-01
136+
137+
You will get a warning that this is a temporary deployment and you will see that
138+
the version number will look something like ``2023.3.29-b14.29`` this
139+
indicates that this is a beta deployment made at 14:29 on 29th March 2023.
140+
141+
Now when you ask for the IOCs running in your domain you should see your IOC
142+
with beta version listed:
143+
144+
.. code-block:: bash
145+
146+
$ ec ps -w
147+
POD VERSION STATE RESTARTS STARTED IP GENERIC_IOC_IMAGE
148+
bl01t-ea-ioc-01-7d7c5bc759-5bjsr 2023.3.29-b14.29 Running 0 2023-03-29T14:29:18Z 192.168.0.32 ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:23.3.4
149+
150+
You can check it is working as before (replace the IP with yours
151+
from the above command):
152+
153+
.. code-block:: bash
154+
155+
export EPICS_CA_ADDR_LIST=192.168.0.32
156+
caget BL01T-EA-IOC-01:TEST
157+
158+
Once you are happy with your changes you can push and tag your beamline repo.
159+
This will publish a new version of the IOC instance helm chart to the OCI helm
160+
registry. You can then deploy the versioned IOC instance to the cluster.
161+
162+
163+
164+
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)