Skip to content

Commit 31175fb

Browse files
committed
deploy example updated
1 parent 0166c46 commit 31175fb

File tree

4 files changed

+78
-142
lines changed

4 files changed

+78
-142
lines changed

docs/tutorials/create_beamline.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ NOTE: for these tutorials we will use your personal GitHub Account to store ever
4646

4747
1. Use copier to copy the services template repository to a new repository named `t01-services`. Note that there are two services templates, one for local deployments (using docker compose) and one for deployments to Kubernetes. We will use the local deployment template here.
4848

49+
Note the benefits of using copier to create a new repository:
50+
- you can template the repository and use questions to fill in the template, making a unique result.
51+
- if the template changes in future you can merge the changes into you repository without losing your changes, simply by running `copier update .`.
52+
4953
```bash
5054
copier copy gh:epics-containers/services-template-compose t01-services
5155
```

docs/tutorials/deploy_example.md

Lines changed: 50 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ is working as expected. To do this go to the following URL (make sure you insert
1313
your GitHub account name where indicated):
1414

1515
```
16-
https://github.com/YOUR_GITHUB_ACCOUNT/bl01t/actions
16+
https://github.com/YOUR_GITHUB_ACCOUNT/t01-services/actions
1717
```
1818

1919
You should see something like the following:
@@ -36,152 +36,75 @@ have valid configuration.
3636
For the moment just check that your CI passed and if not review that you
3737
have followed the instructions in the previous tutorial correctly.
3838

39-
(setup-beamline-bl01t)=
39+
(setup-beamline-t01)=
4040
## Set up Environment for the t01 Beamline
4141

42-
It is much easier to investigate the commands available to you with command line completion enabled. You need only do the following steps once to permanently enable this feature.
42+
Make sure you have a terminal open and the current working directory is your `t01-services` project root folder.
4343

44-
```bash
45-
# these steps will make cli completion work for bash
46-
mkdir -p ~/.local/share/bash-completion/completions
47-
docker completion bash > ~/.local/share/bash-completion/completions/docker
48-
49-
# these steps will make cli completion work for zsh
50-
mkdir -p ~/.oh-my-zsh/completions
51-
docker completion zsh > ~/.oh-my-zsh/completions/_docker
52-
```
53-
54-
The standard way to set up your environment for any ec services repository is to get the environment.sh script from the domain repository and source it.
55-
56-
Start this section of the tutorial inside the vscode project that you created in the previous tutorial. Make sure you have a terminal open and the current working directory is your `bl01t` project root folder.
57-
58-
First make sure you have the local binaries folder in your path by adding
59-
the following to the end of your `$HOME/.bash_profile` file:
44+
The standard way to set up your environment for any ec services repository is to source the environment.sh script from the root of the services repo. i.e.
6045

6146
```bash
6247
source ./environment.sh
6348
```
6449

50+
The environment file is the same for all local deployment services projects and sets up the following. The defaults supplied are all intended for developer workstation use:-
51+
52+
- **UIDGID** Used to set which account and group containers are launched with. This is always 0:0 for podman and USERID:GROUPID for docker. Only required for developer workstations.
53+
- **COMPOSE_PROFILES** Determines which compose profile is launched. Defaults to the 'develop' profile intended for developer workstations. It runs a ca-gateway container that publishes PVs on localhost and a container for phoebus to provide an OPI.
54+
- **EPICS_CA_ADDR_LIST** Set to localhost so that host caget's can see the containerised IOC PVs on a developer workstation.
55+
6556

6657
(deploy-example-instance)=
6758
## Deploy the Example IOC Instance
6859

69-
For this section we will be making use of the epics-containers-cli tool.
70-
This command line entry point for the tool is `ec`. For more
71-
details see: {any}`CLI` or try `ec --help`.
72-
73-
The simplest command to check that the tool is working is `ps` which lists
74-
the IOC Instances that are currently running:
60+
To launch all the services described by the `compose.yml` file in the root of the services repository, make sure your current working directory is still the root of your your `t01-services` project and run the following command:
7561

7662
```bash
77-
ec ps
63+
docker compose up -d
7864
```
7965

80-
You should see no IOCs listed as you have not yet started an IOC Instance.
81-
82-
The following command will deploy the example IOC instance to your local
83-
machine (unless you have skipped ahead and set up your Kubernetes config
84-
in which case the same command will deploy to your Kubernetes cluster).
85-
86-
```bash
87-
cd bl01t # (if you are not already in your beamline repo)
88-
ec deploy-local services/bl01t-ea-test-01
89-
```
66+
The `up` command tells compose to make sure all of the services are up and running. The `-d` flag tells compose to detach and run the services in the background. If you don't specify -d then your terminal will attach to the stdout of the services and you will see their output as they start up. This can be useful and is done with colour coding so you can distinguish between the different services (terminal colours must be enabled).
9067

91-
You will be prompted to say that this is a *TEMPORARY* deployment. This is
92-
because we are deploying directly from the local filesystem. You should only
93-
use this for testing purposes because there is no guarantee that you could
94-
ever roll back to this version of the IOC (as it is lost as soon as filesystem
95-
changes are made). Local filesystem deployments are given a beta version
96-
number to indicate that they are not permanent.
97-
98-
You can now see the beta IOC instance running with:
99-
100-
<pre>$ ec ps
101-
| name | version | running | restarts | deployed |
102-
|------------------|---------------|---------|----------|---------------------|
103-
| bl01t-ea-test-01 | 2024.3.8e8b-b | true | 0 | 2024-03-19 10:08:15 |</pre>
104-
105-
At the end of the last tutorial we tagged the beamline repository with a
106-
`CalVer` version number and pushed it up to GitHub. This means that we
107-
can now use that tagged release of the IOC instance. First let's
108-
check that the IOC instance version is available as expected. The following
109-
command lists all of the tagged versions of the IOC instance that are
110-
available in the GitHub repository.
111-
112-
<pre>$ ec instances bl01t-ea-test-01
113-
| version |
114-
|----------|
115-
| 2024.3.1 |
116-
</pre>
117-
118-
:::{note}
119-
The above command is the first one to look at your github repository.
120-
This is how it finds out the versions
121-
of the IOC instance that are available. If you get an error it may be
122-
because you set EC_SERVICES_REPO incorrectly in environment.sh. Check it
123-
and source it again to pick up any changes.
124-
:::
68+
There will be a short delay the first time while the container images are downloaded from the GitHub container registry to your local image cache. Subsequent runs will be much faster.
12569

126-
:::{hint}
127-
ec supports command line completion, which means that entering `<tab> <tab>` will give hints on the command line:
70+
The default example project will launch:
12871

129-
```bash
130-
$ ec <tab> <tab>
131-
attach deploy exec list logs start template
132-
delete deploy-local instances log-history restart stop validate
133-
$ ec instances b<tab> <tab>
134-
$ ec instances bl01t-ea-ioc-01
135-
```
72+
- a basic IOC instance with a few records
73+
- a ca-gateway container that publishes the IOC PVs on localhost
74+
- a phoebus container that can be used to view the IOC PVs using an example bob file that comes with the template.
13675

137-
To enable this behavior in your shell run the command `ec --install-completion`
138-
:::
13976

140-
Now that we know the latest version number we can deploy a release version.
141-
This command will extract the IOC instance using the tag from GitHub and deploy
142-
it to your local machine:
77+
You can see the status of the services by running the following command:
14378

14479
```bash
145-
$ ec deploy bl01t-ea-test-01 2024.3.1
146-
bdbd155d437361fe88bce0faa0ddd3cd225a9026287ac5e73545aeb4ab3a67e9
147-
148-
$ ec ps -w
149-
| name | version | running | restarts | deployed | image |
150-
|------------------|----------|---------|----------|---------------------|-------------------------------------------------------------------|
151-
| bl01t-ea-test-01 | 2024.3.1 | true | 0 | 2024-03-19 11:10:53 | ghcr.io/epics-containers/ioc-adsimdetectorruntime:2024.4.1 |
80+
docker compose ps
15281
```
15382

154-
### IMPORTANT: deploy-local vs deploy
155-
156-
Be aware of the distinction of `deploy-local` vs `deploy`. Both of these commands create a running instance of the IOC in the target environment (currently your local machine - later on a Kubernetes Cluster). However, `deploy-local` gets the IOC instance description YAML direct from your local filesystem. This means it is not likely to be available for re-deployment later on. `deploy` gets the IOC instance description YAML from the GitHub repository with a specific tag and therefore is a known state that can be recovered at a later date.
157-
158-
Always strive to have released versions of IOC instances deployed in your
159-
environments. `deploy-local` is only for temporary testing purposes.
83+
In environment.sh we created an alias for `docker compose` named `ec` from now on we'll shorten the commands to use `ec` instead of `docker compose`.
16084

16185
## Managing the Example IOC Instance
16286

16387
### Starting and Stopping IOCs
16488

165-
To stop / start the example IOC try the following commands. Note that
166-
`ec ps -a` shows you all IOCs including stopped ones.
89+
To stop / start the example IOC try the following commands. Note that `ec ps -a` shows you all IOCs including stopped ones.
90+
91+
Also note that tab completion should allow you to complete the names of your commands and services. e.g.
92+
`ec star <tab> ex <tab>`, should complete to `ec start example-test-01`.
16793

16894
```bash
16995
ec ps -a
170-
ec stop bl01t-ea-test-01
96+
ec stop example-test-01
17197
ec ps -a
172-
ec start bl01t-ea-test-01
98+
ec start example-test-01
17399
ec ps
174100
```
175101

176102
:::{Note}
177103
Generic IOCs.
178104

179-
You may have noticed that the IOC instance has is showing that it has
180-
an image `ghcr.io/epics-containers/ioc-adsimdetectorruntime:2024.4.1`.
105+
You may have noticed that the IOC instance has is showing that it has container image `ghcr.io/epics-containers/ioc-template-example-runtime:3.5.1`.
181106

182-
This is a Generic IOC image and all IOC Instances must be based upon one
183-
of these images. This IOC instance has no startup script and is therefore
184-
not functional, it could have been based on any Generic IOC.
107+
This is a Generic IOC image and all IOC Instances must be based upon one of these images. ioc-template-example-runtime is an instantiation of the template project for creating new Generic IOCs. It has only deviocstats support and no other support modules. This generic IOC can be used for serving records out of a database file as we have done in this example.
185108
:::
186109

187110
### Monitoring and interacting with an IOC shell
@@ -192,59 +115,49 @@ shell. In the next tutorial we will use this command to interact with
192115
iocShell.
193116

194117
```bash
195-
ec attach bl01t-ea-test-01
118+
ec attach example-test-01
119+
dbl
120+
# ctrl-p ctrl-q to detach
196121
```
197122

198-
Use the command sequence ctrl-P then ctrl-Q to detach from the IOC. **However,
199-
there are issues with both VSCode and IOC shells capturing ctrl-P. until
200-
this is resolved it may be necessary to close the terminal window to detach.**
201-
You can also restart and detach from the IOC using ctrl-D or ctrl-C, or
202-
by typing `exit`.
123+
Use the command sequence ctrl-P then ctrl-Q to detach from the IOC. **However, there are issues with both VSCode and IOC shells capturing ctrl-P**. Until this is resolved it may be necessary to close the terminal window to detach. You can also restart and detach from the IOC using ctrl-D or ctrl-C, or by typing `exit`. If you do this docker will restart your IOC right away.
203124

204125
To run a bash shell inside the IOC container:
205126

206127
```bash
207-
ec exec bl01t-ea-test-01
128+
ec exec example-test-01 bash
129+
caget EXAMPLE:SUM
208130
```
209131

210-
Once you have a shell inside the container you could inspect the following
211-
folders:
132+
Once you have a shell inside the container you could inspect the following folders. Because this is the runtime container you will only see the binaries and runtime files, not the source code:
212133

213134
```{eval-rst}
214-
=================== =======================================================
215-
ioc code /epics/ioc
216-
support modules /epics/support
217-
EPICS binaries /epics/epics-base
218-
IOC instance config /epics/ioc/config
219-
IOC startup script /epics/runtime
220-
=================== =======================================================
135+
================== ===================
136+
/epics/ioc ioc code
137+
/epics/ioc/start.sh IOC startup script
138+
/epics/support support modules
139+
/epics/epics-base EPICS base binaries
140+
/epics/ioc/config IOC instance config used to generate runtime files
141+
/epics/runtime IOC startup script and database file generated at runtime
142+
================== ===================
221143
```
222144

223-
Being at a terminal prompt inside the IOC container can be useful for debugging
224-
and testing. You will have access to caget and caput, plus other EPICS tools,
225-
and you can inspect files such as the IOC startup script.
145+
Being at a terminal prompt inside the IOC container can be useful for debugging and testing. You will have access EPICS command line tools including pvAccess, and you can inspect files such as the IOC startup script.
146+
147+
In the Virtual Machine supplied for testing epics-containers we do not install EPICS into the host environment. Instead you can use an IOC container when you need EPICS tools. Working this way makes your developer environment very portable, you only require docker or podman to work on any IOC project. It is equally possible to install EPICS on your host and use the host tools to interact with the IOC container, for the developer configuration you would just need to make sure `EPICS_CA_ADDR_LIST=127.0.0.1`.
226148

227149
### Logging
228150

229151
To get the current logs for the example IOC:
230152

231153
```bash
232-
ec logs bl01t-ea-test-01
154+
ec logs example-test-01
233155
```
234156

235157
Or follow the IOC log until you hit ctrl-C:
236158

237159
```bash
238-
ec logs bl01t-ea-test-01 -f
239-
```
240-
241-
You should see the log of ibek loading and generating the IOC startup assets and then the ioc shell startup script log.
242-
243-
You can also attach to the IOC and check that it has started correctly by using the 'dbl' command to list all the records in it's IOC database.
244-
245-
```bash
246-
ec attach bl01t-ea-test-01
247-
dbl
248-
# ctrl-p ctrl-q to detach
160+
ec logs example-test-01 -f
249161
```
250162

163+
You should see the log of ibek loading and generating the IOC startup assets and then the ioc shell startup script log. Ibek is the tool that runs inside of the IOC container and generates the ioc shell script and database file by interpreting the /epics/ioc/config/ioc.yaml at launch time.

docs/tutorials/ioc_changes1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ git push origin 2024.3.2
8989
ec deploy bl01t-ea-test-02 2024.3.2
9090
```
9191

92-
NOTE: the above assumes you have an active python virtual environment with the `edge-containers-cli` installed and you have sourced the beamline environment file (for a reminder of how to do this see {any}`setup-beamline-bl01t`).
92+
NOTE: the above assumes you have an active python virtual environment with the `edge-containers-cli` installed and you have sourced the beamline environment file (for a reminder of how to do this see {any}`setup-beamline-t01`).
9393

9494
You can now see that the versioned IOC instance is running and loading the extra.db by looking at its log with:
9595

docs/tutorials/setup_workstation.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ The docker install page encourages you to install Docker Desktop. This is a paid
8282

8383
### Docker Compose For Podman Users
8484

85-
docker compose allows you to define and run multi-container Docker applications. epics-containers uses it for describing a set of IOCs and other serial services that are deployed together.
85+
docker compose allows you to define and run multi-container Docker applications. epics-containers uses it for describing a set of IOCs and other services that are deployed together.
8686

8787
If you installed docker using the above instructions then docker compose is already installed. If you installed podman then you will need to install docker compose separately. We prefer to use docker-compose instead of podman-compose because it is more widely used and avoids behaviour differences between the two tools. If you are at DLS you just need to run 'module load docker-compose' to get access to docker compose with podman as the back end.
8888

89-
Other users of podman please see these instructions [rootless docker with docker-compose](https://connect.redhat.com/hydra/prm/v1/business/companies/0ed5e6899bce415b89d82cb334da214a/linked-resources/aa9ae6ada5f04000a66472cc0fc18160/content/public/view).
89+
Other users of podman please see these instructions [rootless podman with docker-compose](https://connect.redhat.com/hydra/prm/v1/business/companies/0ed5e6899bce415b89d82cb334da214a/linked-resources/aa9ae6ada5f04000a66472cc0fc18160/content/public/view).
9090

9191
### Important Notes Regarding docker and podman
9292

@@ -99,8 +99,27 @@ in your `.bashrc` file.
9999
`docker` users should also take a look at this page: [](../reference/docker.md) which describes a couple of extra steps that are required to make docker work in developer containers.
100100

101101

102-
(python-setup)=
102+
### Command Line Completion
103+
104+
This is an optional step to set up CLI completion for docker or podman.
103105

106+
It is much easier to investigate the commands available to you with command line completion enabled. You need only do the following steps once to permanently enable this feature for docker and docker compose.
107+
108+
```bash
109+
# these steps will make cli completion work for bash
110+
mkdir -p ~/.local/share/bash-completion/completions
111+
docker completion bash > ~/.local/share/bash-completion/completions/docker
112+
# OR
113+
podman completion bash > ~/.local/share/bash-completion/completions/podman
114+
115+
# these steps will make cli completion work for zsh
116+
mkdir -p ~/.oh-my-zsh/completions
117+
docker completion zsh > ~/.oh-my-zsh/completions/_docker
118+
# OR
119+
podman completion zsh > ~/.oh-my-zsh/completions/_podman
120+
```
121+
122+
(python-setup)=
104123
### Install Python
105124

106125
:::{Note}
@@ -157,7 +176,7 @@ ln -fs /dls_sw/work/python3/ec-venv/bin/ec $HOME/.local/bin/ec
157176
```
158177
:::
159178

160-
## Git
179+
### Git
161180

162181
If you don't already have git installed see
163182
<https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>. Any recent

0 commit comments

Comments
 (0)