Skip to content

Commit 5e17bcd

Browse files
committed
feat: adding mlserver for selection
This is testing an idea that a compatibility spec can direct to use (ask) an ml model. This is fully working but needs testing in a cloud now since kind (locally) does not have the instance type label. Signed-off-by: vsoch <[email protected]>
1 parent c4eb8d0 commit 5e17bcd

18 files changed

+816
-161
lines changed

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ build:
1616
$(BUILD_CONTEXT)
1717
@echo "Docker image $(FULL_IMAGE_NAME) built successfully."
1818

19+
# The mlserver
20+
mlserver:
21+
make -C ./mlserver
22+
23+
# Kind setup - we want to build both and push
24+
kind: mlserver build push
25+
docker push ghcr.io/converged-computing/aws-performance-study:model-server
26+
1927
# Push the docker image
2028
push:
2129
@echo "Pushing image $(FULL_IMAGE_NAME)..."
@@ -26,6 +34,11 @@ install:
2634
@echo "Installing $(FULL_IMAGE_NAME)..."
2735
kubectl apply -f ./deploy/webhook.yaml
2836

37+
# Install the webhook
38+
uninstall-mlserver:
39+
@echo "Installing $(FULL_IMAGE_NAME)..."
40+
kubectl apply -f ./deploy/webhook-with-mlserver.yaml
41+
2942
# Install the webhook
3043
uninstall:
3144
@echo "Uninstalling $(FULL_IMAGE_NAME)..."
@@ -37,5 +50,5 @@ clean:
3750
docker rmi $(FULL_IMAGE_NAME) || true
3851
@echo "Docker image $(FULL_IMAGE_NAME) removed (if it existed)."
3952

40-
.PHONY: all build clean
53+
.PHONY: all build clean mlserver
4154

README.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
1-
21
# OCIFit
32

43
<p align="center">
54
<img src="docs/ocifit-k8s.png" height="500" alt="OCIFit Kubernetes">
65
</p>
76

7+
This is a Kubernetes controller that can:
8+
9+
- Select a container for a pod based on a compatibility artifact.
10+
- Select an instance type for a pod based on a machine learning model.
11+
12+
For the latter, we serve a sidecar to the controller that provides models. The node features are served to the model with a request to use a specific one to determine the optimal instance type.
813

14+
## Details
915

10-
This is a Kubernetes controller that will do the following:
16+
We do the following:
1117

1218
* Start running in a cluster with NFD, and retrieving metadata about nodes in the cluster, along with being updated when nodes are added and removed.
1319
* Receiving pods and checking if they are flagged for image selection.
1420
* Being flagged means having the label "oci.image.compatibilities.selection/enabled" and (optionally) a node selector
15-
* If the cluster is not homogenous, a node selector is required, and should be the instance type that the pod is intended for.
21+
* If the cluster is not homogeneous, a node selector is required, and should be the instance type that the pod is intended for.
22+
23+
When a pod (or abstraction that creates them) is created:
24+
1625
* If enabled, a URI is provided that points to a compatibility artifact
1726
* The artifact describes several images (and criteria for checking) that can be used for the Pod
1827
* The controller checks known nodes for the instance type against the spec,
19-
28+
* If an ML server model is specified in the artifact, the entire set of node metadata is sent to it.
2029

2130
## Notes
2231

@@ -62,12 +71,21 @@ make push
6271
kind load docker-image ghcr.io/compspec/ocifit-k8s:latest
6372
```
6473

74+
You'll need the certificate manager.
75+
76+
```bash
77+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.17.2/cert-manager.yaml
78+
```
79+
6580
And install the deployment manifest (assuming you are sitting in the cloned repository)
6681

6782
```bash
6883
kubectl apply -f deploy/webhook.yaml
6984

70-
# The same
85+
# or with the ml server
86+
kubectl apply -f deploy/webhook-with-mlserver.yaml
87+
88+
# The same (just the webhook)
7189
make install
7290
```
7391

@@ -94,11 +112,11 @@ And install NFD. This will add node feature discovery labels to each node.
94112
kubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref=v0.17.3
95113
```
96114

97-
### 2. Add Custom Labels
115+
### 2. Custom Labels (Optional)
98116

99117
Since we want to test that NFD is working, we are going to add custom labels. We just want to test and don't need the labels to persist with recreations, so we can just use `kubectl label`. However,
100118
if we do it the right (persistent) way we would write a configuration file to `/etc/kubernetes/node-feature-discovery/features.d` on the node.
101-
In our real world use case we would select based on operating system and kernel version. For our test case, we will just use a script that will programaticallly update worker nodes. In this example,
119+
In our real world use case we would select based on operating system and kernel version. For our test case, we will just use a script that will programatically update worker nodes. In this example,
102120
we are just going to add the same label to all nodes and then check our controller based on the image selected. Let's first add "vanilla":
103121

104122
```bash
@@ -144,6 +162,10 @@ kubectl logs ocifit-k8s-deployment-68d5bf5865-494mg -f
144162

145163
### 4. Test Compatibilility
146164

165+
#### Custom Labels
166+
167+
**Requires generation of custom labels above**
168+
147169
At this point, we want to test compatibility. This step is already done, but I'll show you how I designed the compatibility spec. The logic for this dummy case is the following:
148170

149171
1. If our custom label "feature.node.ocifit-k8s.flavor" is vanilla, we want to choose a debian container.
@@ -155,6 +177,9 @@ here we are flipping the logic a bit. We don't know the image, and instead we ar
155177

156178
```bash
157179
oras push ghcr.io/compspec/ocifit-k8s-compatibility:kind-example ./example/compatibility-test.json:application/vnd.oci.image.compatibilities.v1+json
180+
181+
# For the ml model spec
182+
oras push ghcr.io/compspec/ocifit-k8s-compatibility:ml-example ./example/ml-compatibility-artifact.json:application/vnd.oci.image.model-compatibilities.v1+json
158183
```
159184

160185
We aren't going to be using any referrers API or linking this to an image. The target images are in the artifact, and we get there directly from the associated manifest.
@@ -234,6 +259,10 @@ REDHAT_SUPPORT_PRODUCT_VERSION="9.3"
234259

235260
Boum! Conceptually, we are selecting a different image depending on the rules in the compatibility spec. Our node features were dummy, but they could be real attributes related to kernel, networking, etc.
236261

262+
#### ML Server Decision
263+
264+
265+
237266
## License
238267

239268
HPCIC DevTools is distributed under the terms of the MIT license.
@@ -245,4 +274,4 @@ See [LICENSE](https://github.com/converged-computing/cloud-select/blob/main/LICE
245274

246275
SPDX-License-Identifier: (MIT)
247276

248-
LLNL-CODE- 842614
277+
LLNL-CODE- 842614

0 commit comments

Comments
 (0)