Skip to content

Commit 44bbd64

Browse files
authored
Merge pull request #159 from epics-containers/k8s-tutorials
K8s tutorials part 1
2 parents 04b98ec + 2c97019 commit 44bbd64

File tree

8 files changed

+372
-333
lines changed

8 files changed

+372
-333
lines changed

docs/reference/services_config.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Configuring a Services Repository for a Cluster
2+
3+
:::{warning}
4+
This page is a work in progress.
5+
:::
6+
7+
## Intro
8+
9+
In {any}`../tutorials/setup_k8s_new_beamline` we created a new beamline repository for a Kubernetes cluster. The copier template is capable of fully configuring the repo for the following types of cluster:
10+
11+
- a local k3s cluster created in {any}`../tutorials/setup_k8s`
12+
- your DLS *fedid* namespace in the Pollux cluster
13+
- a dedicated beamline cluster at DLS
14+
- a shared accelerator cluster at DLS
15+
16+
If you have a cluster that is not in the above list then you will need edit your **environment.sh** and **services/values.yaml** files accordingly. The following sections introduce the details of this process.
17+
18+
19+
## Cluster Topologies
20+
21+
There are two supported topologies for beamline clusters:
22+
23+
- shared cluster with multiple beamlines' IOCs running in the same cluster
24+
- dedicated cluster with a single beamline's IOCs running in the cluster
25+
26+
If you are working with the single node k3s cluster set up in the previous tutorial then this will be considered a dedicated cluster.
27+
28+
If you are creating a real DLS beamline then this will also be a dedicated cluster. However if your repo contains a set of accelerator IOCs this will share the single accelerator cluster amongst several serives repositories and is therefore a shared cluster.
29+
30+
If you are working with one of the test beamlines at DLS then these are usually shared topology and are set up as nodes on the Pollux cluster.
31+
32+
Other facilities are free to choose the topology that best suits their needs.
33+
34+
### Shared Clusters
35+
36+
In a shared cluster topology we will likely need to tell the IOCs which servers they are allowed to run on. This is primarily becasuse the server needs to be able to connect to the device the IOC is controlling.
37+
38+
In the case of the DLS accelerator will be 2 nodes (AKA servers) per CIA connected to the local instrumentation network. Only those nodes will be able to see the devices on the local instrumentation network.
39+
40+
To facilitate this we use `node affinity rules` to ensure that IOCs run on the correct nodes. `Node affinity` can look for a `label` on the node to say that it belongs to a beamline or CIA.
41+
42+
We can also use `taints` to stop other pods from running on our beamline nodes. A `taint` will stop pods from being scheduled
43+
on a node unless the pod has a matching toleration.
44+
45+
For example the test beamline p47 at DLS has the following `taints` and
46+
`labels`:
47+
48+
```
49+
Labels: beamline=bl47p
50+
nodetype=test-rig
51+
52+
Taints: beamline=bl47p:NoSchedule
53+
nodetype=test-rig:NoSchedule
54+
```
55+
56+
That test beamline has a single server which has the labels `beamline=bl47p` and `nodetype=test-rig`. It also has the taints `beamline=bl47p:NoSchedule` and `nodetype=test-rig:NoSchedule`. All of the devices on the test beamline are connected directly to this server and only visible on local IP addresses. The taints and tolerences assure that only p47 IOCs are scheduled on this server and that those IOCs will never run anywhere else.
57+
58+
If you are working with your facility cluster then, you may not have permission to set up these labels and taints. In this case, your administrator will need to do this for you. At DLS, you should expect that this is already set up for you.
59+
60+
For an explanation of these K8S concepts see
61+
62+
- [Taints and Tolerances](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
63+
- [Node Affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity-beta-feature)
64+
65+
### Dedicated Clusters
66+
67+
In the dedicated cluster topology we would usually want to let the IOCs run on any of the worker nodes in the cluster. In this case the only thing that is required is a namespace in which to run your IOCs.
68+
69+
By convention we use a namespace like `t03-beamline` for this purpose. This namespace will need the appropriate permissions to allow the IOCs to run with network host OR you will expose your PVs by running a ca-gateway in the cluster. At DLS we have chosen to use network host for our dedicated clusteres because:
70+
71+
- we prefer not to pass the Channel Access traffic through the gateway
72+
- other protocols such as GigE Streaming also require network host because they are not NAT friendly
73+
74+
TODO - these following sections are WORK IN PROGRESS.
75+
76+
## Environment Setup
77+
78+
Every services repository has an `environment.sh` file used to configure your shell so that the command line tools know which cluster to talk to. Up to this point we have been using the local docker or podman instance, but here we have configured it to use the the cluster. The copier template should have created the correct settings in **environment.sh** for you. But you can review them by if needed here {any}`../reference/environment`.
79+
80+
TODO pull the above ref into this page and update it.
81+
82+
83+
## Setting up the Beamline Helm Chart Defaults
84+
85+
You do not need to understand helm in detail to deploy IOCs to the cluster. But it may be instructive to understand what is happening under the hood. You will need to know how to edit the **values.yaml** files to configure your charts for your individual cluster topology.
86+
87+
TODO incomplete.
88+

docs/tutorials.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tutorials/debug_generic_ioc
2121
tutorials/support_module
2222
tutorials/setup_k8s
2323
tutorials/setup_k8s_new_beamline
24+
tutorials/add_k8s_ioc
2425
tutorials/rtems_setup
2526
tutorials/rtems_ioc
2627
```

docs/tutorials/add_k8s_ioc.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Add an IOC to the Kubernetes Beamline
2+
3+
In this tutorial we will add an additional IOC to the Kubernetes Simulation Beamline created in the previous tutorial.
4+
5+
This IOC will be a Simulation Area Detector IOC, very like the one we made in {any}`create_ioc`.
6+
7+
Here we will also take a look at the helm chart and resulting Kubernetes Manifest that is created as part of this process.
8+
9+
TODO: WIP

docs/tutorials/create_beamline.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ NOTE: for these tutorials we will use your personal GitHub Account to store ever
5050
copier copy gh:epics-containers/services-template-compose t01-services
5151
```
5252

53-
Note the benefits of using copier to create a new repository:
54-
- you can template the repository and use questions to fill in the template, making a unique result.
55-
- if the template changes in future you can merge the changes into you repository without losing your changes, simply by running `copier update .`
53+
Note the benefits of using copier to create a new repository:
54+
- you can template the repository and use questions to fill in the template, making a unique result.
55+
- if the template changes in future you can merge the changes into you repository without losing your changes, simply by running `copier update .`
5656

5757

5858
1. Answer the copier template questions with their default values as follows:

docs/tutorials/rtems_ioc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RTEMS - Deploying an Example IOC
22

33
:::{Warning}
4-
This tutorial is out of date and will be updated by Sept 2024.
4+
This tutorial is out of date and will be updated by Nov 2024.
55
:::
66

77
The previous tutorials walked through how to create a Generic linux soft

docs/tutorials/rtems_setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RTEMS - Creating a File Server
22

33
:::{Warning}
4-
This tutorial is out of date and will be updated in Sept 2024.
4+
This tutorial is out of date and will be updated in Nov 2024.
55
:::
66

77
## Introduction

0 commit comments

Comments
 (0)