Skip to content

Commit 1593704

Browse files
committed
Add in-cluster builds (#11)
Add in-cluster builds. Improve watchers and predicates.
1 parent 544c302 commit 1593704

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2358
-519
lines changed

.github/workflows/e2e.yaml

+139
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
run: |
8383
wget https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
8484
sudo dpkg -i ./minikube_latest_amd64.deb
85+
8586
- name: Start minikube and wait until CoreDNS is available
8687
run: |
8788
minikube start --driver=docker
@@ -131,6 +132,7 @@ jobs:
131132
echo "Unexpected lsmod output - the module should not be loaded"
132133
exit 1
133134
fi
135+
134136
- name: Add an ooto-ci Module that contains a valid mapping
135137
run: |
136138
sed -e "s/KVER_CHANGEME/$(uname -r)/g" \
@@ -139,6 +141,7 @@ jobs:
139141
ci/module-ooto-ci.template.yaml | tee module-ooto-ci.yaml
140142
141143
kubectl apply -f module-ooto-ci.yaml
144+
142145
- name: Check that the module gets loaded on the node
143146
run: |
144147
until minikube ssh -- lsmod | grep ooto_ci_a; do
@@ -199,6 +202,7 @@ jobs:
199202
run: |
200203
wget https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
201204
sudo dpkg -i ./minikube_latest_amd64.deb
205+
202206
- name: Start minikube and wait until CoreDNS is available
203207
run: |
204208
minikube start --driver=docker -n 2
@@ -332,3 +336,138 @@ jobs:
332336
- name: Get all operator logs
333337
run: kubectl logs deployment.apps/oot-operator-controller-manager -n oot-operator-system
334338
if: ${{ always() }}
339+
340+
in-cluster-build:
341+
runs-on: ubuntu-latest
342+
343+
name: In-cluster build
344+
345+
needs: [build-operator-image, build-drivercontainer-image]
346+
347+
steps:
348+
- name: Checkout
349+
uses: actions/checkout@v2
350+
351+
- name: Download and install minikube
352+
run: |
353+
wget https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
354+
sudo dpkg -i ./minikube_latest_amd64.deb
355+
356+
- name: Start minikube and wait until CoreDNS is available
357+
run: |
358+
minikube start --driver=docker --addons registry,registry-aliases
359+
kubectl wait --for=condition=available deployment coredns -n kube-system
360+
361+
kubectl apply -f ci/registry-nodeport.yaml
362+
363+
- name: Install skopeo
364+
run: |
365+
sudo apt -y update
366+
sudo apt -y install skopeo
367+
368+
- name: Download container images
369+
uses: actions/download-artifact@v3
370+
with:
371+
name: ci-images
372+
373+
- name: Import DriverContainer base into the internal-registry
374+
run: |
375+
MINIKUBE_REGISTRY_EXT="$(minikube service registry-nodeport -n kube-system --format '{{.IP}}:{{.Port}}' --url)"
376+
skopeo copy --dest-tls-verify=false docker-archive:ooto-kmod_local.tar docker://${MINIKUBE_REGISTRY_EXT}/ooto-base:local
377+
378+
- name: Import the OOTO image into minikube
379+
run: minikube image load ooto_local.tar
380+
381+
- uses: actions/setup-go@v2
382+
with:
383+
go-version: 1.17.6
384+
385+
- name: Deploy OOTO
386+
run: make deploy
387+
env:
388+
KUSTOMIZE_CONFIG_DEFAULT: ci/install-ci
389+
390+
- name: Wait until the OOTO Deployment is Available
391+
run: kubectl wait --for condition=Available deployments.apps -n oot-operator-system oot-operator-controller-manager
392+
timeout-minutes: 1
393+
394+
- name: Describe the Deployment / pods and get their YAML if that failed
395+
run: |
396+
kubectl describe deployments.apps -n oot-operator-system oot-operator-controller-manager
397+
kubectl get -o yaml deployments.apps -n oot-operator-system oot-operator-controller-manager
398+
399+
kubectl describe pod -n oot-operator-system
400+
kubectl get -o yaml pod -n oot-operator-system
401+
if: ${{ failure() }}
402+
403+
- name: Add an ooto-ci Module that contains a valid mapping
404+
run: |
405+
sed -e "s/KVER_CHANGEME/$(uname -r)/g" ci/module-ooto-ci-build.template.yaml | tee module-ooto-ci.yaml
406+
407+
kubectl apply -f module-ooto-ci.yaml
408+
409+
- name: Wait for the job to be created
410+
run: |
411+
until kubectl get job -l oot.node.kubernetes.io/module.name | grep ooto; do
412+
sleep 3
413+
done
414+
timeout-minutes: 1
415+
416+
- name: Wait for Job completion
417+
run: kubectl wait --for condition=complete job -l oot.node.kubernetes.io/module.name --timeout=-1s
418+
timeout-minutes: 2
419+
420+
- name: Collect job logs
421+
run: |
422+
JOB_NAME=$(kubectl get jobs.batch -l oot.node.kubernetes.io/module.name --template='{{ (index .items 0).metadata.name }}')
423+
kubectl logs jobs.batch/${JOB_NAME}
424+
if: ${{ always() }}
425+
426+
- name: Check that the module gets loaded on the node
427+
run: |
428+
until minikube ssh -- lsmod | grep ooto_ci_a; do
429+
sleep 3
430+
done
431+
timeout-minutes: 1
432+
433+
- name: Remove the Module
434+
run: kubectl delete -f module-ooto-ci.yaml
435+
436+
- name: Check that the module gets unloaded from the node
437+
run: |
438+
until ! minikube ssh -- lsmod | grep ooto_ci_a; do
439+
sleep 3
440+
done
441+
timeout-minutes: 1
442+
443+
- name: Get all resources in the oot-operator-system namespace
444+
run: kubectl get all -n oot-operator-system
445+
if: ${{ always() }}
446+
447+
- name: Get all resources in the default namespace
448+
run: kubectl get all
449+
if: ${{ always() }}
450+
451+
- name: Describe nodes
452+
run: kubectl describe node
453+
if: ${{ always() }}
454+
455+
- name: Describe Jobs
456+
run: kubectl describe job
457+
if: ${{ always() }}
458+
459+
- name: Describe DaemonSets
460+
run: kubectl describe daemonset -l oot.node.kubernetes.io/module.name
461+
if: ${{ always() }}
462+
463+
- name: Describe Pods
464+
run: kubectl describe pod -l oot.node.kubernetes.io/module.name
465+
if: ${{ always() }}
466+
467+
- name: Collect dmesg
468+
run: sudo dmesg
469+
if: ${{ always() }}
470+
471+
- name: Get all operator logs
472+
run: kubectl logs deployment.apps/oot-operator-controller-manager -n oot-operator-system
473+
if: ${{ always() }}

api/v1beta1/module_types.go

+36
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,42 @@ import (
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
)
2323

24+
type PullOptions struct {
25+
// +optional
26+
27+
// When Insecure is true, images can be pulled from an insecure (plain HTTP) registry.
28+
Insecure bool `json:"insecure"`
29+
}
30+
31+
type PushOptions struct {
32+
// +optional
33+
34+
// When Insecure is true, built images can be pushed to an insecure (plain HTTP) registry.
35+
Insecure bool `json:"insecure"`
36+
}
37+
38+
type Build struct {
39+
Dockerfile string `json:"dockerfile"`
40+
41+
// +optional
42+
43+
// Pull contains settings determining how to check if the DriverContainer image already exists.
44+
Pull PullOptions `json:"pull"`
45+
46+
// +optional
47+
48+
// Push contains settings determining how to push a built DriverContainer image.
49+
Push PushOptions `json:"push"`
50+
}
51+
2452
// KernelMapping pairs kernel versions with a DriverContainer image.
2553
// Kernel versions can be matched literally or using a regular expression.
2654
type KernelMapping struct {
55+
// +optional
56+
57+
// Build enables in-cluster builds for this mapping and allows overriding the Module's build settings.
58+
Build *Build `json:"build"`
59+
2760
// ContainerImage is the name of the DriverContainer image that should be used to deploy the module.
2861
ContainerImage string `json:"containerImage"`
2962

@@ -40,6 +73,9 @@ type KernelMapping struct {
4073

4174
// ModuleSpec describes how the OOT operator should deploy a Module on those nodes that need it.
4275
type ModuleSpec struct {
76+
// +optional
77+
Build Build `json:"build"`
78+
4379
// +optional
4480

4581
// AdditionalVolumes is a list of volumes that will be attached to the DriverContainer / DevicePlugin pod,

api/v1beta1/zz_generated.deepcopy.go

+56-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/module-ooto-ci-build.template.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
apiVersion: ooto.sigs.k8s.io/v1beta1
3+
kind: Module
4+
metadata:
5+
name: ooto-ci-build
6+
spec:
7+
driverContainer:
8+
name: overwritten-anyway
9+
command: [sleep, infinity]
10+
lifecycle:
11+
postStart:
12+
exec:
13+
command: [modprobe, -vd, /opt, ooto_ci_a]
14+
preStop:
15+
exec:
16+
command: [modprobe, -rvd, /opt, ooto_ci_a]
17+
securityContext:
18+
capabilities:
19+
add: [SYS_MODULE]
20+
kernelMappings:
21+
- literal: KVER_CHANGEME
22+
containerImage: registry.minikube/ooto-kmod:local
23+
build:
24+
pull:
25+
insecure: true
26+
push:
27+
insecure: true
28+
dockerfile: FROM registry.minikube/ooto-base:local
29+
selector:
30+
kubernetes.io/hostname: minikube

ci/module-ooto-ci.template.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ spec:
1111
lifecycle:
1212
postStart:
1313
exec:
14-
command: [modprobe, -d, /opt, -v, KMOD_CHANGEME]
14+
command: [modprobe, -vd, /opt, KMOD_CHANGEME]
1515
preStop:
1616
exec:
17-
command: [modprobe, -d, /opt, -rv, KMOD_CHANGEME]
17+
command: [modprobe, -rvd, /opt, KMOD_CHANGEME]
1818
securityContext:
1919
capabilities:
2020
add: [SYS_MODULE]

ci/registry-nodeport.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: registry-nodeport
6+
namespace: kube-system
7+
spec:
8+
selector:
9+
actual-registry: 'true'
10+
kubernetes.io/minikube-addons: registry
11+
ports:
12+
- port: 5000
13+
targetPort: 5000
14+
type: NodePort

0 commit comments

Comments
 (0)