-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RHOAIENG-16076: tests(gha): install a cri-o backed kubernetes for run…
…ning Makefile tests (#783) * RHOAIENG-16076: tests(gha): install a cri-o backed kubernetes for running tests * Update .github/workflows/build-notebooks-TEMPLATE.yaml Co-authored-by: Jan Stourac <jstourac@redhat.com> --------- Co-authored-by: Jan Stourac <jstourac@redhat.com>
- Loading branch information
Showing
5 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"cniVersion": "1.0.0", | ||
"name": "crio", | ||
"plugins": [ | ||
{ | ||
"type": "bridge", | ||
"bridge": "cni0", | ||
"isGateway": true, | ||
"ipMasq": true, | ||
"hairpinMode": true, | ||
"ipam": { | ||
"type": "host-local", | ||
"routes": [ | ||
{ "dst": "0.0.0.0/0" } | ||
], | ||
"ranges": [ | ||
[{ "subnet": "10.85.0.0/16" }] | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://github.com/cri-o/cri-o/blob/main/docs/crio.conf.5.md | ||
|
||
[crio] | ||
storage_driver = "overlay" | ||
# storage_option = [ "overlay.mountopt=nodev,metacopy=on" ] | ||
|
||
# reuse podman's container storage because we have huge images that don't fit on disk twice | ||
root = "/home/runner/.local/share/containers/storage" | ||
# has to be the same as root! | ||
runroot = "/home/runner/.local/share/containers/storage" | ||
|
||
# https://stackoverflow.com/questions/62408028/kubelet-failed-to-createpodsandbox-for-coredns-failed-to-set-bridge-addr-c | ||
[crio.network] | ||
# the /etc/cni/net.d/11-crio-ipv4-bridge.conflist default IPs confilct with flannel, | ||
# older versions of kubernetes the kubelet was touching the cni, now only the container runtime touches | ||
# c.f. https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#installation | ||
#network_dir = "/etc/cni/net.d-kube/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import json | ||
import os | ||
import pathlib | ||
import typing | ||
import unittest | ||
|
||
import gha_pr_changed_files | ||
|
||
"""Determines whether we have deploy Makefile tests for this target or not | ||
https://github.com/openshift/release/blob/master/ci-operator/config/opendatahub-io/notebooks/opendatahub-io-notebooks-main.yaml#L1485 | ||
""" | ||
|
||
|
||
class Args(argparse.Namespace): | ||
"""Type annotation to have autocompletion for args""" | ||
target: str | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser("make_test.py") | ||
parser.add_argument("--target", type=str) | ||
args = typing.cast(Args, parser.parse_args()) | ||
|
||
has_tests = check_tests(args.target) | ||
|
||
if "GITHUB_ACTIONS" in os.environ: | ||
with open(os.environ["GITHUB_OUTPUT"], "at") as f: | ||
print(f"tests={json.dumps(has_tests)}", file=f) | ||
|
||
print(f"{has_tests=}") | ||
|
||
|
||
def check_tests(target: str) -> bool: | ||
if target.startswith("rocm-jupyter-minimal-") or target.startswith("rocm-jupyter-datascience-"): | ||
return False # we don't have specific tests for -minimal-, ... in ci-operator/config | ||
if '-intel-' in target: | ||
return False # RHOAIENG-8388: Intel tensorflow notebook failed to get tested on OCP-CI | ||
|
||
has_tests = False | ||
dirs = gha_pr_changed_files.analyze_build_directories(target) | ||
for d in reversed(dirs): # (!) | ||
kustomization = pathlib.Path(gha_pr_changed_files.PROJECT_ROOT) / d / "kustomize/base/kustomization.yaml" | ||
has_tests = has_tests or kustomization.is_file() | ||
break # TODO: check only the last directory (the top level layer) for now | ||
return has_tests | ||
|
||
|
||
class TestCheckTests(unittest.TestCase): | ||
def test_has_tests(self): | ||
assert check_tests("base-c9s-python-3.11") is False | ||
assert check_tests("jupyter-minimal-ubi9-python-3.9") is True | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
# kubeadm config print init-defaults > kubeadm.yaml | ||
# kubeadm init --cri-socket=/var/run/crio/crio.sock | ||
|
||
# https://kubernetes.io/docs/reference/config-api/kubeadm-config.v1beta3/ | ||
# https://kubernetes.io/docs/reference/config-api/kubeadm-config.v1beta4/ | ||
apiVersion: kubeadm.k8s.io/v1beta3 | ||
bootstrapTokens: | ||
- groups: | ||
- system:bootstrappers:kubeadm:default-node-token | ||
token: abcdef.0123456789abcdef | ||
ttl: 24h0m0s | ||
usages: | ||
- signing | ||
- authentication | ||
kind: InitConfiguration | ||
localAPIEndpoint: | ||
bindPort: 6443 | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
# Need to have enough disk space for Kubelet, so move root-dir on the LVM volume | ||
# Note: the internets discourage from changing the default because storage plugins may then struggle | ||
# https://cep.dev/posts/adventure-trying-change-kubelet-rootdir/ | ||
root-dir: "/home/runner/.local/share/containers/kubelet-root-dir" | ||
criSocket: unix:///var/run/crio/crio.sock | ||
imagePullPolicy: IfNotPresent | ||
taints: null | ||
--- | ||
apiServer: | ||
timeoutForControlPlane: 4m0s | ||
apiVersion: kubeadm.k8s.io/v1beta3 | ||
certificatesDir: /etc/kubernetes/pki | ||
clusterName: kubernetes | ||
controllerManager: {} | ||
dns: {} | ||
etcd: | ||
local: | ||
dataDir: /var/lib/etcd | ||
imageRepository: registry.k8s.io | ||
kind: ClusterConfiguration | ||
networking: | ||
dnsDomain: cluster.local | ||
# this matches the default in /etc/cni/net.d/11-crio-ipv4-bridge.conflist | ||
podSubnet: 10.85.0.0/16 | ||
scheduler: {} |