Skip to content

Commit d86f031

Browse files
committed
add deploying instances tutorial
1 parent bfd12cf commit d86f031

File tree

9 files changed

+132
-182
lines changed

9 files changed

+132
-182
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
# to complete as the docs build warns and fails.
153153
html_theme_options = dict(
154154
logo=dict(
155-
text=project,
155+
text="EPICS Containers",
156156
),
157157
navigation_with_keys=True,
158158
use_edit_page_button=True,

docs/user/images/bl01t-actions.png

46 KB
Loading

docs/user/images/edm_sim.png

-21.6 KB
Binary file not shown.

docs/user/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ side-bar.
1717
tutorials/setup_workstation
1818
tutorials/create_beamline
1919
tutorials/deploy_example
20+
tutorials/create_ioc
2021
tutorials/ioc_changes
21-
tutorials/release_beamline
2222
tutorials/generic_ioc
2323
tutorials/debug_generic_ioc
2424
tutorials/test_generic_ioc

docs/user/tutorials/create_beamline.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ Wrapping Up
174174
-----------
175175

176176
You should now have a working beamline repository. It contains a single
177-
IOC Instance and that is only a non-functional example. In the following
178-
tutorials we will investigate the example and then create a real IOC Instance.
177+
IOC Instance which is a non-functional example. In the following
178+
tutorial we will investigate the example and then create a real IOC Instance.
179179

180180
You can now push the repository up to GitHub and give it a version tag like this:
181181

@@ -185,7 +185,7 @@ You can now push the repository up to GitHub and give it a version tag like this
185185
git commit -m "changed blxxi to bl01t"
186186
git push
187187
git tag 2023.11.1
188-
git push --tags
188+
git push origin 2023.11.1
189189
190190
191191
We use ``CalVer`` version numbers for beamline repositories and Generic IOCs.

docs/user/tutorials/create_ioc.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Create a Working Example IOC Instance
2+
=====================================
3+
4+
Introduction
5+
------------
6+
7+
The last section covered deploying and managing the example Instance that
8+
came with the template beamline repository. Here we will create a new
9+
IOC Instance that implements a simulated detector.
10+
11+
TODO - complete this.
12+
13+
.. figure:: ../images/c2dv.png
14+
15+
the c2dv viewer showing an image from the example IOC
Lines changed: 110 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,49 @@
1-
Deploy The Example IOC
2-
======================
3-
4-
.. Warning::
5-
6-
This tutorial is out of date and will be updated soon.
1+
Deploying and Managing IOC Instances
2+
====================================
73

84
Introduction
95
------------
106

11-
This tutorial will show you how to deploy some IOC Instances to the test
12-
beamline bl01t. You will need to have your own bl01t beamline repository
7+
This tutorial will show you how to deploy and manage the example IOC Instance
8+
that came with the template beamline repository.
9+
You will need to have your own ``bl01t`` beamline repository
1310
from the previous tutorial.
1411

1512
For these early tutorials we are not using Kubernetes and instead are deploying
16-
IOCs to the local docker or podman instance. So for the this tutorial we
13+
IOCs to the local docker or podman instance. So for these tutorials we
1714
shall pretend that your workstation is one of the IOC servers on the fictitious
18-
beamline BL01T.
15+
beamline ``BL01T``.
16+
17+
Continuous Integration
18+
----------------------
19+
20+
Before we change anything, we shall make sure that the beamline repository CI
21+
is working as expected. To do this go to the following URL (make sure you insert
22+
your GitHub account name where indicated):
23+
24+
.. code::
1925
20-
Take a Look at Your Project's Continuous Integration
21-
----------------------------------------------------
26+
[email protected]:**YOUR GITHUB ACCOUNT**/bl01t/actions
2227
23-
Before we change anything we shall make sure that the beamline repository CI
24-
is working as expected. To do this go to the following URL:
28+
You should see something like the following:
2529

26-
-
30+
.. figure:: ../images/bl01t-actions.png
31+
32+
the GitHub Actions page for the example beamline repository
33+
34+
This is a list of all the Continuous Integration (CI) jobs that have been
35+
executed (or are executing) for your beamline repository. There should be
36+
two jobs listed, one for when you pushed the main branch and one for when you
37+
tagged with the ``CalVer`` version number.
38+
39+
If you click on the most recent job you can drill in and see the steps that
40+
were executed. The most interesting step is ``Run bash ./ci_verify.sh``. This
41+
is executing the script in the root of your beamline repository that verifies
42+
each IOC instance in the ``iocs`` folder. In future we can make this script
43+
more sophisticated when we have simulated hardware to test against.
44+
45+
For the moment just check that your CI passed and if not review that you
46+
have followed the instructions in the previous tutorial correctly.
2747

2848
Set up Environment for BL01T Beamline
2949
-------------------------------------
@@ -45,38 +65,28 @@ where indicated):
4565
4666
cd /tmp
4767
curl -o ~/.local/bin/bl01t https://raw.githubusercontent.com/**YOUR GITHUB ACCOUNT**/bl01t/main/environment.sh?token=$(date +%s)
48-
. ~/.bash_profile
49-
. bl01t
68+
source ~/.bash_profile
69+
source bl01t
5070
5171
Once you have done this and logged out and back in again to pick up your new
52-
profile you should be able enable the bl01t environment as follows:
72+
profile you should be able enable the ``bl01t`` environment as follows:
5373

5474
.. code-block:: bash
5575
56-
. bl01t
76+
# first make sure you have loaded your virtual environment
77+
source $HOME/ec-venv/bin/activate
78+
source bl01t
5779
5880
59-
Deploy the IOC Instance to Kubernetes
60-
-------------------------------------
81+
Deploy the Example IOC Instance
82+
-------------------------------
6183

62-
For this tutorial we are going to work with the example IOC bl01t-ea-ioc-01
63-
that came with our beamline repository from the previous tutorial.
64-
Here we will deploy the IOC into our cluster and then learn how to interact
65-
with it.
84+
For this section we will be making use of the epics-containers-cli tool.
85+
This command line entry point for the tool is ``ec``. For more
86+
details see: `CLI` or try ``ec --help``.
6687

67-
If you are interested in the detail of what is in the bl01t-ea-ioc-01 folder
68-
that describes this IOC instance then see: `../reference/ioc_helm_chart`.
69-
70-
Also, if you are interested in how the helm chart manifests itself in your
71-
cluster when deployed then see: `../reference/k8s_resources`.
72-
73-
For this section we will be making use of the epics-containers-cli tool. This makes
74-
it easier to interact with kubernetes and helm from the command line and is
75-
described in more detail here: `CLI`.
76-
77-
You will need a working Kubernetes cluster for most of the rest of the
78-
tutorials. You can verify that it is working by asking for a list of IOCs
79-
running in your default domain as follows:
88+
The simplest command to check that the tool is working is ``ps`` which lists
89+
the IOC Instances that are currently running:
8090

8191
.. code-block:: bash
8292
@@ -85,134 +95,115 @@ running in your default domain as follows:
8595
You should see some headings and an empty list as you have not yet started an
8696
IOC Instance.
8797

88-
.. note::
89-
90-
The command ``ec`` is the epics-containers command line utilities entry
91-
point. For more information see `CLI` or try ``ec --help``.
92-
93-
94-
The following command will deploy the example IOC instance to your cluster
95-
(if you changed the ioc name in the previous tutorial then
96-
remember to change bl01t-ea-ioc-01 to your unique name here):
98+
The following command will deploy the example IOC instance to your local
99+
machine (unless you have skipped ahead and set up your Kubernetes config
100+
in which case the same command will deploy to your Kubernetes cluster).
97101

98102
.. code-block:: bash
99103
100-
ec ioc deploy bl01t-ea-ioc-01 23.4.1
101-
102-
Note that this is looking for the IOC's helm chart in your OCI helm registry.
103-
You delivered the IOC helm chart to the registry when you made a release of
104-
the beamline repo in the previous tutorial. You must supply a version number
105-
that exists. If you do not recall the version number you used in the last tutorial,
106-
you can use the following command to list the versions available in your
107-
registry:
108-
109-
.. code-block:: bash
104+
cd bl01t # (if you are not already in your beamline repo)
105+
ec ioc deploy-local iocs/bl01t-ea-ioc-01
110106
111-
ec ioc versions bl01t-ea-ioc-01
107+
You will be prompted to say that this is a *TEMPORARY* deployment. This is
108+
because we are deploying directly from the local filesystem. You should only
109+
use this for testing purposes because there is no guarantee that you could
110+
ever roll back to this version of the IOC (as it is lost as soon as filesystem
111+
changes are made). Local filesystem deployments are given a beta version
112+
number to indicate that they are not permanent.
112113

113-
As the deployment is progressing you could use the following command to
114-
monitor the progress (hit ctrl-C to stop following the logs):
114+
You can now see the beta IOC instance running with:
115115

116116
.. code-block:: bash
117117
118-
ec ioc logs bl01t-ea-ioc-01 -f
119-
120-
Note there may be a little delay while the cluster pulls the Generic IOC
121-
image from the GitHub container registry. The error
122-
"recGblRecordError: devStringinEnvVar (init_record) Illegal INP parm field Illegal field value PV: BL01T-EA-IOC-01:TIMEZONE"
123-
is benign, TODO: take a look at the cause of this error.
118+
$ ec ps
119+
IOC NAME VERSION STATUS IMAGE
120+
bl01t-ea-ioc-01 2023.10.26-b11.53 Up 6 minutes ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2023.10.5
124121
125-
Once the IOC is running you can find out the IP address of the pod it is
126-
running in with:
122+
At the end of the last tutorial we tagged the beamline repository with a
123+
``CalVer`` version number and pushed it up to GitHub. This means that we
124+
can now release the IOC instance with that same version number. First let's
125+
check that the IOC instance version is available as expected:
127126

128127
.. code-block:: bash
129128
130-
ec ps -w
131-
132-
This will show you the status of the IOC instance and the IP address of the
133-
pod it is running in. In a real beamline setup the IOCs would run in the same
134-
subnet as your workstation so you would not care about the IP address. But
135-
for the example you may need to do the following to let our EPICS clients
136-
know where to look for PVs:
137-
138-
.. code-block:: bash
129+
$ ec ioc instances bl01t-ea-ioc-01
130+
Available instance versions for bl01t-ea-ioc-01:
131+
2023.11.1
139132
140-
export EPICS_CA_ADDR_LIST=ip_address_of_pod
141-
export EPICS_PVA_ADDR_LIST=ip_address_of_pod
142133
143-
epics-containers does not yet have any provision for EPICS operator interfaces.
144-
For this example we have hand crafted some EDM screens to control and monitor
145-
the test IOC. These EDM screens are supplied in the template so you will
146-
have them in the ``opi`` folder in your beamline repository.
147-
148-
You can now launch the client applications as follows:
134+
Now that we know the latest version number we can deploy a release version.
135+
This command will extract the IOC instance using the tag from GitHub and deploy
136+
it to your local machine:
149137

150138
.. code-block:: bash
151139
152-
./blxxi-ea-ioc-01-gui.sh
153-
c2dv --pv $USER-EA-TST-01:IMAGE
154-
155-
Now make sure the AreaDetector is Acquiring by clicking Start if needed on
156-
the CAM screen. Next click on Auto to scale the
157-
black and white thresholds on the C2D viewer. You should see something like the
158-
following images.
159-
160-
.. figure:: ../images/edm_sim.png
161-
162-
edm screen for the example IOC
140+
$ ec ioc deploy bl01t-ea-ioc-01 2023.11.1
141+
bdbd155d437361fe88bce0faa0ddd3cd225a9026287ac5e73545aeb4ab3a67e9
163142
164-
.. figure:: ../images/c2dv.png
143+
$ ec ps
144+
IOC NAME VERSION STATUS IMAGE
145+
bl01t-ea-ioc-01 2023.11.1 Up 4 seconds ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2023.10.5
165146
166-
the c2dv viewer showing an image from the example IOC
167147
168-
169-
Managing IOCs
170-
--------------
171-
172-
IOCs running in Kubernetes can be managed using the ``ec`` command.
148+
Managing the Example IOC Instance
149+
---------------------------------
173150

174151
Starting and Stopping IOCs
175152
~~~~~~~~~~~~~~~~~~~~~~~~~~
176153

177-
To stop / start the example IOC:
154+
To stop / start the example IOC try the following commands. Note that
155+
``ec ps -a`` shows you all IOCs including stopped ones.
178156

179157
.. code-block:: bash
180158
159+
ec ps -a
181160
ec ioc stop bl01t-ea-ioc-01
161+
ec ps -a
182162
ec ioc start bl01t-ea-ioc-01
163+
ec ps
164+
165+
.. Note::
166+
167+
Generic IOCs.
168+
169+
You may have noticed that the IOC instance has is showing that it has
170+
an image ``ghcr.io/epics-containers/ioc-adsimdetector-linux-runtime:2023.10.5``.
171+
172+
This is a Generic IOC image and all IOC Instances must be based upon one
173+
of these images. This IOC instance has no startup script and is therefore
174+
not functional, it could have been based on any Generic IOC.
183175

184176
Monitoring and interacting with an IOC shell
185177
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
186178

187-
To attach to the ioc shell:
179+
To attach to the ioc shell you can use the following command. HOWEVER, this
180+
will attach you to nothing in the case of this example IOC as it has no
181+
shell. In the next tutorial we will use this command to interact with
182+
iocShell.
188183

189184
.. code-block:: bash
190185
191186
ec ioc attach bl01t-ea-ioc-01
192187
193-
Use the command sequence ctrl-P then ctrl-Q to detach or ctrl-D to restart the
194-
IOC and detach.
195-
196-
TODO: I'm having issues with the shell eating the ^P^Q sequences so
197-
at present you can only detach from the IOC by killing the terminal or
198-
using ^D.
188+
Use the command sequence ctrl-P then ctrl-Q to detach from the IOC
189+
You can also usually restart and detach from the IOC using ctrl-D or
190+
ctrl-C.
199191

200192
To run a bash shell inside the IOC container:
201193

202194
.. code-block:: bash
203195
204196
ec ioc exec bl01t-ea-ioc-01
205197
206-
Once you have a shell inside the container you can inspect the following
198+
Once you have a shell inside the container you could inspect the following
207199
folders:
208200

209201
=============== ==============================================================
210-
ioc code repos/epics/ioc
211-
support modules repos/epics/support
212-
epics binaries repos/epics/epics-base
202+
ioc code /epics/ioc
203+
support modules /epics/support
204+
EPICS binaries /epics/epics-base
213205
=============== ==============================================================
214206

215-
216207
Logging
217208
~~~~~~~
218209

@@ -228,6 +219,9 @@ Or follow the IOC log until you hit ctrl-C:
228219
229220
ec ioc logs bl01t-ea-ioc-01 -f
230221
222+
You will notice that this IOC simply prints out a message regarding what
223+
you can place in the /epics/ioc/config folder. In the next tutorial
224+
we will look at how to configure a real EPICS IOC.
231225

232226

233227

0 commit comments

Comments
 (0)