Skip to content

Commit c2fa641

Browse files
ybettank8s-ci-robot
authored andcommitted
Adding an enhancement for checking image existence using the container-runtime.
Signed-off-by: Yoni Bettan <yonibettan@gmail.com>
1 parent 6d66a6c commit c2fa641

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Using the container-runtime to check images existance
2+
3+
Authors: @ybettan, @yevgeny-shnaidman
4+
5+
## Introduction
6+
7+
This enhancement aims at eliminating several pain points related to how KMM checks if container images exists.
8+
9+
The current implementation of KMM is checking whether images exists by generating an HTTP[s] request to the
10+
container registry. It requires KMM to manually access a bunch of configurations files on the nodes such as:
11+
* Container images mirroring configs
12+
* TLS configs
13+
* Installed CAs
14+
15+
In addition to that, in order to reduce the number of registy accesses, we also need to maintain a cache as
16+
we do for the Hub&Spoke topology.
17+
18+
[We recently started using the cluster's container-runtime for pulling kmod images from the worker pods](https://github.com/kubernetes-sigs/kernel-module-management/pull/886) which was a great step forward to maximum automation for pulling images
19+
in the cluster. Once we start checking the images existance using the container-runtime as well, we will be
20+
at ~100% automation for handlering images - everything the cluster does when pulling images, KMM will do as well.
21+
22+
## Goals
23+
24+
1. Remove the need for KMM to pull the images by itself using HTTP[s] and specific
25+
configuration, and instead rely on the built-in kubernetes functionality and cache.
26+
27+
## Non-goals
28+
29+
1. Add further control for building/signing kmod images.
30+
31+
## Design
32+
33+
### The new `ModuleImagesConfig` CRD
34+
35+
The new CRD will hold information regarding the existance of images mentioned in `Module` objects.
36+
The cluster will contain a single `ModuleImagesConfig` per `Module` in the cluster.
37+
The `generation` and `observedGeneration` are used to trigger the `ModuleImagesConfig` controller in some cases.
38+
39+
```yaml
40+
apiVersion: kmm.sigs.x-k8s.io/v1beta1
41+
kind: ModuleImagesConfig
42+
metadata:
43+
...
44+
...
45+
spec:
46+
items:
47+
- image: registry.example.com/org/kmod1:kver
48+
generation: 1 # default value
49+
- image: registry.example.com/org/kmod2:kver
50+
generation: 2
51+
build:
52+
....
53+
sign:
54+
...
55+
- image: registry.example.com/org/kmod3:kver
56+
generation: 1 # default value
57+
status
58+
obserevedGeneration: 1
59+
items:
60+
- image: registry.example.com/org/kmod1:kver
61+
status: Exists
62+
observedGeneration: 1
63+
- image: registry.example.com/org/kmod2:kver
64+
status: DoesNotExist
65+
observedGeneration: 1
66+
```
67+
68+
### Module-NMC controller's changes
69+
70+
* The only controller creating or modifying `ModuleImagesConfig` objects - one per `Module`
71+
* Update `ModuleImagesConfig`'s spec by adding/modifying/removing entries.
72+
* Checking `ModuleImagesConfig`'s status to determine whether the defined image exists in the image
73+
repository or not.
74+
* Continues to create `NodeModulesConfig` objects as before.
75+
76+
```mermaid
77+
flowchart TD
78+
MOD((Module)) -->|Reconcile| MNMCC(Module-NMC controller)
79+
MNMCC --> |No MIC exists for the Module| MIC((Create MIC)) --> DONE
80+
MNMCC --> |Image's NOT in MIC's spec| A1{{Add it to ModuleImagesConfig's spec with generation=1}} --> DONE(((Done)))
81+
MNMCC --> |Image's in MIC's spec| J1((.))
82+
J1 --> |Image has no status| DONE
83+
J1 --> |status='DoesNotExist'| A2{{generation++}} --> DONE
84+
J1 --> |Image's status='Exists'| NMC((Create NMC)) --> DONE
85+
```
86+
87+
### ModuleImagesConfig controller (MIC) (previously called the BuildSign controller) changes
88+
89+
* Continue to build/sign kmods as before
90+
* Creating pods to check if images exists and updates the `ModuleImagesConfig`'s status accordingly
91+
* Remove `ModuleImagesConfig`'s status entries that were removed from `spec`.
92+
93+
**The following chart only describe the new functionality added to the controller.**
94+
```mermaid
95+
flowchart TD
96+
MIC((ModuleImagesConfig)) -->|Reconcile| MICC(MIC controller)
97+
MICC --> |Image has no status| J1((.))
98+
J1 --> |Pull pod exists| J2((.))
99+
J2 --> |Succeed| USE{{Update status to 'Exists'}}
100+
USE --> GENBUMP{{observedGeneration++}}
101+
GENBUMP --> DELETE{{Delete the pod}}
102+
DELETE --> DONE(((Done)))
103+
J2 --> |Failed| USDE{{Update status to 'DoesNotExist'}}
104+
USDE --> GENBUMP
105+
J1 --> |No pull pod| POD((Create Pull Pod)) --> DONE
106+
MICC --> |status='Exists'| DONE
107+
MICC --> |status='DoesNotExist'| J3((.))
108+
J3 --> |'generation'!='observedGeneration'| J1
109+
J3 --> |'generation'=='observedGeneration'| J4((.))
110+
J4 --> |Build section exists| J5((.))
111+
J5 --> |No build pod| BUILD((Create Build Pod)) --> DONE
112+
J5 --> |Build pod exist| J6((.))
113+
J6 --> |Succeed| A5{{Update status to 'Exists'}}
114+
A5 --> DELETE
115+
J6 --> |Failed| DONE
116+
J4 --> |No build section| DONE
117+
```
118+
119+
## Addressing goals
120+
121+
This design addresses the goals stated at the beginning of this proposal:
122+
123+
* **Container images mirroring configs:**
124+
Since the container-runtime pulls images directly on the nodes, therefore, checking
125+
the node's configuration for mirror registries is now done automatically.
126+
There is no more need to manually read `/etc/containers/registries.conf`.
127+
128+
* **TLS configs:**
129+
Same here - no need to check the container-runtime TLS configuration.
130+
For example, when using docker as the runtime, there is not need to check
131+
its config by inspecting `/etc/docker/daemon.json`.
132+
133+
* **Installed CAs:**
134+
No need to read the CAs list on the node.
135+
136+
* **Using the node's cache:**
137+
The container runtime will use the node's cache for pulling images and we won't
138+
need to maintain our own cache anymore.
139+
140+
## API changes
141+
142+
We do not foresee any change to the existing APIs, including `Module`, for this enhancement.
143+
The new `ModuleImagesConfig` CRD will be strictly internal to KMM and should not be relied upon for any purpose.
144+
145+
## Upgrading from a previous version of KMM
146+
147+
We do not expect any issue preforming such upgrade.

0 commit comments

Comments
 (0)