├── .codespellignorelines ├── .codespellignorewords ├── .codespellrc ├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yaml │ ├── feature-request.yaml │ └── new-release.md └── workflows │ ├── codespell.yml │ ├── helm-lint.yaml │ ├── lint.yaml │ ├── package-helm.yaml │ ├── publish-docs.yml │ ├── publish-helm-charts.yaml │ ├── publish-images.yaml │ ├── publish-olm-bundle.yaml │ └── verify.yaml ├── .gitignore ├── CODE-OF-CONDUCT.md ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── TODO.md ├── Tiltfile ├── cmd ├── config-manager │ ├── Dockerfile │ └── main.go ├── mpolset │ ├── Dockerfile │ └── mpolset.go └── plugins │ ├── balloons │ ├── Dockerfile │ ├── main.go │ └── policy │ │ ├── balloons-policy.go │ │ ├── balloons-policy_test.go │ │ ├── cputree.go │ │ ├── cputree_test.go │ │ ├── fillmethod.go │ │ ├── flags.go │ │ └── metrics.go │ ├── memory-policy │ ├── Dockerfile │ └── main.go │ ├── memory-qos │ ├── Dockerfile │ └── main.go │ ├── memtierd │ ├── Dockerfile │ ├── licensechack │ │ └── pull-licenses.go │ └── main.go │ ├── sgx-epc │ ├── Dockerfile │ └── sgx-epc.go │ ├── template │ ├── Dockerfile │ ├── main.go │ └── policy │ │ └── template-policy.go │ └── topology-aware │ ├── Dockerfile │ ├── main.go │ └── policy │ ├── affinity.go │ ├── cache.go │ ├── cache_test.go │ ├── coldstart.go │ ├── coldstart_test.go │ ├── error.go │ ├── hint.go │ ├── hint_test.go │ ├── libmem.go │ ├── logging.go │ ├── metrics.go │ ├── mocks_test.go │ ├── node.go │ ├── pod-preferences.go │ ├── pod-preferences_test.go │ ├── pools.go │ ├── pools_test.go │ ├── resources.go │ ├── testdata │ └── sysfs.tar.bz2 │ └── topology-aware-policy.go ├── config └── crd │ └── bases │ ├── config.nri_balloonspolicies.yaml │ ├── config.nri_nriplugindeployments.yaml │ ├── config.nri_templatepolicies.yaml │ ├── config.nri_topologyawarepolicies.yaml │ └── topology.node.k8s.io_noderesourcetopologies.yaml ├── deployment ├── helm │ ├── balloons │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── crds │ │ │ ├── config.nri_balloonspolicies.yaml │ │ │ └── noderesourcetopology.yaml │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ ├── clusterrole.yaml │ │ │ ├── clusterrolebinding.yaml │ │ │ ├── config.yaml │ │ │ ├── daemonset.yaml │ │ │ ├── role.yaml │ │ │ ├── rolebindings.yaml │ │ │ └── serviceaccount.yaml │ │ ├── values.schema.json │ │ └── values.yaml │ ├── memory-policy │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ ├── configmap.yaml │ │ │ └── daemonset.yaml │ │ ├── values.schema.json │ │ └── values.yaml │ ├── memory-qos │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ ├── configmap.yaml │ │ │ └── daemonset.yaml │ │ ├── values.schema.json │ │ └── values.yaml │ ├── memtierd │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ ├── configmap.yaml │ │ │ └── daemonset.yaml │ │ ├── values.schema.json │ │ └── values.yaml │ ├── sgx-epc │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ └── daemonset.yaml │ │ ├── values.schema.json │ │ └── values.yaml │ ├── template │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── crds │ │ │ ├── config.nri_templatepolicies.yaml │ │ │ └── noderesourcetopology.yaml │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ ├── clusterrole.yaml │ │ │ ├── clusterrolebinding.yaml │ │ │ ├── config.yaml │ │ │ ├── daemonset.yaml │ │ │ ├── role.yaml │ │ │ ├── rolebindings.yaml │ │ │ └── serviceaccount.yaml │ │ ├── values.schema.json │ │ └── values.yaml │ └── topology-aware │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── crds │ │ ├── config.nri_topologyawarepolicies.yaml │ │ └── noderesourcetopology.yaml │ │ ├── templates │ │ ├── _helpers.tpl │ │ ├── clusterrole.yaml │ │ ├── clusterrolebinding.yaml │ │ ├── config.yaml │ │ ├── daemonset.yaml │ │ ├── role.yaml │ │ ├── rolebindings.yaml │ │ └── serviceaccount.yaml │ │ ├── values.schema.json │ │ └── values.yaml └── operator │ ├── Dockerfile │ ├── Makefile │ ├── PROJECT │ ├── README.md │ ├── ansible.cfg │ ├── bundle.Dockerfile │ ├── config │ ├── crd │ │ └── kustomization.yaml │ ├── default │ │ ├── kustomization.yaml │ │ ├── manager_auth_proxy_patch.yaml │ │ └── manager_config_patch.yaml │ ├── manager │ │ ├── kustomization.yaml.in │ │ └── manager.yaml │ ├── manifests │ │ ├── bases │ │ │ └── nri-plugins-operator.clusterserviceversion.yaml.in │ │ └── kustomization.yaml │ ├── rbac │ │ ├── auth_proxy_client_clusterrole.yaml │ │ ├── auth_proxy_role.yaml │ │ ├── auth_proxy_role_binding.yaml │ │ ├── auth_proxy_service.yaml │ │ ├── config.nri_nriplugindeployment_editor_role.yaml │ │ ├── config.nri_nriplugindeployment_viewer_role.yaml │ │ ├── kustomization.yaml │ │ ├── leader_election_role.yaml │ │ ├── leader_election_role_binding.yaml │ │ ├── role.yaml │ │ ├── role_binding.yaml │ │ └── service_account.yaml │ ├── samples │ │ ├── config.nri_v1alpha1_nriplugindeployment.yaml │ │ └── kustomization.yaml │ └── scorecard │ │ ├── bases │ │ └── config.yaml │ │ ├── kustomization.yaml │ │ └── patches │ │ ├── basic.config.yaml │ │ └── olm.config.yaml │ ├── playbooks │ └── plugin-deployment.yml │ ├── requirements.yml │ ├── roles │ └── plugin-deployment │ │ └── tasks │ │ └── main.yml │ └── watches.yaml ├── docs ├── Dockerfile ├── _templates │ └── layout.html ├── conf.py ├── contributing.md ├── deployment │ ├── helm │ │ ├── balloons.md │ │ ├── index.md │ │ ├── memory-qos.md │ │ ├── memtierd.md │ │ ├── sgx-epc.md │ │ ├── template.md │ │ └── topology-aware.md │ ├── index.md │ └── operator │ │ ├── index.md │ │ └── operator.md ├── index.html ├── index.md ├── introduction.md ├── memory │ ├── index.md │ ├── memory-qos.md │ ├── memtierd.md │ └── sgx-epc.md ├── releases │ ├── conf.py │ └── index.md ├── requirements.txt └── resource-policy │ ├── configuration.md │ ├── developers-guide │ ├── architecture.md │ ├── cpu-allocator.md │ ├── e2e-test.md │ ├── figures │ │ └── nri-resource-policy.png │ ├── index.md │ ├── testing.md │ └── unit-test.md │ ├── index.md │ ├── introduction.md │ ├── policy │ ├── balloons.md │ ├── common-functionality.md │ ├── index.md │ ├── template.md │ └── topology-aware.md │ └── setup.md ├── go.mod ├── go.sum ├── pkg ├── agent │ ├── agent.go │ ├── config-interface.go │ ├── node-resource-topology.go │ ├── nrtapi │ │ └── nrtapi.go │ ├── pod-resource-api.go │ ├── podresapi │ │ ├── client.go │ │ ├── resources.go │ │ └── resources_test.go │ └── watch │ │ ├── file.go │ │ ├── object.go │ │ └── watch.go ├── apis │ ├── config │ │ └── v1alpha1 │ │ │ ├── agent.go │ │ │ ├── balloons-policy.go │ │ │ ├── groupversion_info.go │ │ │ ├── instrumentation │ │ │ ├── config.go │ │ │ └── zz_generated.deepcopy.go │ │ │ ├── log │ │ │ ├── config.go │ │ │ ├── klogcontrol │ │ │ │ ├── config.go │ │ │ │ ├── doc.go │ │ │ │ ├── gen-config.go │ │ │ │ └── zz_generated.deepcopy.go │ │ │ └── zz_generated.deepcopy.go │ │ │ ├── metrics │ │ │ ├── config.go │ │ │ └── zz_generated.deepcopy.go │ │ │ ├── node-status.go │ │ │ ├── resmgr.go │ │ │ ├── resmgr │ │ │ ├── control │ │ │ │ ├── blockio │ │ │ │ │ ├── config.go │ │ │ │ │ └── zz_generated.deepcopy.go │ │ │ │ ├── config.go │ │ │ │ ├── cpu │ │ │ │ │ ├── config.go │ │ │ │ │ └── zz_generated.deepcopy.go │ │ │ │ ├── rdt │ │ │ │ │ ├── config.go │ │ │ │ │ └── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.deepcopy.go │ │ │ └── policy │ │ │ │ ├── balloons │ │ │ │ ├── config.go │ │ │ │ └── zz_generated.deepcopy.go │ │ │ │ ├── config.go │ │ │ │ ├── template │ │ │ │ ├── config.go │ │ │ │ └── zz_generated.deepcopy.go │ │ │ │ └── topologyaware │ │ │ │ ├── config.go │ │ │ │ └── zz_generated.deepcopy.go │ │ │ ├── template-policy.go │ │ │ ├── topology-aware-policy.go │ │ │ ├── types.go │ │ │ ├── validator.go │ │ │ └── zz_generated.deepcopy.go │ └── resmgr │ │ └── v1alpha1 │ │ ├── evaluable.go │ │ ├── expression.go │ │ ├── expression_test.go │ │ ├── types.go │ │ └── zz_generated.deepcopy.go ├── cgroups │ ├── cgroupcontrol.go │ ├── cgroupid.go │ ├── cgroupid_linux.go │ ├── cgroupid_other.go │ ├── cgrouppath.go │ └── cgroupstats.go ├── cpuallocator │ ├── allocator.go │ ├── cpuallocator_test.go │ └── testdata │ │ └── sysfs.tar.bz2 ├── generated │ └── clientset │ │ └── versioned │ │ ├── clientset.go │ │ ├── fake │ │ ├── clientset_generated.go │ │ ├── doc.go │ │ └── register.go │ │ ├── scheme │ │ ├── doc.go │ │ └── register.go │ │ └── typed │ │ └── config │ │ └── v1alpha1 │ │ ├── balloonspolicy.go │ │ ├── config_client.go │ │ ├── doc.go │ │ ├── fake │ │ ├── doc.go │ │ ├── fake_balloonspolicy.go │ │ ├── fake_config_client.go │ │ ├── fake_templatepolicy.go │ │ └── fake_topologyawarepolicy.go │ │ ├── generated_expansion.go │ │ ├── templatepolicy.go │ │ └── topologyawarepolicy.go ├── healthz │ └── healthz.go ├── http │ ├── http.go │ └── http_test.go ├── instrumentation │ ├── instrumentation.go │ ├── instrumentation_test.go │ ├── metrics │ │ └── metrics.go │ └── tracing │ │ ├── exporter.go │ │ ├── sampler.go │ │ ├── span.go │ │ └── tracing.go ├── kubernetes │ ├── cpuset.go │ ├── cpuset_test.go │ ├── kubernetes.go │ ├── resources.go │ └── resources_test.go ├── log │ ├── config.go │ ├── default.go │ ├── klogcontrol │ │ └── klogcontrol.go │ ├── log.go │ ├── ratelimit.go │ ├── ratelimit_test.go │ ├── signal.go │ ├── slog-logger.go │ └── stdlog-logger.go ├── mempolicy │ └── mempolicy.go ├── metrics │ ├── collectors │ │ └── collectors.go │ ├── doc.go │ ├── metrics.go │ └── metrics_test.go ├── pidfile │ ├── pidfile.go │ └── pidfile_test.go ├── resmgr │ ├── blockio.go │ ├── cache │ │ ├── affinity.go │ │ ├── affinity_test.go │ │ ├── cache.go │ │ ├── cache_suite_test.go │ │ ├── cache_test.go │ │ ├── container.go │ │ ├── container_test.go │ │ ├── error.go │ │ ├── pod.go │ │ ├── pod_test.go │ │ ├── test-cleanup.sh │ │ ├── test-data.tar.gz │ │ ├── test-setup.sh │ │ ├── utils.go │ │ └── utils_test.go │ ├── control │ │ ├── control.go │ │ ├── cpu │ │ │ ├── api.go │ │ │ ├── cache.go │ │ │ ├── cpu.go │ │ │ └── cstates_overridefs.go │ │ └── e2e-test │ │ │ └── e2e-test.go │ ├── controllers.go │ ├── error.go │ ├── events.go │ ├── events │ │ └── events.go │ ├── flags.go │ ├── lib │ │ └── memory │ │ │ ├── allocator.go │ │ │ ├── allocator_test.go │ │ │ ├── custom-allocator.go │ │ │ ├── custom-allocator_test.go │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── helpers_test.go │ │ │ ├── logging.go │ │ │ ├── mask-cache.go │ │ │ ├── mask-cache_test.go │ │ │ ├── nodes.go │ │ │ ├── nodes_test.go │ │ │ ├── request.go │ │ │ ├── request_test.go │ │ │ ├── test-cleanup.sh │ │ │ ├── test-data-sample1.tar.xz │ │ │ ├── test-data-sample2.tar.xz │ │ │ ├── test-setup.sh │ │ │ ├── types.go │ │ │ ├── types_test.go │ │ │ └── zones.go │ ├── main │ │ └── main.go │ ├── nri.go │ ├── policy │ │ ├── error.go │ │ ├── metrics.go │ │ └── policy.go │ ├── rdt.go │ └── resource-manager.go ├── sockets │ └── sockets.go ├── sysfs │ ├── error.go │ ├── parsers.go │ ├── sysfs_suite_test.go │ ├── system.go │ ├── system_test.go │ ├── test-cleanup.sh │ ├── test-data-sample1.tar.xz │ ├── test-data-sample2.tar.xz │ ├── test-setup.sh │ └── utils.go ├── testutils │ └── verify.go ├── topology │ ├── LICENSE │ ├── go.mod │ ├── go.sum │ ├── test-cleanup.sh │ ├── test-data.tar.gz │ ├── test-setup.sh │ ├── topology.go │ ├── topology_linux.go │ ├── topology_other.go │ └── topology_test.go ├── udev │ ├── doc.go │ ├── monitor.go │ └── reader.go ├── utils │ ├── cpuset │ │ └── cpuset.go │ ├── json.go │ ├── net.go │ ├── parse.go │ ├── sort.go │ └── tar.go └── version │ └── version.go ├── sample-configs ├── balloons-config.yaml ├── noderesourcetopology.yaml ├── nri-memory-policy.yaml ├── nri-memory-qos.yaml ├── nri-memtierd.yaml ├── template-config.yaml └── topologyaware-config.yaml ├── scripts ├── build │ ├── extract-licenses.sh │ ├── get-buildid │ ├── helm-publisher.sh │ ├── update-gh-pages.sh │ └── verify-licenses.sh ├── docs │ └── make.bat ├── hack │ ├── boilerplate.go.txt │ ├── go-mod-replace-helper.sh │ ├── go-mod-tree │ └── update_codegen.sh ├── release │ └── check-artifacts.sh ├── testing │ ├── e2e-runner │ ├── jaeger │ ├── kube-cgroups │ ├── pairwise │ ├── prometheus │ └── prometheus.yaml └── udev-monitor │ └── udev-monitor.go └── test ├── e2e ├── README.md ├── files │ ├── 10-bridge.conf.in │ ├── Makefile.in │ ├── Vagrantfile.in │ ├── besteffort.yaml.in │ ├── burstable.yaml.in │ ├── containerd-nri-enable │ ├── crio-nri-enable │ ├── env.in │ ├── guaranteed.yaml.in │ ├── nri-memory-qos-test-pod.yaml │ ├── nri-memtierd-test-pod.yaml │ └── vagrant.ini.in ├── lib │ ├── command.bash │ ├── host.bash │ ├── topology.py │ ├── topology2qemuopts.py │ └── vm.bash ├── memory.test-suite │ └── memory-policy │ │ └── n6-hbm-cxl │ │ ├── dram-hbm-cxl.helm-config.yaml.in │ │ ├── test01-policies │ │ └── code.var.sh │ │ └── topology.var.json ├── playbook │ ├── deploy-policy-plugin.yaml │ ├── nri-balloons-plugin-deploy.yaml │ ├── nri-memory-policy-plugin-deploy.yaml │ ├── nri-topology-aware-plugin-deploy.yaml │ └── provision.yaml ├── policies.test-suite │ ├── balloons │ │ ├── balloons-busybox.yaml.in │ │ ├── balloons-config.yaml.in │ │ ├── cpuclass.cfg │ │ ├── helm-config.yaml │ │ ├── match-config.yaml │ │ ├── n4c16 │ │ │ ├── test01-basic-placement │ │ │ │ └── code.var.sh │ │ │ ├── test02-prometheus-metrics │ │ │ │ ├── balloons-metrics.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test03-reserved │ │ │ │ ├── balloons-reserved.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test04-groupby │ │ │ │ ├── balloons-groupby.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test05-namespace │ │ │ │ ├── balloons-namespace.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test06-update-config │ │ │ │ ├── code.var.sh │ │ │ │ └── initial-balloons-config.cfg │ │ │ ├── test07-maxballoons │ │ │ │ ├── balloons-maxballoons-impossible.cfg │ │ │ │ ├── balloons-maxballoons.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test08-numa │ │ │ │ ├── balloons-numa.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test09-isolated │ │ │ │ ├── balloons-isolated.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test10-allocator-opts │ │ │ │ ├── balloons-allocator-opts.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test11-match-expression │ │ │ │ └── code.var.sh │ │ │ ├── test13-cacheclusters │ │ │ │ ├── balloons-2cpu-cacheclusters.cfg │ │ │ │ ├── balloons-4cpu-cacheclusters.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test15-loadclasses │ │ │ │ ├── balloons-loadclasses.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test16-composite-balloons │ │ │ │ ├── balloons-composite.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test17-cstates │ │ │ │ ├── balloons-cstates.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test20-config-status │ │ │ │ ├── balloons.cfg │ │ │ │ ├── broken-balloons-config.yaml │ │ │ │ └── code.var.sh │ │ │ ├── test21-controller-check │ │ │ │ ├── balloons-config.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test22-isolcpus │ │ │ │ ├── balloons-isolcpus.cfg │ │ │ │ └── code.var.sh │ │ │ └── topology.var.json │ │ ├── n6-hbm-cxl │ │ │ ├── py_consts.var.py │ │ │ ├── test01-memory-types │ │ │ │ ├── balloons-memory-types.cfg │ │ │ │ └── code.var.sh │ │ │ ├── test04-nrt │ │ │ │ ├── balloons-nrt.cfg │ │ │ │ └── code.var.sh │ │ │ └── topology.var.json │ │ └── verify.source.sh │ └── topology-aware │ │ ├── helm-config.yaml.in │ │ ├── n4c16 │ │ ├── test00-basic-placement │ │ │ └── code.var.sh │ │ ├── test01-always-fits │ │ │ └── code.var.sh │ │ ├── test02-shrink-and-grow-shared │ │ │ └── code.var.sh │ │ ├── test03-simple-affinity │ │ │ ├── code.var.sh │ │ │ └── guaranteed+affinity.yaml.in │ │ ├── test04-available-resources │ │ │ └── code.var.sh │ │ ├── test05-reserved-resources │ │ │ └── code.var.sh │ │ ├── test06-fuzz │ │ │ ├── code.var.sh │ │ │ ├── codelib.sh │ │ │ ├── fuzz.aal │ │ │ ├── fuzz.fmbt.conf │ │ │ ├── generate.go │ │ │ └── generate.sh │ │ ├── test07-mixed-allocations │ │ │ ├── code.var.sh │ │ │ └── guaranteed-annotated.yaml.in │ │ ├── test08-cpuprio-allocation │ │ │ └── code.var.sh │ │ ├── test09-container-exit │ │ │ └── code.var.sh │ │ ├── test10-additional-reserved-namespaces │ │ │ └── code.var.sh │ │ ├── test11-reserved-cpu-annotations │ │ │ ├── code.var.sh │ │ │ └── reserved-annotated.yaml.in │ │ ├── test12-config-status │ │ │ ├── code.var.sh │ │ │ └── custom-config.yaml.in │ │ ├── test13-reject-symlink │ │ │ └── code.var.sh │ │ ├── test14-burstable │ │ │ └── code.var.sh │ │ ├── test14-global-shared-preference │ │ │ ├── code.var.sh │ │ │ └── guaranteed-annotated.yaml.in │ │ └── topology.var.json │ │ └── n6-hbm-cxl │ │ ├── py_consts.var.py │ │ ├── test01-memory-types │ │ └── code.var.sh │ │ ├── test02-fuzz-memallocs │ │ ├── code.var.sh │ │ ├── codelib.sh │ │ ├── fuzz.aal │ │ ├── fuzz.fmbt.conf │ │ └── generate.sh │ │ ├── test04-nrt │ │ ├── code.var.sh │ │ └── topology-aware-nrt.cfg │ │ └── topology.var.json ├── report-test-status.sh ├── run.sh └── run_tests.sh └── statistics-analysis ├── README.md ├── manifests ├── jaeger-deployment.yaml ├── sleep-deployment.yaml └── stress-ng-deployment.yaml ├── prometheus-values.yaml └── scripts ├── destroy-deployment.sh ├── get-jaeger-tracing-data.py ├── get-prometheus-timeseries-data.py ├── plot-graphs.py ├── post-run.sh ├── pre-run.sh ├── requirements.txt ├── run-test.sh └── run-tests.sh /.codespellignorelines: -------------------------------------------------------------------------------- 1 | ( vm-command "kubectl delete pods -n kube-system \$(kubectl get pods -n kube-system | awk '/t[0-9]r[gb][ue]/{print \$1}')" ) || true 2 | ( vm-command "kubectl delete pods -n default \$(kubectl get pods -n default | awk '/t[0-9][rgb][ue][0-9]/{print \$1}')" ) || true 3 | docker run -v "$(pwd):/mnt/models" "$FMBT_IMAGE" sh -c 'cd /mnt/models; fmbt tmp.fuzz.fmbt.conf 2>/dev/null | fmbt-log -f STEP\$sn\$as\$al' | grep -v AAL | sed -e 's/^, / /g' -e '/^STEP/! s/\(^.*\)/echo "TESTGEN: \1"/g' -e 's/^STEP\([0-9]*\)i:\(.*\)/echo "TESTGEN: STEP \1"; vm-command "date +%T.%N"; \2; vm-command "date +%T.%N"; kubectl get pods -A/g' | sed "s/\([^a-z0-9]\)\(r\?\)\(gu\|bu\|be\)\([0-9]\)/\1t${testid}\2\3\4/g" > "$OUTFILE" 4 | allocs := map[string]cpuset.CPUSet{"--:allo": currentCpus} 5 | allocName := fmt.Sprintf("%02d:allo", i+1) 6 | preferTightestFit = func(cA, cB *cpuCluster, pkgA, pkgB, dieA, dieB int, csetA, csetB cpuset.CPUSet) (r int) { 7 | if dieA >= a.cnt && dieB < a.cnt { 8 | if dieA < a.cnt && dieB >= a.cnt { 9 | if dieA >= a.cnt && dieB >= a.cnt { 10 | if diff := dieA - dieB; diff != 0 { 11 | -------------------------------------------------------------------------------- /.codespellignorewords: -------------------------------------------------------------------------------- 1 | clos 2 | NotIn 3 | -------------------------------------------------------------------------------- /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | skip = .git,build,testdata,n[0-9]*,*.pdf,*.svg,*.png,*.tar.*,go.sum,go.mod,./cmd/plugins/topology-aware/policy 3 | ignore-words = .codespellignorewords 4 | exclude-file = .codespellignorelines 5 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Ignore any e2e VM directories 2 | **/n*-containerd/ 3 | **/n*-crio/ 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yaml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for this project 3 | body: 4 | - type: textarea 5 | id: description 6 | attributes: 7 | label: Description 8 | description: Describe the solution you'd like 9 | value: "A clear and concise description of you want to happen." 10 | validations: 11 | required: true 12 | - type: textarea 13 | id: rationale 14 | attributes: 15 | label: Rationale 16 | description: Describe why this is needed 17 | value: "A clear and concise description of the use case and/or justification for the feature" 18 | validations: 19 | required: true 20 | -------------------------------------------------------------------------------- /.github/workflows/codespell.yml: -------------------------------------------------------------------------------- 1 | name: Codespell 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | codespell: 11 | name: Check for spelling errors 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v5 17 | - name: Codespell 18 | uses: codespell-project/actions-codespell@v2 19 | -------------------------------------------------------------------------------- /.github/workflows/helm-lint.yaml: -------------------------------------------------------------------------------- 1 | name: helm linter 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - 'deployment/helm/**' 7 | 8 | jobs: 9 | lint-test: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v5 14 | with: 15 | fetch-depth: 0 16 | 17 | - name: Set up Helm 18 | uses: azure/setup-helm@v4.0.0 19 | with: 20 | version: v3.11.2 21 | 22 | - name: Run linter for all the charts 23 | run: helm lint deployment/helm/* 24 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - "release-*" 8 | - "test/**" 9 | pull_request: 10 | branches: 11 | - main 12 | - "release-*" 13 | 14 | permissions: 15 | contents: read 16 | # allow checks write access to let the action annotate code in PRs 17 | checks: write 18 | 19 | jobs: 20 | golangci-lint: 21 | name: golangci-lint 22 | runs-on: ubuntu-24.04 23 | timeout-minutes: 10 24 | steps: 25 | - uses: actions/checkout@v5 26 | - uses: actions/setup-go@v5 27 | with: 28 | go-version-file: go.mod 29 | - uses: golangci/golangci-lint-action@v8 30 | with: 31 | version: v2.4.0 32 | args: --timeout=10m 33 | -------------------------------------------------------------------------------- /.github/workflows/publish-docs.yml: -------------------------------------------------------------------------------- 1 | name: Publish documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - release-* 8 | tags: 9 | - v[0-9]+.[0-9]+.[0-9]+ 10 | 11 | concurrency: 12 | group: gh-pages 13 | 14 | jobs: 15 | update-gh-pages: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v5 19 | with: 20 | fetch-depth: 0 21 | - uses: actions/setup-go@v5 22 | with: 23 | go-version-file: go.mod 24 | - name: Install build dependencies 25 | run: | 26 | pip3 install --user -r docs/requirements.txt 27 | echo "`python3 -m site --user-base`/bin" >> $GITHUB_PATH 28 | 29 | - name: Add docs from this revision to gh-pages 30 | run: | 31 | git config user.name "Github" 32 | git config user.email "no-reply@github.com" 33 | ./scripts/build/update-gh-pages.sh 34 | 35 | - name: Publish/push to gh-pages 36 | shell: bash 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | run: | 40 | git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git gh-pages 41 | -------------------------------------------------------------------------------- /.github/workflows/publish-helm-charts.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Helm charts 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | concurrency: 9 | group: gh-pages 10 | cancel-in-progress: false 11 | 12 | jobs: 13 | release: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: write 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v5 20 | with: 21 | ref: main 22 | fetch-depth: 0 23 | 24 | - name: Install Helm 25 | uses: azure/setup-helm@v4.0.0 26 | 27 | - name: Run chart publisher script 28 | run: ./scripts/build/helm-publisher.sh ${{ join(github.event.release.assets.*.browser_download_url, ' ') }} 29 | shell: bash 30 | 31 | - name: Push 32 | run: | 33 | git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git gh-pages 34 | env: 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | shell: bash 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | 4 | *_gendata.go 5 | /build 6 | /deployment/operator/bundle/ 7 | /build-aux 8 | /generate 9 | coverage.html 10 | coverage.txt 11 | .git-hooks.redirected 12 | 13 | *.tar 14 | *.tar.* 15 | *.spec 16 | .static.* 17 | /debian 18 | /packages 19 | 20 | *.stamp 21 | test/e2e/**/output 22 | 23 | test/statistics-analysis/output 24 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # The NRI Plugins Project Community Code of Conduct 2 | 3 | The NRI Plugins Project follows the [Containers Community Code of Conduct](https://github.com/containers/common/blob/main/CODE-OF-CONDUCT.md). 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NRI Plugins 2 | 3 | This repository contains a collection of community maintained NRI plugins. 4 | 5 | Currently following plugins are available: 6 | 7 | | Name | Type | 8 | |---------------------|:-----------------:| 9 | | [Topology Aware][1] | resource policy | 10 | | [Balloons][2] | resource policy | 11 | | [Memtierd][3] | memory management | 12 | | [Memory-qos][4] | memory management | 13 | | [SGX-EPC][5] | memory management | 14 | 15 | [1]: https://containers.github.io/nri-plugins/stable/docs/resource-policy/policy/topology-aware.html 16 | [2]: https://containers.github.io/nri-plugins/stable/docs/resource-policy/policy/balloons.html 17 | [3]: https://containers.github.io/nri-plugins/stable/docs/memory/memtierd.html 18 | [4]: https://containers.github.io/nri-plugins/stable/docs/memory/memory-qos.html 19 | [5]: https://containers.github.io/nri-plugins/stable/docs/memory/sgx-epc.html 20 | 21 | See the [NRI plugins documentation](https://containers.github.io/nri-plugins/) for more information. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security and Disclosure Information Policy for the NRI Plugins Project 2 | 3 | * [Reporting a Vulnerability](#Reporting-a-Vulnerability) 4 | * [Security Announcements](#Security-Announcements) 5 | * [Security Vulnerability Response](#Security-Vulnerability-Response) 6 | 7 | ## Reporting a Vulnerability 8 | 9 | If you think you've identified a security issue in a NRI Plugins project, 10 | please DO NOT report the issue publicly via the Github issue tracker, 11 | mailing list, or IRC. Instead, send an email with as many details as 12 | possible to [cncf-crio-security@lists.cncf.io](mailto:cncf-crio-security@lists.cncf.io?subject=Security%20Vunerablity%20Report) or [security@containerd.io](mailto:security@containerd.io?subject=Security%20Vunerablity%20Report). 13 | 14 | Please do **not** create a public issue. 15 | 16 | ## Security Announcements 17 | 18 | The containerd-security-announce@lists.cncf.io email list is used for messages about 19 | plugins security announcements as well as general announcements and discussions. 20 | 21 | ## Security Vulnerability Response 22 | 23 | Each report is acknowledged and analyzed by the core maintainers within 3 working days. 24 | 25 | Any vulnerability information shared with core maintainers stays within the project 26 | and will not be disseminated to other projects unless it is necessary to get the issue fixed. 27 | 28 | As the security issue moves from triage, to an identified fix, to release planning, the core 29 | maintainers will keep the reporter updated. 30 | -------------------------------------------------------------------------------- /cmd/config-manager/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.25 2 | 3 | FROM golang:${GO_VERSION}-bookworm AS builder 4 | 5 | ARG IMAGE_VERSION 6 | ARG BUILD_VERSION 7 | ARG BUILD_BUILDID 8 | ARG DEBUG=0 9 | ARG NORACE=0 10 | ARG SKIP_LICENSES=0 11 | 12 | WORKDIR /go/builder 13 | 14 | # Fetch go dependencies in a separate layer for caching 15 | COPY go.mod go.sum . 16 | COPY pkg/topology/ pkg/topology/ 17 | RUN --mount=type=cache,target=/go/pkg/mod/ go mod download 18 | 19 | # Build config-manager binary 20 | COPY . . 21 | 22 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 23 | --mount=type=cache,target="/root/.cache/go-build" \ 24 | make IMAGE_VERSION=${IMAGE_VERSION} \ 25 | BUILD_VERSION=${BUILD_VERSION} \ 26 | BUILD_BUILDID=${BUILD_BUILDID} \ 27 | V=$DEBUG \ 28 | DEBUG=$DEBUG \ 29 | NORACE=$NORACE \ 30 | OTHER_IMAGE_TARGETS="" \ 31 | BINARIES=config-manager \ 32 | PLUGINS="" \ 33 | clean install-go-licenses build-binaries-static licenses 34 | 35 | FROM gcr.io/distroless/static 36 | 37 | COPY --from=builder /go/builder/build/bin/config-manager /bin/config-manager 38 | COPY --from=builder /go/builder/build/licenses/config-manager/ /licenses/config-manager/ 39 | 40 | ENTRYPOINT ["/bin/config-manager"] 41 | -------------------------------------------------------------------------------- /cmd/mpolset/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.25 2 | 3 | FROM golang:${GO_VERSION}-bookworm AS builder 4 | 5 | ARG IMAGE_VERSION 6 | ARG BUILD_VERSION 7 | ARG BUILD_BUILDID 8 | ARG DEBUG=0 9 | ARG NORACE=0 10 | ARG SKIP_LICENSES=0 11 | 12 | WORKDIR /go/builder 13 | 14 | # Fetch go dependencies in a separate layer for caching 15 | COPY go.mod go.sum . 16 | COPY pkg/topology/ pkg/topology/ 17 | RUN --mount=type=cache,target=/go/pkg/mod/ go mod download 18 | 19 | # Build mpolset 20 | COPY . . 21 | 22 | 23 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 24 | --mount=type=cache,target="/root/.cache/go-build" \ 25 | make IMAGE_VERSION=${IMAGE_VERSION} \ 26 | BUILD_VERSION=${BUILD_VERSION} \ 27 | BUILD_BUILDID=${BUILD_BUILDID} \ 28 | V=$DEBUG \ 29 | DEBUG=$DEBUG \ 30 | NORACE=$NORACE \ 31 | OTHER_IMAGE_TARGETS="" \ 32 | BINARIES=mpolset \ 33 | PLUGINS="" \ 34 | clean install-go-licenses build-binaries-static licenses 35 | 36 | FROM gcr.io/distroless/static 37 | 38 | COPY --from=builder /go/builder/build/bin/mpolset /bin/mpolset 39 | COPY --from=builder /go/builder/build/licenses/mpolset/ /licenses/mpolset/ 40 | 41 | ENTRYPOINT ["/bin/mpolset"] 42 | -------------------------------------------------------------------------------- /cmd/plugins/balloons/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "flag" 19 | 20 | policy "github.com/containers/nri-plugins/cmd/plugins/balloons/policy" 21 | agent "github.com/containers/nri-plugins/pkg/agent" 22 | logger "github.com/containers/nri-plugins/pkg/log" 23 | resmgr "github.com/containers/nri-plugins/pkg/resmgr/main" 24 | ) 25 | 26 | var log = logger.Default() 27 | 28 | func main() { 29 | flag.Parse() 30 | 31 | agt, err := agent.New(agent.BalloonsConfigInterface()) 32 | if err != nil { 33 | log.Fatal("%v", err) 34 | } 35 | 36 | mgr, err := resmgr.New(agt, policy.New()) 37 | if err != nil { 38 | log.Fatalf("%v", err) 39 | } 40 | 41 | if err := mgr.Run(); err != nil { 42 | log.Fatalf("%v", err) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /cmd/plugins/memory-policy/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.25 2 | 3 | FROM golang:${GO_VERSION}-bookworm AS builder 4 | 5 | ARG IMAGE_VERSION 6 | ARG BUILD_VERSION 7 | ARG BUILD_BUILDID 8 | ARG DEBUG=0 9 | ARG NORACE=0 10 | ARG SKIP_LICENSES=0 11 | 12 | WORKDIR /go/builder 13 | 14 | # Fetch go dependencies in a separate layer for caching 15 | COPY go.mod go.sum . 16 | COPY pkg/topology/ pkg/topology/ 17 | RUN --mount=type=cache,target=/go/pkg/mod/ go mod download 18 | 19 | # Build nri-resmgr 20 | COPY . . 21 | 22 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 23 | --mount=type=cache,target="/root/.cache/go-build" \ 24 | make IMAGE_VERSION=${IMAGE_VERSION} \ 25 | BUILD_VERSION=${BUILD_VERSION} \ 26 | BUILD_BUILDID=${BUILD_BUILDID} \ 27 | V=$DEBUG \ 28 | DEBUG=$DEBUG \ 29 | NORACE=$NORACE \ 30 | OTHER_IMAGE_TARGETS="" \ 31 | BINARIES=mpolset \ 32 | PLUGINS=nri-memory-policy \ 33 | clean install-go-licenses build-plugins-static build-binaries-static licenses 34 | 35 | FROM gcr.io/distroless/static 36 | 37 | COPY --from=builder /go/builder/build/bin/nri-memory-policy /bin/nri-memory-policy 38 | COPY --from=builder /go/builder/build/bin/mpolset /bin/mpolset 39 | COPY --from=builder /go/builder/build/licenses/nri-memory-policy/ /licenses/nri-memory-policy/ 40 | COPY --from=builder /go/builder/build/licenses/mpolset/ /licenses/mpolset/ 41 | COPY --from=builder /go/builder/sample-configs/nri-memory-policy.yaml /etc/nri/memory-policy/config.yaml 42 | 43 | ENTRYPOINT ["/bin/nri-memory-policy", "-idx", "92", "-config", "/etc/nri/memory-policy/config.yaml"] 44 | -------------------------------------------------------------------------------- /cmd/plugins/memory-qos/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.25 2 | 3 | FROM golang:${GO_VERSION}-bookworm AS builder 4 | 5 | ARG IMAGE_VERSION 6 | ARG BUILD_VERSION 7 | ARG BUILD_BUILDID 8 | ARG DEBUG=0 9 | ARG NORACE=0 10 | ARG SKIP_LICENSES=0 11 | 12 | WORKDIR /go/builder 13 | 14 | # Fetch go dependencies in a separate layer for caching 15 | COPY go.mod go.sum . 16 | COPY pkg/topology/ pkg/topology/ 17 | RUN --mount=type=cache,target=/go/pkg/mod/ go mod download 18 | 19 | # Build nri-resmgr 20 | COPY . . 21 | 22 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 23 | --mount=type=cache,target="/root/.cache/go-build" \ 24 | make IMAGE_VERSION=${IMAGE_VERSION} \ 25 | BUILD_VERSION=${BUILD_VERSION} \ 26 | BUILD_BUILDID=${BUILD_BUILDID} \ 27 | DEBUG=$DEBUG \ 28 | NORACE=$NORACE \ 29 | OTHER_IMAGE_TARGETS="" \ 30 | BINARIES="" \ 31 | PLUGINS=nri-memory-qos \ 32 | clean install-go-licenses build-plugins-static licenses 33 | 34 | FROM gcr.io/distroless/static 35 | 36 | COPY --from=builder /go/builder/build/bin/nri-memory-qos /bin/nri-memory-qos 37 | COPY --from=builder /go/builder/build/licenses/nri-memory-qos/ /licenses/nri-memory-qos/ 38 | COPY --from=builder /go/builder/sample-configs/nri-memory-qos.yaml /etc/nri/memory-qos/config.yaml 39 | 40 | ENTRYPOINT ["/bin/nri-memory-qos", "-idx", "40", "-config", "/etc/nri/memory-qos/config.yaml"] 41 | -------------------------------------------------------------------------------- /cmd/plugins/memtierd/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.25 2 | 3 | FROM golang:${GO_VERSION}-bookworm AS builder 4 | 5 | ARG IMAGE_VERSION 6 | ARG BUILD_VERSION 7 | ARG BUILD_BUILDID 8 | ARG DEBUG=0 9 | ARG NORACE=0 10 | ARG SKIP_LICENSES=0 11 | 12 | WORKDIR /go/builder 13 | 14 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 15 | --mount=type=cache,target="/root/.cache/go-build" \ 16 | GOBIN=/bin go install \ 17 | -tags osusergo,netgo \ 18 | -ldflags "-extldflags=-static" \ 19 | github.com/intel/memtierd/cmd/memtierd@v0.1.1 20 | 21 | # Fetch go dependencies in a separate layer for caching 22 | COPY go.mod go.sum . 23 | COPY pkg/topology/ pkg/topology/ 24 | RUN --mount=type=cache,target=/go/pkg/mod/ go mod download 25 | 26 | # Build nri-memtierd 27 | COPY . . 28 | 29 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 30 | --mount=type=cache,target="/root/.cache/go-build" \ 31 | make IMAGE_VERSION=${IMAGE_VERSION} \ 32 | BUILD_VERSION=${BUILD_VERSION} \ 33 | BUILD_BUILDID=${BUILD_BUILDID} \ 34 | DEBUG=$DEBUG \ 35 | NORACE=$NORACE \ 36 | OTHER_IMAGE_TARGETS="" \ 37 | BINARIES="" \ 38 | PLUGINS=nri-memtierd \ 39 | clean install-go-licenses build-plugins-static licenses 40 | 41 | FROM gcr.io/distroless/static 42 | ENV PATH=/bin 43 | 44 | COPY --from=builder /go/builder/build/bin/nri-memtierd /bin/nri-memtierd 45 | COPY --from=builder /go/builder/build/licenses/nri-memtierd/ /licenses/nri-memtierd/ 46 | COPY --from=builder /bin/memtierd /bin/memtierd 47 | 48 | ENTRYPOINT ["/bin/nri-memtierd", "--idx", "45"] 49 | -------------------------------------------------------------------------------- /cmd/plugins/memtierd/licensechack/pull-licenses.go: -------------------------------------------------------------------------------- 1 | package licensechack 2 | 3 | import ( 4 | _ "github.com/intel/memtierd/pkg/memtier" 5 | _ "github.com/intel/memtierd/pkg/version" 6 | ) 7 | -------------------------------------------------------------------------------- /cmd/plugins/sgx-epc/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.25 2 | 3 | FROM golang:${GO_VERSION}-bookworm AS builder 4 | 5 | ARG IMAGE_VERSION 6 | ARG BUILD_VERSION 7 | ARG BUILD_BUILDID 8 | ARG DEBUG=0 9 | ARG NORACE=0 10 | ARG SKIP_LICENSES=0 11 | 12 | WORKDIR /go/builder 13 | 14 | # Fetch go dependencies in a separate layer for caching 15 | COPY go.mod go.sum . 16 | COPY pkg/topology/ pkg/topology/ 17 | RUN --mount=type=cache,target=/go/pkg/mod/ go mod download 18 | 19 | # Build the nri-sgx-epc plugin. 20 | COPY . . 21 | 22 | 23 | RUN --mount=type=cache,target=/go/pkg/mod/ \ 24 | --mount=type=cache,target="/root/.cache/go-build" \ 25 | make IMAGE_VERSION=${IMAGE_VERSION} \ 26 | BUILD_VERSION=${BUILD_VERSION} \ 27 | BUILD_BUILDID=${BUILD_BUILDID} \ 28 | V=$DEBUG \ 29 | DEBUG=$DEBUG \ 30 | NORACE=$NORACE \ 31 | OTHER_IMAGE_TARGETS="" \ 32 | BINARIES="" \ 33 | PLUGINS=nri-sgx-epc \ 34 | clean install-go-licenses build-plugins-static licenses 35 | 36 | FROM gcr.io/distroless/static 37 | 38 | COPY --from=builder /go/builder/build/bin/nri-sgx-epc /bin/nri-sgx-epc 39 | COPY --from=builder /go/builder/build/licenses/nri-sgx-epc/ /licenses/nri-sgx-epc/ 40 | 41 | ENTRYPOINT ["/bin/nri-sgx-epc", "-idx", "40"] 42 | -------------------------------------------------------------------------------- /cmd/plugins/template/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "flag" 19 | 20 | policy "github.com/containers/nri-plugins/cmd/plugins/template/policy" 21 | agent "github.com/containers/nri-plugins/pkg/agent" 22 | logger "github.com/containers/nri-plugins/pkg/log" 23 | resmgr "github.com/containers/nri-plugins/pkg/resmgr/main" 24 | ) 25 | 26 | var ( 27 | log = logger.Default() 28 | ) 29 | 30 | func main() { 31 | flag.Parse() 32 | 33 | agt, err := agent.New(agent.TemplateConfigInterface()) 34 | if err != nil { 35 | log.Fatal("%v", err) 36 | } 37 | 38 | mgr, err := resmgr.New(agt, policy.New()) 39 | if err != nil { 40 | log.Fatalf("%v", err) 41 | } 42 | 43 | if err := mgr.Run(); err != nil { 44 | log.Fatalf("%v", err) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /cmd/plugins/topology-aware/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "flag" 19 | 20 | policy "github.com/containers/nri-plugins/cmd/plugins/topology-aware/policy" 21 | agent "github.com/containers/nri-plugins/pkg/agent" 22 | logger "github.com/containers/nri-plugins/pkg/log" 23 | resmgr "github.com/containers/nri-plugins/pkg/resmgr/main" 24 | ) 25 | 26 | var ( 27 | log = logger.Default() 28 | ) 29 | 30 | func main() { 31 | flag.Parse() 32 | 33 | agt, err := agent.New(agent.TopologyAwareConfigInterface()) 34 | if err != nil { 35 | log.Fatal("%v", err) 36 | } 37 | 38 | mgr, err := resmgr.New(agt, policy.New()) 39 | if err != nil { 40 | log.Fatalf("%v", err) 41 | } 42 | 43 | if err := mgr.Run(); err != nil { 44 | log.Fatalf("%v", err) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /cmd/plugins/topology-aware/policy/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package topologyaware 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | // policyError creates a formatted policy-specific error. 22 | func policyError(format string, args ...interface{}) error { 23 | return fmt.Errorf(PolicyName+": "+format, args...) 24 | } 25 | -------------------------------------------------------------------------------- /cmd/plugins/topology-aware/policy/logging.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package topologyaware 16 | 17 | import ( 18 | "fmt" 19 | 20 | logger "github.com/containers/nri-plugins/pkg/log" 21 | ) 22 | 23 | // Create our logger instance. 24 | var log logger.Logger = logger.NewLogger("policy") 25 | 26 | // indent produces an indentation string for the given level. 27 | const ( 28 | IndentDepth = 4 29 | ) 30 | 31 | func indent(prefix string, level ...int) string { 32 | if len(level) < 1 { 33 | return prefix 34 | } 35 | 36 | depth := level[0] * IndentDepth 37 | return prefix + fmt.Sprintf("%*.*s", depth, depth, "") 38 | } 39 | -------------------------------------------------------------------------------- /cmd/plugins/topology-aware/policy/testdata/sysfs.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/cmd/plugins/topology-aware/policy/testdata/sysfs.tar.bz2 -------------------------------------------------------------------------------- /deployment/helm/balloons/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deployment/helm/balloons/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | The balloons NRI resource policy plugin implements workload placement into 5 | “balloons” that are disjoint CPU pools. 6 | name: nri-resource-policy-balloons 7 | sources: 8 | - https://github.com/containers/nri-plugins 9 | home: https://github.com/containers/nri-plugins 10 | type: application 11 | version: v0.0.0 12 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-resource-policy-balloons 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: nri-resource-policy-balloons 5 | labels: 6 | {{- include "nri-plugin.labels" . | nindent 4 }} 7 | rules: 8 | - apiGroups: 9 | - "" 10 | resources: 11 | - nodes 12 | verbs: 13 | - get 14 | - watch 15 | - apiGroups: 16 | - topology.node.k8s.io 17 | resources: 18 | - noderesourcetopologies 19 | verbs: 20 | - create 21 | - get 22 | - list 23 | - update 24 | - delete 25 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: nri-resource-policy-balloons 5 | labels: 6 | {{- include "nri-plugin.labels" . | nindent 4 }} 7 | roleRef: 8 | apiGroup: rbac.authorization.k8s.io 9 | kind: ClusterRole 10 | name: nri-resource-policy-balloons 11 | subjects: 12 | - kind: ServiceAccount 13 | name: nri-resource-policy-balloons 14 | namespace: {{ .Release.Namespace }} 15 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.nri/v1alpha1 2 | kind: BalloonsPolicy 3 | metadata: 4 | name: default 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | spec: 9 | {{- toYaml .Values.config | nindent 2 }} 10 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | name: nri-resource-policy-balloons 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | rules: 9 | - apiGroups: 10 | - config.nri 11 | resources: 12 | - balloonspolicies 13 | verbs: 14 | - get 15 | - list 16 | - watch 17 | - apiGroups: 18 | - config.nri 19 | resources: 20 | - balloonspolicies/status 21 | verbs: 22 | - get 23 | - update 24 | - patch 25 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/rolebindings.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: nri-resource-policy-balloons 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | roleRef: 9 | apiGroup: rbac.authorization.k8s.io 10 | kind: Role 11 | name: nri-resource-policy-balloons 12 | subjects: 13 | - kind: ServiceAccount 14 | name: nri-resource-policy-balloons 15 | namespace: {{ .Release.Namespace }} 16 | -------------------------------------------------------------------------------- /deployment/helm/balloons/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: nri-resource-policy-balloons 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | -------------------------------------------------------------------------------- /deployment/helm/memory-policy/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | The memory-policy NRI plugin configures default Linux memory policy 5 | for containers at creation time. 6 | name: nri-memory-policy 7 | sources: 8 | - https://github.com/containers/nri-plugins 9 | home: https://github.com/containers/nri-plugins 10 | type: application 11 | version: v0.0.0 12 | -------------------------------------------------------------------------------- /deployment/helm/memory-policy/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-memory-policy 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/memory-policy/templates/configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nri-memory-policy-config.default 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | data: 9 | config.yaml: | 10 | {{- toYaml .Values.config | nindent 4 }} 11 | -------------------------------------------------------------------------------- /deployment/helm/memory-qos/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deployment/helm/memory-qos/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | The memory-qos NRI plugin adds two methods for controlling cgroups v2 5 | memory.* parameters: QoS class and direct memory annotations. 6 | name: nri-memory-qos 7 | sources: 8 | - https://github.com/containers/nri-plugins 9 | home: https://github.com/containers/nri-plugins 10 | type: application 11 | version: v0.0.0 12 | -------------------------------------------------------------------------------- /deployment/helm/memory-qos/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-memory-qos 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/memory-qos/templates/configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nri-memory-qos-config.default 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | data: 9 | config.yaml: | 10 | classes: 11 | - name: bronze 12 | swaplimitratio: 0.5 13 | - name: silver 14 | swaplimitratio: 0.2 15 | unifiedannotations: 16 | - memory.swap.max 17 | - memory.high 18 | -------------------------------------------------------------------------------- /deployment/helm/memtierd/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deployment/helm/memtierd/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | The memtierd NRI plugin enables managing workloads with Memtierd in Kubernetes. 5 | name: nri-memtierd 6 | sources: 7 | - https://github.com/containers/nri-plugins 8 | home: https://github.com/containers/nri-plugins 9 | type: application 10 | version: v0.0.0 11 | -------------------------------------------------------------------------------- /deployment/helm/memtierd/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-memtierd 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/sgx-epc/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deployment/helm/sgx-epc/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | The sgx-epc NRI plugin allows control over SGX encrypted page cache usage using the 5 | cgroup v2 misc controller and pod annotations. 6 | name: nri-sgx-epc 7 | sources: 8 | - https://github.com/containers/nri-plugins 9 | home: https://github.com/containers/nri-plugins 10 | type: application 11 | version: v0.0.0 12 | -------------------------------------------------------------------------------- /deployment/helm/sgx-epc/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-sgx-epc 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/template/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deployment/helm/template/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | The template NRI resource policy plugin is a wireframe implementation without any policy logic. It can be used as a template to create new policies. 5 | name: nri-resource-policy-template 6 | sources: 7 | - https://github.com/containers/nri-plugins 8 | home: https://github.com/containers/nri-plugins 9 | type: application 10 | version: v0.0.0 11 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-resource-policy-template 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: nri-resource-policy-template 5 | labels: 6 | {{- include "nri-plugin.labels" . | nindent 4 }} 7 | rules: 8 | - apiGroups: 9 | - "" 10 | resources: 11 | - nodes 12 | verbs: 13 | - get 14 | - watch 15 | - apiGroups: 16 | - topology.node.k8s.io 17 | resources: 18 | - noderesourcetopologies 19 | verbs: 20 | - create 21 | - get 22 | - list 23 | - update 24 | - delete 25 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: nri-resource-policy-template 5 | labels: 6 | {{- include "nri-plugin.labels" . | nindent 4 }} 7 | roleRef: 8 | apiGroup: rbac.authorization.k8s.io 9 | kind: ClusterRole 10 | name: nri-resource-policy-template 11 | subjects: 12 | - kind: ServiceAccount 13 | name: nri-resource-policy-template 14 | namespace: {{ .Release.Namespace }} 15 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.nri/v1alpha1 2 | kind: TemplatePolicy 3 | metadata: 4 | name: default 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | spec: 9 | {{- toYaml .Values.config | nindent 2 }} 10 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | name: nri-resource-policy-template 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | rules: 9 | - apiGroups: 10 | - config.nri 11 | resources: 12 | - templatepolicies 13 | verbs: 14 | - get 15 | - list 16 | - watch 17 | - apiGroups: 18 | - config.nri 19 | resources: 20 | - templatepolicies/status 21 | verbs: 22 | - get 23 | - update 24 | - patch 25 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/rolebindings.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: nri-resource-policy-template 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | roleRef: 9 | apiGroup: rbac.authorization.k8s.io 10 | kind: Role 11 | name: nri-resource-policy-template 12 | subjects: 13 | - kind: ServiceAccount 14 | name: nri-resource-policy-template 15 | namespace: {{ .Release.Namespace }} 16 | -------------------------------------------------------------------------------- /deployment/helm/template/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: nri-resource-policy-template 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | appVersion: unstable 3 | description: | 4 | Topology-aware NRI resource policy plugin is a NRI plugin that will 5 | apply hardware-aware resource allocation policies to the containers 6 | running in the system. 7 | name: nri-resource-policy-topology-aware 8 | sources: 9 | - https://github.com/containers/nri-plugins 10 | home: https://github.com/containers/nri-plugins 11 | type: application 12 | version: v0.0.0 13 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Common labels 3 | */}} 4 | {{- define "nri-plugin.labels" -}} 5 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} 6 | app.kubernetes.io/managed-by: {{ .Release.Service }} 7 | {{ include "nri-plugin.selectorLabels" . }} 8 | {{- end -}} 9 | 10 | {{/* 11 | Selector labels 12 | */}} 13 | {{- define "nri-plugin.selectorLabels" -}} 14 | app.kubernetes.io/name: nri-resource-policy-topology-aware 15 | app.kubernetes.io/instance: {{ .Release.Name }} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: nri-resource-policy-topology-aware 5 | labels: 6 | {{- include "nri-plugin.labels" . | nindent 4 }} 7 | rules: 8 | - apiGroups: 9 | - "" 10 | resources: 11 | - nodes 12 | verbs: 13 | - get 14 | - watch 15 | - apiGroups: 16 | - topology.node.k8s.io 17 | resources: 18 | - noderesourcetopologies 19 | verbs: 20 | - create 21 | - get 22 | - list 23 | - update 24 | - delete 25 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: nri-resource-policy-topology-aware 5 | labels: 6 | {{- include "nri-plugin.labels" . | nindent 4 }} 7 | roleRef: 8 | apiGroup: rbac.authorization.k8s.io 9 | kind: ClusterRole 10 | name: nri-resource-policy-topology-aware 11 | subjects: 12 | - kind: ServiceAccount 13 | name: nri-resource-policy-topology-aware 14 | namespace: {{ .Release.Namespace }} 15 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.nri/v1alpha1 2 | kind: TopologyAwarePolicy 3 | metadata: 4 | name: default 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | spec: 9 | {{- toYaml .Values.config | nindent 2 }} 10 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | name: nri-resource-policy-topology-aware 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | rules: 9 | - apiGroups: 10 | - config.nri 11 | resources: 12 | - topologyawarepolicies 13 | verbs: 14 | - get 15 | - list 16 | - watch 17 | - apiGroups: 18 | - config.nri 19 | resources: 20 | - topologyawarepolicies/status 21 | verbs: 22 | - get 23 | - update 24 | - patch 25 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/rolebindings.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: nri-resource-policy-topology-aware 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | roleRef: 9 | apiGroup: rbac.authorization.k8s.io 10 | kind: Role 11 | name: nri-resource-policy-topology-aware 12 | subjects: 13 | - kind: ServiceAccount 14 | name: nri-resource-policy-topology-aware 15 | namespace: {{ .Release.Namespace }} 16 | -------------------------------------------------------------------------------- /deployment/helm/topology-aware/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: nri-resource-policy-topology-aware 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | {{- include "nri-plugin.labels" . | nindent 4 }} 8 | -------------------------------------------------------------------------------- /deployment/operator/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:latest AS build 2 | ENV VERIFY_CHECKSUM=false 3 | RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \ 4 | && chmod 700 get_helm.sh && ./get_helm.sh 5 | 6 | FROM quay.io/operator-framework/ansible-operator:v1.36.0 7 | COPY --from=build /usr/local/bin/helm /usr/local/bin/helm 8 | COPY requirements.yml ${HOME}/requirements.yml 9 | RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \ 10 | && chmod -R ug+rwx ${HOME}/.ansible 11 | 12 | COPY watches.yaml ${HOME}/watches.yaml 13 | COPY ansible.cfg /etc/ansible/ansible.cfg 14 | COPY roles/ ${HOME}/roles/ 15 | COPY playbooks/ ${HOME}/playbooks/ 16 | -------------------------------------------------------------------------------- /deployment/operator/PROJECT: -------------------------------------------------------------------------------- 1 | # Code generated by tool. DO NOT EDIT. 2 | # This file is used to track the info used to scaffold your project 3 | # and allow the plugins properly work. 4 | # More info: https://book.kubebuilder.io/reference/project-config.html 5 | layout: 6 | - ansible.sdk.operatorframework.io/v1 7 | multigroup: true 8 | plugins: 9 | manifests.sdk.operatorframework.io/v2: {} 10 | scorecard.sdk.operatorframework.io/v2: {} 11 | projectName: nri-plugins-operator 12 | resources: 13 | - api: 14 | crdVersion: v1 15 | namespaced: true 16 | group: config.nri 17 | kind: NriPluginDeployment 18 | version: v1alpha1 19 | version: "3" 20 | -------------------------------------------------------------------------------- /deployment/operator/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path = /opt/ansible/roles 3 | library = /usr/share/ansible/openshift 4 | display_skipped_hosts = False 5 | force_color = 1 6 | -------------------------------------------------------------------------------- /deployment/operator/bundle.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | 3 | # Core bundle labels. 4 | LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 5 | LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ 6 | LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ 7 | LABEL operators.operatorframework.io.bundle.package.v1=nri-plugins-operator 8 | LABEL operators.operatorframework.io.bundle.channels.v1=alpha 9 | LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.36.0 10 | LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 11 | LABEL operators.operatorframework.io.metrics.project_layout=ansible.sdk.operatorframework.io/v1 12 | 13 | # Labels for testing. 14 | LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1 15 | LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/ 16 | 17 | # Copy files to locations specified by labels. 18 | COPY bundle/manifests /manifests/ 19 | COPY bundle/metadata /metadata/ 20 | COPY bundle/tests/scorecard /tests/scorecard/ 21 | -------------------------------------------------------------------------------- /deployment/operator/config/crd/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # This kustomization.yaml is not intended to be run by itself, 2 | # since it depends on service name and namespace that are out of this kustomize package. 3 | # It should be run by config/default 4 | resources: 5 | # NOTE(fmuyassarov): We will copy the below CRD files (from the top level config/crd/bases) 6 | # during the bundle build process. We don't store the same copies here too to avoid duplication. 7 | - bases/config.nri_nriplugindeployments.yaml 8 | - bases/topology.node.k8s.io_noderesourcetopologies.yaml 9 | - bases/config.nri_balloonspolicies.yaml 10 | - bases/config.nri_templatepolicies.yaml 11 | - bases/config.nri_topologyawarepolicies.yaml 12 | #+kubebuilder:scaffold:crdkustomizeresource 13 | -------------------------------------------------------------------------------- /deployment/operator/config/default/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # Adds namespace to all resources. 2 | namespace: nri-plugins-operator-system 3 | 4 | # Value of this field is prepended to the 5 | # names of all resources, e.g. a deployment named 6 | # "wordpress" becomes "alices-wordpress". 7 | # Note that it should also match with the prefix (text before '-') of the namespace 8 | # field above. 9 | namePrefix: nri-plugins-operator- 10 | 11 | # Labels to add to all resources and selectors. 12 | #labels: 13 | #- includeSelectors: true 14 | # pairs: 15 | # someName: someValue 16 | 17 | resources: 18 | - ../crd 19 | - ../rbac 20 | - ../manager 21 | # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. 22 | #- ../prometheus 23 | 24 | # Protect the /metrics endpoint by putting it behind auth. 25 | # If you want your controller-manager to expose the /metrics 26 | # endpoint w/o any authn/z, please comment the following line. 27 | patches: 28 | - path: manager_auth_proxy_patch.yaml 29 | -------------------------------------------------------------------------------- /deployment/operator/config/default/manager_config_patch.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: controller-manager 5 | namespace: system 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: manager 11 | -------------------------------------------------------------------------------- /deployment/operator/config/manager/kustomization.yaml.in: -------------------------------------------------------------------------------- 1 | resources: 2 | - manager.yaml 3 | apiVersion: kustomize.config.k8s.io/v1beta1 4 | kind: Kustomization 5 | images: 6 | - name: controller 7 | newName: ghcr.io/containers/nri-plugins/nri-plugins-operator 8 | newTag: unstable 9 | -------------------------------------------------------------------------------- /deployment/operator/config/manifests/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # These resources constitute the fully configured set of manifests 2 | # used to generate the 'manifests/' directory in a bundle. 3 | resources: 4 | - bases/nri-plugins-operator.clusterserviceversion.yaml 5 | - ../default 6 | - ../samples 7 | - ../scorecard 8 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/auth_proxy_client_clusterrole.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: clusterrole 6 | app.kubernetes.io/instance: metrics-reader 7 | app.kubernetes.io/component: kube-rbac-proxy 8 | app.kubernetes.io/created-by: nri-plugins-operator 9 | app.kubernetes.io/part-of: nri-plugins-operator 10 | app.kubernetes.io/managed-by: kustomize 11 | name: metrics-reader 12 | rules: 13 | - nonResourceURLs: 14 | - "/metrics" 15 | verbs: 16 | - get 17 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/auth_proxy_role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: clusterrole 6 | app.kubernetes.io/instance: proxy-role 7 | app.kubernetes.io/component: kube-rbac-proxy 8 | app.kubernetes.io/created-by: nri-plugins-operator 9 | app.kubernetes.io/part-of: nri-plugins-operator 10 | app.kubernetes.io/managed-by: kustomize 11 | name: proxy-role 12 | rules: 13 | - apiGroups: 14 | - authentication.k8s.io 15 | resources: 16 | - tokenreviews 17 | verbs: 18 | - create 19 | - apiGroups: 20 | - authorization.k8s.io 21 | resources: 22 | - subjectaccessreviews 23 | verbs: 24 | - create 25 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/auth_proxy_role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: clusterrolebinding 6 | app.kubernetes.io/instance: proxy-rolebinding 7 | app.kubernetes.io/component: kube-rbac-proxy 8 | app.kubernetes.io/created-by: nri-plugins-operator 9 | app.kubernetes.io/part-of: nri-plugins-operator 10 | app.kubernetes.io/managed-by: kustomize 11 | name: proxy-rolebinding 12 | roleRef: 13 | apiGroup: rbac.authorization.k8s.io 14 | kind: ClusterRole 15 | name: proxy-role 16 | subjects: 17 | - kind: ServiceAccount 18 | name: controller-manager 19 | namespace: system 20 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/auth_proxy_service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | control-plane: controller-manager 6 | app.kubernetes.io/name: service 7 | app.kubernetes.io/instance: controller-manager-metrics-service 8 | app.kubernetes.io/component: kube-rbac-proxy 9 | app.kubernetes.io/created-by: nri-plugins-operator 10 | app.kubernetes.io/part-of: nri-plugins-operator 11 | app.kubernetes.io/managed-by: kustomize 12 | name: controller-manager-metrics-service 13 | namespace: system 14 | spec: 15 | ports: 16 | - name: https 17 | port: 8443 18 | protocol: TCP 19 | targetPort: https 20 | selector: 21 | control-plane: controller-manager 22 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/config.nri_nriplugindeployment_editor_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to edit nriplugindeployments. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | labels: 6 | app.kubernetes.io/name: clusterrole 7 | app.kubernetes.io/instance: nriplugindeployment-editor-role 8 | app.kubernetes.io/component: rbac 9 | app.kubernetes.io/created-by: nri-plugins-operator 10 | app.kubernetes.io/part-of: nri-plugins-operator 11 | app.kubernetes.io/managed-by: kustomize 12 | name: nriplugindeployment-editor-role 13 | rules: 14 | - apiGroups: 15 | - config.nri 16 | resources: 17 | - nriplugindeployments 18 | verbs: 19 | - create 20 | - delete 21 | - get 22 | - list 23 | - patch 24 | - update 25 | - watch 26 | - apiGroups: 27 | - config.nri 28 | resources: 29 | - nriplugindeployments/status 30 | verbs: 31 | - get 32 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/config.nri_nriplugindeployment_viewer_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to view nriplugindeployments. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | labels: 6 | app.kubernetes.io/name: clusterrole 7 | app.kubernetes.io/instance: nriplugindeployment-viewer-role 8 | app.kubernetes.io/component: rbac 9 | app.kubernetes.io/created-by: nri-plugins-operator 10 | app.kubernetes.io/part-of: nri-plugins-operator 11 | app.kubernetes.io/managed-by: kustomize 12 | name: nriplugindeployment-viewer-role 13 | rules: 14 | - apiGroups: 15 | - config.nri 16 | resources: 17 | - nriplugindeployments 18 | verbs: 19 | - get 20 | - list 21 | - watch 22 | - apiGroups: 23 | - config.nri 24 | resources: 25 | - nriplugindeployments/status 26 | verbs: 27 | - get 28 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | # All RBAC will be applied under this service account in 3 | # the deployment namespace. You may comment out this resource 4 | # if your manager will use a service account that exists at 5 | # runtime. Be sure to update RoleBinding and ClusterRoleBinding 6 | # subjects if changing service account names. 7 | - service_account.yaml 8 | - role.yaml 9 | - role_binding.yaml 10 | - leader_election_role.yaml 11 | - leader_election_role_binding.yaml 12 | # Comment the following 4 lines if you want to disable 13 | # the auth proxy (https://github.com/brancz/kube-rbac-proxy) 14 | # which protects your /metrics endpoint. 15 | - auth_proxy_service.yaml 16 | - auth_proxy_role.yaml 17 | - auth_proxy_role_binding.yaml 18 | - auth_proxy_client_clusterrole.yaml 19 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/leader_election_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions to do leader election. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: Role 4 | metadata: 5 | labels: 6 | app.kubernetes.io/name: role 7 | app.kubernetes.io/instance: leader-election-role 8 | app.kubernetes.io/component: rbac 9 | app.kubernetes.io/created-by: nri-plugins-operator 10 | app.kubernetes.io/part-of: nri-plugins-operator 11 | app.kubernetes.io/managed-by: kustomize 12 | name: leader-election-role 13 | rules: 14 | - apiGroups: 15 | - "" 16 | resources: 17 | - configmaps 18 | verbs: 19 | - get 20 | - list 21 | - watch 22 | - create 23 | - update 24 | - patch 25 | - delete 26 | - apiGroups: 27 | - coordination.k8s.io 28 | resources: 29 | - leases 30 | verbs: 31 | - get 32 | - list 33 | - watch 34 | - create 35 | - update 36 | - patch 37 | - delete 38 | - apiGroups: 39 | - "" 40 | resources: 41 | - events 42 | verbs: 43 | - create 44 | - patch 45 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/leader_election_role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: rolebinding 6 | app.kubernetes.io/instance: leader-election-rolebinding 7 | app.kubernetes.io/component: rbac 8 | app.kubernetes.io/created-by: nri-plugins-operator 9 | app.kubernetes.io/part-of: nri-plugins-operator 10 | app.kubernetes.io/managed-by: kustomize 11 | name: leader-election-rolebinding 12 | roleRef: 13 | apiGroup: rbac.authorization.k8s.io 14 | kind: Role 15 | name: leader-election-role 16 | subjects: 17 | - kind: ServiceAccount 18 | name: controller-manager 19 | namespace: system 20 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/role.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: manager-role 6 | rules: 7 | ## 8 | ## Rules for the operator 9 | ## 10 | - apiGroups: 11 | - config.nri 12 | resources: 13 | - nriplugindeployments 14 | verbs: 15 | - get 16 | - list 17 | - watch 18 | - update 19 | - apiGroups: 20 | - config.nri 21 | resources: 22 | - nriplugindeployments/status 23 | verbs: 24 | - get 25 | - update 26 | - patch 27 | - apiGroups: 28 | - topology.node.k8s.io 29 | resources: 30 | - noderesourcetopologies 31 | verbs: 32 | - create 33 | - get 34 | - update 35 | ## 36 | ## Rules for config.nri/v1alpha1, Kind: NriPluginDeployment 37 | ## 38 | - verbs: 39 | - "*" 40 | apiGroups: 41 | - "rbac.authorization.k8s.io" 42 | - "apps" 43 | - "" 44 | resources: 45 | - "clusterrolebindings" 46 | - "clusterroles" 47 | - "rolebindings" 48 | - "roles" 49 | - "daemonsets" 50 | - "configmaps" 51 | - "serviceaccounts" 52 | - "namespaces" 53 | - "secrets" 54 | #+kubebuilder:scaffold:rules 55 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: clusterrolebinding 6 | app.kubernetes.io/instance: manager-rolebinding 7 | app.kubernetes.io/component: rbac 8 | app.kubernetes.io/created-by: nri-plugins-operator 9 | app.kubernetes.io/part-of: nri-plugins-operator 10 | app.kubernetes.io/managed-by: kustomize 11 | name: manager-rolebinding 12 | roleRef: 13 | apiGroup: rbac.authorization.k8s.io 14 | kind: ClusterRole 15 | name: manager-role 16 | subjects: 17 | - kind: ServiceAccount 18 | name: controller-manager 19 | namespace: system 20 | -------------------------------------------------------------------------------- /deployment/operator/config/rbac/service_account.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: serviceaccount 6 | app.kubernetes.io/instance: controller-manager-sa 7 | app.kubernetes.io/component: rbac 8 | app.kubernetes.io/created-by: nri-plugins-operator 9 | app.kubernetes.io/part-of: nri-plugins-operator 10 | app.kubernetes.io/managed-by: kustomize 11 | name: controller-manager 12 | namespace: system 13 | -------------------------------------------------------------------------------- /deployment/operator/config/samples/config.nri_v1alpha1_nriplugindeployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.nri/v1alpha1 2 | kind: NriPluginDeployment 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: nriplugindeployment 6 | app.kubernetes.io/instance: nriplugindeployment-sample 7 | app.kubernetes.io/part-of: nri-plugins-operator 8 | app.kubernetes.io/managed-by: kustomize 9 | app.kubernetes.io/created-by: nri-plugins-operator 10 | name: nriplugindeployment-sample 11 | namespace: kube-system 12 | spec: 13 | pluginName: topology-aware 14 | pluginVersion: "v0.2.3" 15 | state: present 16 | values: 17 | nri: 18 | runtime: 19 | patchConfig: true 20 | -------------------------------------------------------------------------------- /deployment/operator/config/samples/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # NOTE(fmuyassarov): We will copy the below CR files (from the top level sample-configs/) 2 | # during the bundle build process. We don't store the same copies here too to avoid duplication. 3 | resources: 4 | - config.nri_v1alpha1_nriplugindeployment.yaml 5 | - balloons-config.yaml 6 | - template-config.yaml 7 | - topologyaware-config.yaml 8 | - noderesourcetopology.yaml 9 | #+kubebuilder:scaffold:manifestskustomizesamples 10 | -------------------------------------------------------------------------------- /deployment/operator/config/scorecard/bases/config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: scorecard.operatorframework.io/v1alpha3 2 | kind: Configuration 3 | metadata: 4 | name: config 5 | stages: 6 | - parallel: true 7 | tests: [] 8 | -------------------------------------------------------------------------------- /deployment/operator/config/scorecard/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - bases/config.yaml 3 | patchesJson6902: 4 | - path: patches/basic.config.yaml 5 | target: 6 | group: scorecard.operatorframework.io 7 | version: v1alpha3 8 | kind: Configuration 9 | name: config 10 | - path: patches/olm.config.yaml 11 | target: 12 | group: scorecard.operatorframework.io 13 | version: v1alpha3 14 | kind: Configuration 15 | name: config 16 | #+kubebuilder:scaffold:patchesJson6902 17 | -------------------------------------------------------------------------------- /deployment/operator/config/scorecard/patches/basic.config.yaml: -------------------------------------------------------------------------------- 1 | - op: add 2 | path: /stages/0/tests/- 3 | value: 4 | entrypoint: 5 | - scorecard-test 6 | - basic-check-spec 7 | image: quay.io/operator-framework/scorecard-test:v1.32.0 8 | labels: 9 | suite: basic 10 | test: basic-check-spec-test 11 | -------------------------------------------------------------------------------- /deployment/operator/config/scorecard/patches/olm.config.yaml: -------------------------------------------------------------------------------- 1 | - op: add 2 | path: /stages/0/tests/- 3 | value: 4 | entrypoint: 5 | - scorecard-test 6 | - olm-bundle-validation 7 | image: quay.io/operator-framework/scorecard-test:v1.32.0 8 | labels: 9 | suite: olm 10 | test: olm-bundle-validation-test 11 | - op: add 12 | path: /stages/0/tests/- 13 | value: 14 | entrypoint: 15 | - scorecard-test 16 | - olm-crds-have-validation 17 | image: quay.io/operator-framework/scorecard-test:v1.32.0 18 | labels: 19 | suite: olm 20 | test: olm-crds-have-validation-test 21 | - op: add 22 | path: /stages/0/tests/- 23 | value: 24 | entrypoint: 25 | - scorecard-test 26 | - olm-crds-have-resources 27 | image: quay.io/operator-framework/scorecard-test:v1.32.0 28 | labels: 29 | suite: olm 30 | test: olm-crds-have-resources-test 31 | - op: add 32 | path: /stages/0/tests/- 33 | value: 34 | entrypoint: 35 | - scorecard-test 36 | - olm-spec-descriptors 37 | image: quay.io/operator-framework/scorecard-test:v1.32.0 38 | labels: 39 | suite: olm 40 | test: olm-spec-descriptors-test 41 | - op: add 42 | path: /stages/0/tests/- 43 | value: 44 | entrypoint: 45 | - scorecard-test 46 | - olm-status-descriptors 47 | image: quay.io/operator-framework/scorecard-test:v1.32.0 48 | labels: 49 | suite: olm 50 | test: olm-status-descriptors-test 51 | -------------------------------------------------------------------------------- /deployment/operator/playbooks/plugin-deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | gather_facts: no 4 | collections: 5 | - kubernetes.core 6 | - operator_sdk.util 7 | tasks: 8 | - import_role: 9 | name: "plugin-deployment" 10 | -------------------------------------------------------------------------------- /deployment/operator/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | collections: 3 | - name: operator_sdk.util 4 | version: "0.5.0" 5 | - name: kubernetes.core 6 | version: "2.4.0" 7 | - name: cloud.common 8 | version: "2.1.1" 9 | - name: community.docker 10 | version: "3.4.0" 11 | -------------------------------------------------------------------------------- /deployment/operator/roles/plugin-deployment/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add nri-plugins helm chart repo 3 | kubernetes.core.helm_repository: 4 | name: nri-plugins 5 | repo_url: "https://containers.github.io/nri-plugins" 6 | 7 | - name: Plugin installation 8 | block: 9 | - name: Set plugin chart reference 10 | set_fact: 11 | chart_ref: "nri-plugins/nri-{{ 'resource-policy-' if pluginName in ['topology-aware', 'balloons'] else '' }}{{ pluginName }}" 12 | 13 | - name: Deploy {{ pluginName }} plugin 14 | kubernetes.core.helm: 15 | name: "{{ pluginName }}" 16 | chart_ref: "{{ chart_ref }}" 17 | release_namespace: "{{ ansible_operator_meta.namespace }}" 18 | chart_version: "{{ pluginVersion }}" 19 | wait: True 20 | create_namespace: True 21 | values: "{{ values | default({}) }}" 22 | skip_crds: True 23 | when: 24 | - state == "present" 25 | - pluginName in ["topology-aware", "balloons", "memory-qos", "memtierd", "sgx-epc"] 26 | 27 | - name: Uninstall {{ pluginName }} plugin 28 | kubernetes.core.helm: 29 | name: "{{ pluginName }}" 30 | namespace: "{{ ansible_operator_meta.namespace }}" 31 | state: absent 32 | when: state == "absent" or state == "revoked" 33 | -------------------------------------------------------------------------------- /deployment/operator/watches.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - version: v1alpha1 3 | group: config.nri 4 | kind: NriPluginDeployment 5 | playbook: playbooks/plugin-deployment.yml 6 | snakeCaseParameters: False 7 | manageStatus: True 8 | finalizer: 9 | name: nriplugindeployment.config.nri/finalizer 10 | vars: 11 | state: revoked 12 | #+kubebuilder:scaffold:watch 13 | -------------------------------------------------------------------------------- /docs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM sphinxdoc/sphinx:7.4.7 2 | 3 | ARG GO_VERSION=1.25.0 4 | 5 | RUN apt-get update && apt-get install -y wget git 6 | 7 | # Note: Any golang version that can 'go list -m -f {{.Variable}}' is fine... 8 | RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ 9 | tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz 10 | 11 | ENV PATH=$PATH:/usr/local/go/bin 12 | 13 | COPY requirements.txt . 14 | 15 | RUN pip3 install -r requirements.txt 16 | -------------------------------------------------------------------------------- /docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {%- extends "!layout.html" %} 2 | 3 | {% block footer %} 4 | {% if versions_menu %} 5 |
6 | 7 | GitHub Pages 8 | {{ versions_menu_this_version }} 9 | 10 | 11 |
12 |
13 |
{{ _('Versions') }}
14 |
15 |
16 |
17 | all releases 18 |
19 |
20 |
21 |
22 | {% endif %} 23 | 24 | 35 | {% endblock %} 36 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Please use the GitHub\* infrastructure for contributing to NRI Plugins. 4 | Use [pull requests](https://github.com/containers/nri-plugins/pulls) 5 | to contribute code, bug fixes, or if you want to discuss your ideas in terms of 6 | code. Open [issues](https://github.com/containers/nri-plugins/issues) to 7 | report bugs, request new features, or if you want to discuss any other topics 8 | related to NRI plugins. 9 | 10 | For the actual NRI (Node Resource Interface) API, please see [NRI repository](https://github.com/containerd/nri) 11 | -------------------------------------------------------------------------------- /docs/deployment/helm/balloons.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/helm/balloons/README.md 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/deployment/helm/memory-qos.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/helm/memory-qos/README.md 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/deployment/helm/memtierd.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/helm/memtierd/README.md 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/deployment/helm/sgx-epc.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/helm/sgx-epc/README.md 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/deployment/helm/template.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/helm/template/README.md 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/deployment/helm/topology-aware.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/helm/topology-aware/README.md 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/deployment/index.md: -------------------------------------------------------------------------------- 1 | # Deployment 2 | 3 | Currently supported installation methods of the NRI plugins are Helm and Operator. 4 | 5 | ```{toctree} 6 | --- 7 | maxdepth: 2 8 | caption: Contents 9 | --- 10 | helm/index.md 11 | operator/index.md 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/deployment/operator/index.md: -------------------------------------------------------------------------------- 1 | # Operator 2 | 3 | ```{toctree} 4 | --- 5 | maxdepth: 2 6 | caption: Contents 7 | --- 8 | operator.md 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/deployment/operator/operator.md: -------------------------------------------------------------------------------- 1 | ```{include} ../../../deployment/operator/README.md 2 | ``` -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Welcome to NRI Plugins documentation 2 | 3 | ```{toctree} 4 | --- 5 | maxdepth: 2 6 | caption: Contents 7 | --- 8 | introduction.md 9 | resource-policy/index.rst 10 | memory/index.md 11 | deployment/index.md 12 | contributing.md 13 | Project GitHub repository 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The NRI plugins is a collection of NRI (Node Resource Interface) based plugins 4 | to manage various aspects of pod and container life cycle. For example the 5 | [resource policy plugins](resource-policy/policy/index.md) can be used to 6 | modify the container resource allocation depending on available system 7 | resources. 8 | -------------------------------------------------------------------------------- /docs/memory/index.md: -------------------------------------------------------------------------------- 1 | # Memory plugins 2 | 3 | ```{toctree} 4 | --- 5 | maxdepth: 2 6 | caption: Contents 7 | --- 8 | memory-qos.md 9 | memtierd.md 10 | sgx-epc.md 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/memory/sgx-epc.md: -------------------------------------------------------------------------------- 1 | # SGX EPC Limit Plugin 2 | 3 | The sgx-epc NRI plugin allows control over SGX encrypted page cache usage 4 | using the cgroup v2 misc controller and pod annotations. 5 | 6 | ## Annotations 7 | 8 | You can annotate encrypted page cache limit for every container in the pod, 9 | or just a specific container using the following annotation notations: 10 | 11 | ```yaml 12 | ... 13 | metadata: 14 | annotations: 15 | # for all containers in the pod 16 | epc-limit.nri.io/pod: "32768" 17 | # alternative notation for all containers in the pod 18 | epc-limit.nri.io: "8192" 19 | # for container c0 in the pod 20 | epc-limit.nri.io/container.c0: "16384" 21 | ... 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/releases/index.md: -------------------------------------------------------------------------------- 1 | # Releases 2 | 3 | For up-to-date user documentation see the [documentation site](/nri-plugins/resource-policy) 4 | 5 | ## Documentation for Released Versions 6 |
7 |
8 | 9 | 22 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx==7.4.7 2 | sphinx_rtd_theme==2.0.0 3 | myst-parser==4.0.0 4 | sphinx-markdown-tables==0.0.17 5 | Pygments==2.17.0 6 | -------------------------------------------------------------------------------- /docs/resource-policy/configuration.md: -------------------------------------------------------------------------------- 1 | # Dynamic Configuration 2 | 3 | NRI Resource Policy plugin can be configured dynamically using plugin-specific 4 | custom resources. 5 | 6 | The plugin daemon monitors two custom resources the node, a primary node-specific 7 | one and a secondary group-specific or default one, depending on whether the node 8 | belongs to a configuration group. The node-specific custom resource always takes 9 | precedence over the others. 10 | 11 | The names of these custom resources are 12 | 13 | 1. `node.$NODE_NAME`: primary, node-specific configuration 14 | 2. `group.$GROUP_NAME`: secondary group-specific node configuration 15 | 3. `default`: secondary: secondary default node configuration 16 | 17 | You can assign a node to a configuration group by setting the 18 | `config.nri/group` label on the node to the name of the configuration 19 | group. You can remove a node from its group by deleting the node group 20 | label. 21 | 22 | There are [sample configuration](tree:/sample-configs/) custom resources that 23 | contain contains a node-specific, a group-specific, and a default configuration. 24 | See [any available policy-specific documentation](policy/index.md) 25 | for more information on the policy configurations. 26 | -------------------------------------------------------------------------------- /docs/resource-policy/developers-guide/figures/nri-resource-policy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/docs/resource-policy/developers-guide/figures/nri-resource-policy.png -------------------------------------------------------------------------------- /docs/resource-policy/developers-guide/index.md: -------------------------------------------------------------------------------- 1 | # Developer's Guide 2 | 3 | ```{toctree} 4 | --- 5 | maxdepth: 1 6 | --- 7 | architecture.md 8 | testing.rst 9 | cpu-allocator.md 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/resource-policy/developers-guide/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | ```{toctree} 4 | --- 5 | maxdepth: 1 6 | --- 7 | unit-test.md 8 | e2e-test.md 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/resource-policy/developers-guide/unit-test.md: -------------------------------------------------------------------------------- 1 | # Unit tests 2 | 3 | Run unit tests with 4 | 5 | ```bash 6 | make test 7 | ``` 8 | 9 | -------------------------------------------------------------------------------- /docs/resource-policy/index.md: -------------------------------------------------------------------------------- 1 | # Resource Policy Plugins 2 | 3 | ```{toctree} 4 | --- 5 | maxdepth: 2 6 | caption: Contents 7 | --- 8 | introduction.md 9 | setup.md 10 | configuration.md 11 | policy/index.md 12 | developers-guide/index.rst 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/resource-policy/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | NRI Resource Policy is a NRI container runtime plugin. It is connected 4 | to Container Runtime implementation (containerd, cri-o) via NRI API. 5 | The main purpose of the the NRI resource plugin is to apply hardware-aware 6 | resource allocation policies to the containers running in the system. 7 | 8 | There are different policies available, each with a different set of 9 | goals in mind and implementing different hardware allocation strategies. The 10 | details of whether and how a container resource request is altered or 11 | if extra actions are performed depend on which policy plugin is running 12 | and how that policy is configured. 13 | -------------------------------------------------------------------------------- /docs/resource-policy/policy/index.md: -------------------------------------------------------------------------------- 1 | # Policies 2 | 3 | Currently there are two real resource policies implemented: 4 | 5 | The Topology Aware resource policy provides a nearly zero configuration 6 | resource policy that allocates resources evenly in order to avoid the "noisy 7 | neighbor" problem. 8 | 9 | The Balloons resource policy allows user to allocate workloads to resources in 10 | a more user controlled way. 11 | 12 | Additionally there is a wire-frame Template resource policy implementation 13 | without any real resource assignment logic. It can be used as a template to 14 | implement new policies from scratch. 15 | 16 | Also, there is some common functionality offered by the shared generic resource 17 | management code used in these policies. This functionality is available in all 18 | policies. 19 | 20 | 21 | ```{toctree} 22 | --- 23 | maxdepth: 1 24 | --- 25 | topology-aware.md 26 | balloons.md 27 | template.md 28 | common-functionality.md 29 | ``` 30 | -------------------------------------------------------------------------------- /docs/resource-policy/policy/template.md: -------------------------------------------------------------------------------- 1 | # Template Policy 2 | 3 | The template policy is a wireframe implementation without any real resource 4 | allocation and assignment logic. It serves as a template and can be used as 5 | a starting point for creating new policies. 6 | 7 | -------------------------------------------------------------------------------- /pkg/agent/watch/watch.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package watch 16 | 17 | import ( 18 | "k8s.io/apimachinery/pkg/watch" 19 | 20 | logger "github.com/containers/nri-plugins/pkg/log" 21 | ) 22 | 23 | type ( 24 | EventType = watch.EventType 25 | Event = watch.Event 26 | Interface = watch.Interface 27 | ) 28 | 29 | const ( 30 | Added = watch.Added 31 | Modified = watch.Modified 32 | Deleted = watch.Deleted 33 | Bookmark = watch.Bookmark 34 | Error = watch.Error 35 | ) 36 | 37 | var ( 38 | log = logger.Get("agent") 39 | ) 40 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/agent.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v1alpha1 16 | 17 | // AgentConfig provides access to configuration data for the agent. 18 | type AgentConfig struct { 19 | // NodeResourceTopology enables support for exporting resource usage using 20 | // NodeResourceTopology Custom Resources. 21 | // +optional 22 | NodeResourceTopology bool `json:"nodeResourceTopology,omitempty"` 23 | // PodResourceAPI enables support for querying kubelet Pod Resource API. 24 | // +optional 25 | PodResourceAPI bool `json:"podResourceAPI,omitempty"` 26 | } 27 | 28 | // GetAgentConfig returns the agent-specific configuration if we have one. 29 | func GetAgentConfig(cfg interface{}) *AgentConfig { 30 | if ac, ok := cfg.(interface{ AgentConfig() *AgentConfig }); ok { 31 | return ac.AgentConfig() 32 | } 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/groupversion_info.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v1alpha1 is the v1alpha1 version of our config API. 16 | // +kubebuilder:object:generate=true 17 | // +groupName=config.nri 18 | 19 | package v1alpha1 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | "sigs.k8s.io/controller-runtime/pkg/scheme" 24 | ) 25 | 26 | var ( 27 | // SchemeGroupVersion is the group version used to register these objects 28 | SchemeGroupVersion = schema.GroupVersion{Group: "config.nri", Version: "v1alpha1"} 29 | 30 | // SchemeBuilder is the scheme builder for this API. 31 | SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} 32 | 33 | // AddToScheme adds the types in this group-version to the given scheme. 34 | AddToScheme = SchemeBuilder.AddToScheme 35 | ) 36 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/instrumentation/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Copyright The NRI Plugins Authors. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by controller-gen. DO NOT EDIT. 18 | 19 | package instrumentation 20 | 21 | import ( 22 | "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/metrics" 23 | ) 24 | 25 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 26 | func (in *Config) DeepCopyInto(out *Config) { 27 | *out = *in 28 | out.ReportPeriod = in.ReportPeriod 29 | if in.Metrics != nil { 30 | in, out := &in.Metrics, &out.Metrics 31 | *out = new(metrics.Config) 32 | (*in).DeepCopyInto(*out) 33 | } 34 | } 35 | 36 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. 37 | func (in *Config) DeepCopy() *Config { 38 | if in == nil { 39 | return nil 40 | } 41 | out := new(Config) 42 | in.DeepCopyInto(out) 43 | return out 44 | } 45 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/log/config.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package log 16 | 17 | import ( 18 | "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/log/klogcontrol" 19 | ) 20 | 21 | // +kubebuilder:object:generate=true 22 | type Config struct { 23 | // Debub turns on debug messages matching listed logger sources. 24 | // +optional 25 | Debug []string `json:"debug,omitempty"` 26 | // Source controls whether messages are prefixed with their logger source. 27 | // +optional 28 | LogSource bool `json:"source,omitempty"` 29 | // Klog configures the klog backend. 30 | // +optional 31 | Klog klogcontrol.Config `json:"klog,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/log/klogcontrol/doc.go: -------------------------------------------------------------------------------- 1 | package klogcontrol 2 | 3 | //go:generate go run gen-config.go klogcontrol Config config.go 4 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/log/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Copyright The NRI Plugins Authors. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by controller-gen. DO NOT EDIT. 18 | 19 | package log 20 | 21 | import () 22 | 23 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 24 | func (in *Config) DeepCopyInto(out *Config) { 25 | *out = *in 26 | if in.Debug != nil { 27 | in, out := &in.Debug, &out.Debug 28 | *out = make([]string, len(*in)) 29 | copy(*out, *in) 30 | } 31 | in.Klog.DeepCopyInto(&out.Klog) 32 | } 33 | 34 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. 35 | func (in *Config) DeepCopy() *Config { 36 | if in == nil { 37 | return nil 38 | } 39 | out := new(Config) 40 | in.DeepCopyInto(out) 41 | return out 42 | } 43 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/metrics/config.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package metrics 16 | 17 | // Config provides runtime configuration for metrics collection. 18 | // +kubebuilder:object:generate=true 19 | type Config struct { 20 | // Enabled enables collection for metrics matched by glob patterns. 21 | // +optional 22 | // +kubebuilder:example={"*"} 23 | Enabled []string `json:"enabled,omitempty"` 24 | // Polled forces polled collection for metrics matched by glob patterns. 25 | // +optional 26 | // +kubebuilder:example={"computationally-expensive-metrics"} 27 | Polled []string `json:"polled,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/metrics/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Copyright The NRI Plugins Authors. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by controller-gen. DO NOT EDIT. 18 | 19 | package metrics 20 | 21 | import () 22 | 23 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 24 | func (in *Config) DeepCopyInto(out *Config) { 25 | *out = *in 26 | if in.Enabled != nil { 27 | in, out := &in.Enabled, &out.Enabled 28 | *out = make([]string, len(*in)) 29 | copy(*out, *in) 30 | } 31 | if in.Polled != nil { 32 | in, out := &in.Polled, &out.Polled 33 | *out = make([]string, len(*in)) 34 | copy(*out, *in) 35 | } 36 | } 37 | 38 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. 39 | func (in *Config) DeepCopy() *Config { 40 | if in == nil { 41 | return nil 42 | } 43 | out := new(Config) 44 | in.DeepCopyInto(out) 45 | return out 46 | } 47 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/resmgr/control/blockio/config.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package blockio 16 | 17 | // Config provides runtime configuration for class based block I/O 18 | // prioritization and throttling. 19 | // +kubebuilder:object:generate=true 20 | type Config struct { 21 | // Enable class based block I/O prioritization and throttling. When 22 | // enabled, policy implementations can adjust block I/O priority by 23 | // assigning containers to block I/O priority classes. Additionally 24 | // you need to set up your cluster nodes' runtimes with the desired 25 | // block I/O class configuration. 26 | // +optional 27 | Enable bool `json:"enable,omitempty"` 28 | // usePodQoSAsDefaultClass controls whether a container's Pod QoS 29 | // class is used as its block I/O class, if this is otherwise unset. 30 | // +optional 31 | UsePodQoSAsDefaultClass bool `json:"usePodQoSAsDefaultClass,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/resmgr/control/blockio/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Copyright The NRI Plugins Authors. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by controller-gen. DO NOT EDIT. 18 | 19 | package blockio 20 | 21 | import () 22 | 23 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 24 | func (in *Config) DeepCopyInto(out *Config) { 25 | *out = *in 26 | } 27 | 28 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. 29 | func (in *Config) DeepCopy() *Config { 30 | if in == nil { 31 | return nil 32 | } 33 | out := new(Config) 34 | in.DeepCopyInto(out) 35 | return out 36 | } 37 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/resmgr/control/config.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package control 16 | 17 | import ( 18 | "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/resmgr/control/blockio" 19 | "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/resmgr/control/cpu" 20 | "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/resmgr/control/rdt" 21 | ) 22 | 23 | // +kubebuilder:object:generate=true 24 | type Config struct { 25 | // +optional 26 | CPU cpu.Config `json:"cpu,omitempty"` 27 | // +optional 28 | RDT rdt.Config `json:"rdt,omitempty"` 29 | // +optional 30 | BlockIO blockio.Config `json:"blockio,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/resmgr/control/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Copyright The NRI Plugins Authors. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by controller-gen. DO NOT EDIT. 18 | 19 | package control 20 | 21 | import () 22 | 23 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 24 | func (in *Config) DeepCopyInto(out *Config) { 25 | *out = *in 26 | in.CPU.DeepCopyInto(&out.CPU) 27 | in.RDT.DeepCopyInto(&out.RDT) 28 | out.BlockIO = in.BlockIO 29 | } 30 | 31 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. 32 | func (in *Config) DeepCopy() *Config { 33 | if in == nil { 34 | return nil 35 | } 36 | out := new(Config) 37 | in.DeepCopyInto(out) 38 | return out 39 | } 40 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/resmgr/policy/template/config.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package template 16 | 17 | import ( 18 | policy "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/resmgr/policy" 19 | ) 20 | 21 | type ( 22 | Constraints = policy.Constraints 23 | Domain = policy.Domain 24 | Amount = policy.Amount 25 | AmountKind = policy.AmountKind 26 | ) 27 | 28 | const ( 29 | CPU = policy.CPU 30 | Memory = policy.Memory 31 | AmountAbsent = policy.AmountAbsent 32 | AmountQuantity = policy.AmountQuantity 33 | AmountCPUSet = policy.AmountCPUSet 34 | ) 35 | 36 | // +kubebuilder:object:generate=true 37 | // +optional 38 | type Config struct { 39 | AvailableResources Constraints `json:"availableResources,omitempty"` 40 | // +kubebuilder:validation:Required 41 | ReservedResources Constraints `json:"reservedResources"` 42 | } 43 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/template-policy.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v1alpha1 16 | 17 | import "github.com/intel/goresctrl/pkg/rdt" 18 | 19 | var ( 20 | _ ResmgrConfig = &TemplatePolicy{} 21 | ) 22 | 23 | func (c *TemplatePolicy) AgentConfig() *AgentConfig { 24 | if c == nil { 25 | return nil 26 | } 27 | 28 | a := c.Spec.Agent 29 | 30 | return &a 31 | } 32 | 33 | func (c *TemplatePolicy) CommonConfig() *CommonConfig { 34 | if c == nil { 35 | return nil 36 | } 37 | return &CommonConfig{ 38 | Control: c.Spec.Control, 39 | Log: c.Spec.Log, 40 | Instrumentation: c.Spec.Instrumentation, 41 | } 42 | } 43 | 44 | func (c *TemplatePolicy) PolicyConfig() interface{} { 45 | if c == nil { 46 | return nil 47 | } 48 | return &c.Spec.Config 49 | } 50 | 51 | func (c *TemplatePolicy) RdtConfig() (*rdt.Config, bool, error) { 52 | return nil, false, nil 53 | } 54 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/topology-aware-policy.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v1alpha1 16 | 17 | var ( 18 | _ ResmgrConfig = &TopologyAwarePolicy{} 19 | ) 20 | 21 | func (c *TopologyAwarePolicy) AgentConfig() *AgentConfig { 22 | if c == nil { 23 | return nil 24 | } 25 | 26 | a := c.Spec.Agent 27 | 28 | return &a 29 | } 30 | 31 | func (c *TopologyAwarePolicy) CommonConfig() *CommonConfig { 32 | if c == nil { 33 | return nil 34 | } 35 | return &CommonConfig{ 36 | Control: c.Spec.Control, 37 | Log: c.Spec.Log, 38 | Instrumentation: c.Spec.Instrumentation, 39 | } 40 | } 41 | 42 | func (c *TopologyAwarePolicy) PolicyConfig() interface{} { 43 | if c == nil { 44 | return nil 45 | } 46 | return &c.Spec.Config 47 | } 48 | 49 | func (c *TopologyAwarePolicy) Validate() error { 50 | if c == nil { 51 | return nil 52 | } 53 | 54 | if err := c.CommonConfig().Validate(); err != nil { 55 | return err 56 | } 57 | 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha1/validator.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v1alpha1 16 | 17 | // Validator is an optional interface that top level configuration types 18 | // can implement to provide extra custom validation of configuration data. 19 | // +kubebuilder:object:generate=false 20 | type Validator interface { 21 | Validate() error 22 | } 23 | -------------------------------------------------------------------------------- /pkg/apis/resmgr/v1alpha1/evaluable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019-2020 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package resmgr 16 | 17 | // Evaluable is the interface objects need to implement to be evaluable against Expressions. 18 | type Evaluable interface { 19 | // EvalKey returns the value of a simple/single key. 20 | EvalKey(string) interface{} 21 | // EvalRef returns the value of a (potentially joint) key (reference). 22 | EvalRef(string) (string, bool) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/apis/resmgr/v1alpha1/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Copyright The NRI Plugins Authors. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by controller-gen. DO NOT EDIT. 18 | 19 | package resmgr 20 | 21 | import () 22 | 23 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 24 | func (in *Expression) DeepCopyInto(out *Expression) { 25 | *out = *in 26 | if in.Values != nil { 27 | in, out := &in.Values, &out.Values 28 | *out = make([]string, len(*in)) 29 | copy(*out, *in) 30 | } 31 | } 32 | 33 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Expression. 34 | func (in *Expression) DeepCopy() *Expression { 35 | if in == nil { 36 | return nil 37 | } 38 | out := new(Expression) 39 | in.DeepCopyInto(out) 40 | return out 41 | } 42 | -------------------------------------------------------------------------------- /pkg/cgroups/cgroupid.go: -------------------------------------------------------------------------------- 1 | package cgroups 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "sync" 8 | ) 9 | 10 | // CgroupID implements mapping kernel cgroup IDs to cgroupfs paths with transparent caching. 11 | type CgroupID struct { 12 | root string 13 | cache map[uint64]string 14 | sync.Mutex 15 | } 16 | 17 | // NewCgroupID creates a new CgroupID map/cache. 18 | func NewCgroupID(root string) *CgroupID { 19 | return &CgroupID{ 20 | root: root, 21 | cache: make(map[uint64]string), 22 | } 23 | } 24 | 25 | // Find finds the path for the given cgroup id. 26 | func (cgid *CgroupID) Find(id uint64) (string, error) { 27 | found := false 28 | var p string 29 | 30 | cgid.Lock() 31 | defer cgid.Unlock() 32 | 33 | if path, ok := cgid.cache[id]; ok { 34 | return path, nil 35 | } 36 | 37 | err := filepath.Walk(cgid.root, func(path string, info os.FileInfo, err error) error { 38 | if err != nil { 39 | if os.IsNotExist(err) { 40 | return nil 41 | } 42 | fmt.Printf("WalkFunc called with an error (path %q: %v\n)", path, err) 43 | return err 44 | } 45 | 46 | if found { 47 | return filepath.SkipDir 48 | } 49 | 50 | if info.IsDir() && id == getID(path) { 51 | found = true 52 | p = path 53 | return filepath.SkipDir 54 | } 55 | return nil 56 | }) 57 | 58 | if err != nil { 59 | return "", err 60 | } else if !found { 61 | return "", fmt.Errorf("cgroupid %v not found", id) 62 | } else { 63 | cgid.cache[id] = p 64 | return p, nil 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pkg/cgroups/cgroupid_linux.go: -------------------------------------------------------------------------------- 1 | package cgroups 2 | 3 | import ( 4 | "encoding/binary" 5 | 6 | "golang.org/x/sys/unix" 7 | ) 8 | 9 | func getID(path string) uint64 { 10 | h, _, err := unix.NameToHandleAt(unix.AT_FDCWD, path, 0) 11 | if err != nil { 12 | return 0 13 | } 14 | 15 | return binary.LittleEndian.Uint64(h.Bytes()) 16 | } 17 | -------------------------------------------------------------------------------- /pkg/cgroups/cgroupid_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | // +build !linux 3 | 4 | package cgroups 5 | 6 | func getID(path string) uint64 { 7 | panic("not implemented") 8 | } 9 | -------------------------------------------------------------------------------- /pkg/cpuallocator/testdata/sysfs.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/pkg/cpuallocator/testdata/sysfs.tar.bz2 -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by client-gen. DO NOT EDIT. 16 | 17 | // This package has the automatically generated fake clientset. 18 | package fake 19 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by client-gen. DO NOT EDIT. 16 | 17 | // This package contains the scheme of the automatically generated clientset. 18 | package scheme 19 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/config/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by client-gen. DO NOT EDIT. 16 | 17 | // This package has the automatically generated typed clients. 18 | package v1alpha1 19 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by client-gen. DO NOT EDIT. 16 | 17 | // Package fake has the automatically generated clients. 18 | package fake 19 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/config/v1alpha1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Code generated by client-gen. DO NOT EDIT. 16 | 17 | package v1alpha1 18 | 19 | type BalloonsPolicyExpansion interface{} 20 | 21 | type TemplatePolicyExpansion interface{} 22 | 23 | type TopologyAwarePolicyExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/kubernetes/kubernetes.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubernetes 18 | 19 | const ( 20 | // ResmgrKeyNamespace is a NRI Resource Policy namespace 21 | ResmgrKeyNamespace = "resource-policy.nri.io" 22 | 23 | // NamespaceSystem is the kubernetes system namespace. 24 | NamespaceSystem = "kube-system" 25 | // PodNameLabel is the key for the kubernetes pod name label. 26 | PodNameLabel = "io.kubernetes.pod.name" 27 | // ContainerNameLabel is the key for the kubernetes container name label. 28 | ContainerNameLabel = "io.kubernetes.container.name" 29 | ) 30 | 31 | // ResmgrKey returns a full namespaced name of a resource manager specific key 32 | func ResmgrKey(name string) string { 33 | return ResmgrKeyNamespace + "/" + name 34 | } 35 | -------------------------------------------------------------------------------- /pkg/kubernetes/resources_test.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package kubernetes_test 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | 22 | . "github.com/containers/nri-plugins/pkg/kubernetes" 23 | ) 24 | 25 | func TestCalculateOomAdjToMemReqEstimates(t *testing.T) { 26 | const ( 27 | K int64 = 1024 28 | M int64 = 1024 * K 29 | G int64 = 1024 * M 30 | ) 31 | 32 | for capacity := int64(4 * G); capacity <= (1024+512)*G; capacity += 4 * G { 33 | SetMemoryCapacity(capacity) 34 | for adj := int64(MinBurstableOOMScoreAdj); adj <= MaxBurstableOOMScoreAdj; adj++ { 35 | req := OomAdjToMemReq(adj, capacity) 36 | require.NotNil(t, req, 37 | "capacity %d, adj %d: OomAdjToMemReq() returned nil", capacity, adj) 38 | 39 | chk := MemReqToOomAdj(*req) 40 | require.Equal(t, adj, chk, 41 | "capacity %d, adj %d: req=%d, chk=%d != adj\n", capacity, adj, *req, chk) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /pkg/log/stdlog-logger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019-2020 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package log 16 | 17 | import ( 18 | stdlog "log" 19 | ) 20 | 21 | // stdlogger implements an io.Writer to redirect logging by the stock log package. 22 | type stdlogger struct { 23 | l Logger 24 | } 25 | 26 | // SetStdLogger sets up a logger for the standard log package. 27 | func SetStdLogger(source string) { 28 | var l Logger 29 | 30 | if source == "" { 31 | l = Default() 32 | } else { 33 | l = log.get(source) 34 | } 35 | 36 | stdlog.SetPrefix("") 37 | stdlog.SetFlags(0) 38 | stdlog.SetOutput(&stdlogger{l: l}) 39 | } 40 | 41 | // Write implements io.Writer for stdlogger. 42 | func (s *stdlogger) Write(p []byte) (int, error) { 43 | s.l.Debug("%s", string(p)) 44 | return len(p), nil 45 | } 46 | -------------------------------------------------------------------------------- /pkg/resmgr/cache/cache_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cache_test 16 | 17 | import ( 18 | "fmt" 19 | "sync" 20 | "testing" 21 | 22 | . "github.com/onsi/ginkgo/v2" 23 | . "github.com/onsi/gomega" 24 | ) 25 | 26 | func TestCache(t *testing.T) { 27 | RegisterFailHandler(Fail) 28 | RunSpecs(t, "Cache Suite") 29 | } 30 | 31 | var ( 32 | podID = &IdGen{ 33 | base: "pod", 34 | } 35 | ctrID = &IdGen{ 36 | base: "ctr", 37 | } 38 | ) 39 | 40 | type IdGen struct { 41 | sync.Mutex 42 | base string 43 | nextID int 44 | } 45 | 46 | func (g *IdGen) Generate() string { 47 | g.Lock() 48 | defer g.Unlock() 49 | g.nextID++ 50 | id := fmt.Sprintf("%s-#%d", g.base, g.nextID) 51 | return id 52 | } 53 | -------------------------------------------------------------------------------- /pkg/resmgr/cache/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cache 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | func cacheError(format string, args ...interface{}) error { 22 | return fmt.Errorf("cache: "+format, args...) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/resmgr/cache/test-cleanup.sh: -------------------------------------------------------------------------------- 1 | rm -fr testdata 2 | -------------------------------------------------------------------------------- /pkg/resmgr/cache/test-data.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/pkg/resmgr/cache/test-data.tar.gz -------------------------------------------------------------------------------- /pkg/resmgr/cache/test-setup.sh: -------------------------------------------------------------------------------- 1 | tar -xvzf test-data.tar.gz 2 | -------------------------------------------------------------------------------- /pkg/resmgr/controllers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package resmgr 16 | 17 | import ( 18 | // List of controllers to pull in. 19 | _ "github.com/containers/nri-plugins/pkg/resmgr/control/cpu" 20 | _ "github.com/containers/nri-plugins/pkg/resmgr/control/e2e-test" 21 | ) 22 | -------------------------------------------------------------------------------- /pkg/resmgr/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package resmgr 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | // resmgrError creates a resource manager-specific formatted error. 22 | func resmgrError(format string, args ...interface{}) error { 23 | return fmt.Errorf("resource-manager: "+format, args...) 24 | } 25 | -------------------------------------------------------------------------------- /pkg/resmgr/events/events.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019-2020 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package events 16 | 17 | // Metrics is a set of metrics-related events we might need to act upon. 18 | type Metrics struct { 19 | } 20 | 21 | // Policy is a policy-specific event to be handled by the active policy. 22 | type Policy struct { 23 | // Event is the policy-specific type of this event. 24 | Type string 25 | // Source describes where this event is originated from. 26 | Source string 27 | // Data is any optional arbitrary data associated with this event. 28 | Data interface{} 29 | } 30 | 31 | const ( 32 | // ContainerStarted is delivered to policies when a StartContainer request succeeds. 33 | ContainerStarted = "container-started" 34 | ) 35 | -------------------------------------------------------------------------------- /pkg/resmgr/lib/memory/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package libmem 16 | 17 | import "fmt" 18 | 19 | var ( 20 | ErrFailedOption = fmt.Errorf("libmem: failed to apply option") 21 | ErrInvalidType = fmt.Errorf("libmem: invalid type") 22 | ErrInvalidNode = fmt.Errorf("libmem: invalid node") 23 | ErrInvalidNodeMask = fmt.Errorf("libmem: invalid NodeMask") 24 | ErrInvalidQosClass = fmt.Errorf("libmem: invalid QoS class") 25 | ErrExpiredOffer = fmt.Errorf("libmem: expired offer") 26 | ErrUnknownRequest = fmt.Errorf("libmem: unknown allocation") 27 | ErrAlreadyExists = fmt.Errorf("libmem: allocation already exists") 28 | ErrNoMem = fmt.Errorf("libmem: insufficient available memory") 29 | ErrNoZone = fmt.Errorf("libmem: failed to find zone") 30 | ErrInternalError = fmt.Errorf("libmem: internal error") 31 | ) 32 | -------------------------------------------------------------------------------- /pkg/resmgr/lib/memory/helpers_test.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package libmem 16 | 17 | func (a *Allocator) Expand(nodes NodeMask, types TypeMask) (NodeMask, TypeMask) { 18 | return a.expand(nodes, types) 19 | } 20 | -------------------------------------------------------------------------------- /pkg/resmgr/lib/memory/test-cleanup.sh: -------------------------------------------------------------------------------- 1 | ../../../sysfs/test-cleanup.sh -------------------------------------------------------------------------------- /pkg/resmgr/lib/memory/test-data-sample1.tar.xz: -------------------------------------------------------------------------------- 1 | ../../../sysfs/test-data-sample1.tar.xz -------------------------------------------------------------------------------- /pkg/resmgr/lib/memory/test-data-sample2.tar.xz: -------------------------------------------------------------------------------- 1 | ../../../sysfs/test-data-sample2.tar.xz -------------------------------------------------------------------------------- /pkg/resmgr/lib/memory/test-setup.sh: -------------------------------------------------------------------------------- 1 | ../../../sysfs/test-setup.sh -------------------------------------------------------------------------------- /pkg/resmgr/policy/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package policy 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | func policyError(format string, args ...interface{}) error { 22 | return fmt.Errorf("policy: "+format, args...) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/sockets/sockets.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package sockets 16 | 17 | const ( 18 | // Containerd is the CRI socket containerd listens on. 19 | Containerd = "/var/run/containerd/containerd.sock" 20 | // DirPermissions is the permissions to create the directory for sockets with. 21 | DirPermissions = 0711 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/sysfs/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package sysfs 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | func sysfsError(path, format string, args ...interface{}) error { 22 | return fmt.Errorf(path+": "+format, args...) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/sysfs/sysfs_suite_test.go: -------------------------------------------------------------------------------- 1 | package sysfs_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestSysfs(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Sysfs Suite") 13 | } 14 | -------------------------------------------------------------------------------- /pkg/sysfs/test-cleanup.sh: -------------------------------------------------------------------------------- 1 | rm -fr testdata 2 | -------------------------------------------------------------------------------- /pkg/sysfs/test-data-sample1.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/pkg/sysfs/test-data-sample1.tar.xz -------------------------------------------------------------------------------- /pkg/sysfs/test-data-sample2.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/pkg/sysfs/test-data-sample2.tar.xz -------------------------------------------------------------------------------- /pkg/sysfs/test-setup.sh: -------------------------------------------------------------------------------- 1 | mkdir -p testdata 2 | tar -C testdata -xvJf test-data-sample1.tar.xz 3 | tar -C testdata -xvJf test-data-sample2.tar.xz 4 | -------------------------------------------------------------------------------- /pkg/testutils/verify.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "reflect" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | // VerifyDeepEqual checks that two values (including structures) are equal, or else it fails the test. 10 | func VerifyDeepEqual(t *testing.T, valueName string, expectedValue interface{}, seenValue interface{}) bool { 11 | if reflect.DeepEqual(expectedValue, seenValue) { 12 | return true 13 | } 14 | t.Errorf("expected %s value %+v, got %+v", valueName, expectedValue, seenValue) 15 | return false 16 | } 17 | 18 | // VerifyError checks a (multi)error has expected properties, or else it fails the test. 19 | func VerifyError(t *testing.T, err error, expectedCount int, expectedSubstrings []string) bool { 20 | if expectedCount > 0 { 21 | if err == nil { 22 | t.Errorf("error expected, got nil") 23 | return false 24 | } 25 | if merr, ok := err.(interface{ Unwrap() []error }); !ok { 26 | t.Errorf("expected %d errors, but got %#v instead of multierror", expectedCount, err) 27 | return false 28 | } else if errs := merr.Unwrap(); len(errs) != expectedCount { 29 | t.Errorf("expected %d errors, but got %d: %v", expectedCount, len(errs), merr) 30 | return false 31 | } 32 | } else if expectedCount == 0 { 33 | if err != nil { 34 | t.Errorf("expected 0 errors, but got %v", err) 35 | return false 36 | } 37 | } 38 | for _, substring := range expectedSubstrings { 39 | if !strings.Contains(err.Error(), substring) { 40 | t.Errorf("expected error with substring %#v, got \"%v\"", substring, err) 41 | } 42 | } 43 | return true 44 | } 45 | -------------------------------------------------------------------------------- /pkg/topology/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/containers/nri-plugins/pkg/topology 2 | 3 | go 1.20 4 | 5 | require golang.org/x/sys v0.18.0 6 | -------------------------------------------------------------------------------- /pkg/topology/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= 2 | golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 3 | -------------------------------------------------------------------------------- /pkg/topology/test-cleanup.sh: -------------------------------------------------------------------------------- 1 | rm -fr testdata 2 | -------------------------------------------------------------------------------- /pkg/topology/test-data.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/containers/nri-plugins/00c774b94b03ed4a5a005d0441d53b625db35790/pkg/topology/test-data.tar.gz -------------------------------------------------------------------------------- /pkg/topology/test-setup.sh: -------------------------------------------------------------------------------- 1 | tar -xvzf test-data.tar.gz 2 | -------------------------------------------------------------------------------- /pkg/topology/topology_linux.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "syscall" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // FindSysFsDevice for given argument returns physical device where it is linked to. 12 | // For device nodes it will return path for device itself. For regular files or directories 13 | // this function returns physical device where this inode resides (storage device). 14 | // If result device is a virtual one (e.g. tmpfs), error will be returned. 15 | // For non-existing path, no error returned and path is empty. 16 | func FindSysFsDevice(dev string) (string, error) { 17 | fi, err := os.Stat(dev) 18 | if err != nil { 19 | if os.IsNotExist(err) { 20 | return "", nil 21 | } 22 | return "", fmt.Errorf("unable to get stat for %s: %w", dev, err) 23 | } 24 | 25 | devType := "block" 26 | rdev := fi.Sys().(*syscall.Stat_t).Dev 27 | if mode := fi.Mode(); mode&os.ModeDevice != 0 { 28 | rdev = fi.Sys().(*syscall.Stat_t).Rdev 29 | if mode&os.ModeCharDevice != 0 { 30 | devType = "char" 31 | } 32 | } 33 | 34 | major := int64(unix.Major(rdev)) 35 | minor := int64(unix.Minor(rdev)) 36 | if major == 0 { 37 | return "", fmt.Errorf("%s is a virtual device node: %w", dev, err) 38 | } 39 | 40 | realDevPath, err := findSysFsDevice(devType, major, minor) 41 | if err != nil { 42 | return "", fmt.Errorf("failed to find sysfs device for %s: %w", dev, err) 43 | } 44 | 45 | return realDevPath, nil 46 | } 47 | -------------------------------------------------------------------------------- /pkg/topology/topology_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | // +build !linux 3 | 4 | package topology 5 | 6 | import "errors" 7 | 8 | // FindSysFsDevice for given argument returns physical device where it is linked to. 9 | // For device nodes it will return path for device itself. For regular files or directories 10 | // this function returns physical device where this inode resides (storage device). 11 | // If result device is a virtual one (e.g. tmpfs), error will be returned. 12 | // For non-existing path, no error returned and path is empty. 13 | func FindSysFsDevice(dev string) (string, error) { 14 | return "", errors.New("not implemented") 15 | } 16 | -------------------------------------------------------------------------------- /pkg/utils/cpuset/cpuset.go: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cpuset 16 | 17 | import ( 18 | "fmt" 19 | 20 | "k8s.io/utils/cpuset" 21 | ) 22 | 23 | // CPUSet is an alias for k8s.io/utils/cpuset.CPUSet. 24 | type CPUSet = cpuset.CPUSet 25 | 26 | var ( 27 | // New is an alias for cpuset.New. 28 | New = cpuset.New 29 | // Parse is an alias for cpuset.Parse. 30 | Parse = cpuset.Parse 31 | ) 32 | 33 | // MustParse panics if parsing the given cpuset string fails. 34 | func MustParse(s string) cpuset.CPUSet { 35 | cset, err := cpuset.Parse(s) 36 | if err != nil { 37 | panic(fmt.Errorf("failed to parse CPUSet %s: %w", s, err)) 38 | } 39 | return cset 40 | } 41 | -------------------------------------------------------------------------------- /pkg/utils/json.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "fmt" 21 | 22 | "sigs.k8s.io/yaml" 23 | ) 24 | 25 | // DumpJSON dumps a json-compatible struct in human-readable form 26 | func DumpJSON(r interface{}) string { 27 | out, err := yaml.Marshal(r) 28 | if err != nil { 29 | return fmt.Sprintf("!!!!!\nUnable to stringify %T: %v\n!!!!!", r, err) 30 | } 31 | return string(out) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/utils/net.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package utils 16 | 17 | import ( 18 | "errors" 19 | "net" 20 | "os" 21 | "syscall" 22 | ) 23 | 24 | // IsListeningSocket returns true if connections are accepted on the socket. 25 | func IsListeningSocket(socket string) (bool, error) { 26 | conn, err := net.Dial("unix", socket) 27 | if err == nil { 28 | conn.Close() // nolint:errcheck 29 | return true, nil 30 | } 31 | 32 | if errors.Is(err, syscall.ECONNREFUSED) || os.IsNotExist(err) { 33 | return false, nil 34 | } 35 | 36 | return false, err 37 | } 38 | -------------------------------------------------------------------------------- /pkg/utils/parse.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package utils 16 | 17 | import ( 18 | "fmt" 19 | "strings" 20 | ) 21 | 22 | // ParseEnabled returns whether the given string represents an 'enabled' state. 23 | func ParseEnabled(value string) (bool, error) { 24 | switch strings.ToLower(value) { 25 | case "true", "on", "enable", "enabled", "1": 26 | return true, nil 27 | case "false", "off", "disable", "disabled", "0": 28 | return false, nil 29 | default: 30 | return false, fmt.Errorf("ParseEnabled: invalid string %q", value) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pkg/utils/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package utils 16 | 17 | import ( 18 | "sort" 19 | ) 20 | 21 | // SortUint64s sorts a slice of uint64 in increasing order. 22 | func SortUint64s(a []uint64) { 23 | sort.Sort(Uint64Slice(a)) 24 | } 25 | 26 | // Uint64Slice implmenents sort.Interface for a slice of uint64. 27 | type Uint64Slice []uint64 28 | 29 | // Len returns the length of an UintSlice 30 | func (s Uint64Slice) Len() int { return len(s) } 31 | 32 | // Less returns true if element at 'i' is less than the element at 'j' 33 | func (s Uint64Slice) Less(i, j int) bool { return s[i] < s[j] } 34 | 35 | // Swap swaps the values of two elements 36 | func (s Uint64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 37 | -------------------------------------------------------------------------------- /sample-configs/nri-memory-policy.yaml: -------------------------------------------------------------------------------- 1 | classes: 2 | - name: interleave-all 3 | policy: 4 | mode: MPOL_INTERLEAVE 5 | nodes: allowed-mems 6 | - name: interleave-cpu-packages 7 | policy: 8 | mode: MPOL_INTERLEAVE 9 | nodes: cpu-packages 10 | - name: interleave-cpu-nodes 11 | policy: 12 | mode: MPOL_INTERLEAVE 13 | nodes: cpu-nodes 14 | - name: interleave-local-nodes 15 | policy: 16 | mode: MPOL_INTERLEAVE 17 | nodes: max-dist:19 18 | -------------------------------------------------------------------------------- /sample-configs/nri-memory-qos.yaml: -------------------------------------------------------------------------------- 1 | classes: 2 | - name: bronze 3 | swaplimitratio: 0.5 4 | - name: silver 5 | swaplimitratio: 0.2 6 | unifiedannotations: 7 | - memory.swap.max 8 | - memory.high 9 | -------------------------------------------------------------------------------- /sample-configs/nri-memtierd.yaml: -------------------------------------------------------------------------------- 1 | classes: 2 | - name: swap-idle-data 3 | allowswap: true 4 | memtierdconfig: | 5 | policy: 6 | name: age 7 | config: | 8 | intervalms: 10000 9 | pidwatcher: 10 | name: cgroups 11 | config: | 12 | cgroups: 13 | - $CGROUP2_ABS_PATH 14 | swapoutms: 10000 15 | tracker: 16 | name: idlepage 17 | config: | 18 | pagesinregion: 512 19 | maxcountperregion: 1 20 | scanintervalms: 10000 21 | mover: 22 | intervalms: 20 23 | bandwidth: 50 24 | - name: track-working-set-size 25 | allowswap: false 26 | memtierdconfig: | 27 | policy: 28 | name: age 29 | config: | 30 | intervalms: 20000 31 | pidwatcher: 32 | name: cgroups 33 | config: | 34 | cgroups: 35 | - $CGROUP2_ABS_PATH 36 | tracker: 37 | name: idlepage 38 | config: | 39 | pagesinregion: 512 40 | maxcountperregion: 1 41 | scanintervalms: 20000 42 | routines: 43 | - name: statactions 44 | config: | 45 | intervalms: 60000 46 | intervalcommand: ["policy", "-dump", "accessed", "0,1m,30m,2h,24h,0"] 47 | intervalcommandrunner: memtier 48 | -------------------------------------------------------------------------------- /scripts/build/extract-licenses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SUMMARY="licenses-summary.txt" 4 | CSVFILE="licenses.csv" 5 | ERRFILE="go-license-errors" 6 | IGNORED="--ignore github.com/containers/nri-plugins/pkg/topology" 7 | VERBOSE="" 8 | 9 | if [ "$#" != 2 ]; then 10 | echo "Usage: $0 " 11 | exit 1 12 | fi 13 | 14 | SRC="$1" 15 | OUT="$2" 16 | CSV="$OUT/$CSVFILE" 17 | ERR="$OUT.$ERRFILE" 18 | SUM="$OUT/$SUMMARY" 19 | 20 | echo "Extracting/checking licenses for $(basename $OUT)..." 21 | rm -fr $OUT && mkdir -p $(dirname $OUT) 22 | go-licenses check $IGNORED "$SRC" 2>"$ERR" && \ 23 | go-licenses save $IGNORED "$SRC" --save_path "$OUT" 2>"$ERR" && \ 24 | go-licenses report $IGNORED "$SRC" > "$CSV" 2>"$ERR" 25 | status="$?" 26 | 27 | echo "go-license warnings/errors:" 28 | cat "$ERR" | sed 's/^/ /g' 29 | if [ "$status" != "0" ]; then 30 | echo "License check FAILED, status $status" 31 | exit $status 32 | fi 33 | rm -f "$ERR" 34 | 35 | cat "$CSV" | sed 's/^.*,//g' | sort -u > "$SUM" 36 | -------------------------------------------------------------------------------- /scripts/build/helm-publisher.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | index_file="index.yaml" 5 | browser_download_url="$@" 6 | 7 | git checkout gh-pages 8 | 9 | # Verify if the release assets include Helm chart packages. If they do, 10 | # we can proceed with updating the index.yaml file, otherwise throw an error. 11 | charts_urls=$(echo "$browser_download_url" | grep '.*helm-chart-.*.tgz') 12 | 13 | # Check if Helm release assets were found 14 | if [ -n "$charts_urls" ]; then 15 | # Loop through the URLs 16 | for chart in $charts_urls; do 17 | # Check if the URL path exists in index.yaml 18 | # and if not, update the index.yaml accordingly 19 | if ! grep -q "$chart" "$index_file"; then 20 | wget "$chart" 21 | base_url=$(dirname "$chart") 22 | if ! helm repo index . --url "$base_url" --merge "$index_file"; then 23 | echo "Failed to update "$index_file" for: $base_url" 24 | fi 25 | rm *chart*.tgz 26 | fi 27 | done 28 | else 29 | echo "No Helm packages were found on this release" 30 | exit 1 31 | fi 32 | 33 | # Create a new commit 34 | release=$(basename "$base_url") 35 | commit_msg="Update Helm index for release $release" 36 | 37 | echo "Committing changes..." 38 | 39 | git config user.name "Github Actions" 40 | git config user.email "no-reply@github.com" 41 | git add index.yaml 42 | git commit -m "$commit_msg" 43 | 44 | echo "gh-pages branch successfully updated" 45 | -------------------------------------------------------------------------------- /scripts/docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | cd ..\.. 14 | 15 | if "%1" == "" goto help 16 | 17 | %SPHINXBUILD% >NUL 2>NUL 18 | if errorlevel 9009 ( 19 | echo. 20 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 21 | echo.installed, then set the SPHINXBUILD environment variable to point 22 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 23 | echo.may add the Sphinx directory to PATH. 24 | echo. 25 | echo.If you don't have Sphinx installed, grab it from 26 | echo.http://sphinx-doc.org/ 27 | exit /b 1 28 | ) 29 | 30 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 31 | goto end 32 | 33 | :help 34 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 35 | 36 | :end 37 | popd 38 | -------------------------------------------------------------------------------- /scripts/hack/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | // Copyright The NRI Plugins Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | -------------------------------------------------------------------------------- /scripts/hack/update_codegen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | trap cleanup EXIT 8 | GO_CMD="${1:-go}" 9 | BUILD_AUX="${2:-${REPO_ROOT}/build-aux}" 10 | REPO_ROOT="$(git rev-parse --show-toplevel)" 11 | CURRENT_DIR="$(dirname "${BASH_SOURCE[0]}")" 12 | TEMP_VENDOR_DIR="${BUILD_AUX}/vendor" 13 | 14 | function cleanup() { 15 | echo "Cleaning up temporary vendor directory..." 16 | rm -rf "${TEMP_VENDOR_DIR}" 17 | } 18 | 19 | pushd "$REPO_ROOT" > /dev/null 20 | "${GO_CMD}" mod vendor 21 | mv vendor "${TEMP_VENDOR_DIR}" 22 | 23 | CODEGEN_PKG=$(cd "${TEMP_VENDOR_DIR}"; "${GO_CMD}" list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator) 24 | popd > /dev/null 25 | 26 | # shellcheck source=/dev/null 27 | source "${CODEGEN_PKG}/kube_codegen.sh" 28 | 29 | cd "${REPO_ROOT}/pkg/apis" 30 | 31 | kube::codegen::gen_client \ 32 | --output-dir "${REPO_ROOT}/pkg/generated" \ 33 | --output-pkg github.com/containers/nri-plugins/pkg/generated \ 34 | --boilerplate "${REPO_ROOT}/scripts/hack/boilerplate.go.txt" \ 35 | "${REPO_ROOT}/pkg/apis" 36 | -------------------------------------------------------------------------------- /scripts/testing/jaeger: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ENVVARS="-e COLLECTOR_ZIPKIN_HTTP_PORT=9411" 4 | PORTS="-p 5775:5775/udp \ 5 | -p 6831:6831/udp \ 6 | -p 6832:6832/udp \ 7 | -p 5778:5778 \ 8 | -p 16686:16686 \ 9 | -p 14268:14268 \ 10 | -p 9411:9411" 11 | 12 | if [ "$1" = "--permanent" ]; then 13 | storage=/tmp/jaeger-trace 14 | data=$storage/data 15 | key=$storage/key 16 | echo "Using $data and $key to store (badger) traces..." 17 | mkdir -p $storage 18 | STORAGE="-e SPAN_STORAGE_TYPE=badger \ 19 | -e BADGER_EPHEMERAL=false \ 20 | -e BADGER_DIRECTORY_VALUE=$data \ 21 | -e BADGER_DIRECTORY_KEY=$key \ 22 | -v $storage:$storage" 23 | fi 24 | 25 | cmd="docker run $ENVVARS $PORTS $STORAGE jaegertracing/all-in-one:latest" 26 | echo "Running command $cmd..." 27 | $cmd 28 | -------------------------------------------------------------------------------- /scripts/testing/prometheus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dir=$(dirname "$0") 4 | cfg=$dir/prometheus.yaml 5 | 6 | cmd="docker run -p 9090:9090 \ 7 | -v $cfg:/etc/prometheus/prometheus.yml \ 8 | prom/prometheus --config.file=/etc/prometheus/prometheus.yml $*" 9 | 10 | echo "Running command $cmd..." 11 | $cmd 12 | -------------------------------------------------------------------------------- /scripts/testing/prometheus.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 10s 3 | external_labels: 4 | monitor: 'CRI-RM' 5 | 6 | scrape_configs: 7 | - job_name: 'CRI-RM' 8 | scrape_interval: 10s 9 | static_configs: 10 | - targets: ['10.0.0.2:8888'] 11 | -------------------------------------------------------------------------------- /test/e2e/files/10-bridge.conf.in: -------------------------------------------------------------------------------- 1 | { 2 | "cniVersion": "0.4.0", 3 | "name": "demonet", 4 | "type": "bridge", 5 | "isGateway": true, 6 | "ipMasq": true, 7 | "ipam": { 8 | "type": "host-local", 9 | "subnet": "CNI_NETWORK", 10 | "routes": [ 11 | { "dst": "0.0.0.0/0" } 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/e2e/files/Makefile.in: -------------------------------------------------------------------------------- 1 | ifneq ($(V),1) 2 | .SILENT: 3 | endif 4 | 5 | all: up 6 | 7 | install: .plugins.installed.stamp 8 | 9 | .plugins.installed.stamp: 10 | for plugin in dotenv vagrant-proxyconf vagrant-qemu; do \ 11 | vagrant plugin list | grep ^$$plugin || vagrant plugin install $$plugin || exit 1; \ 12 | done 13 | if [ ! -f "$@" ]; then \ 14 | touch "$@"; \ 15 | fi; 16 | 17 | provision: install 18 | vagrant up --provision --provider=qemu --no-parallel --no-destroy-on-error 19 | 20 | up: 21 | vagrant up 22 | 23 | down: 24 | vagrant halt 25 | 26 | ssh: 27 | if [ -f .ssh-config ]; then \ 28 | if ! ssh -F .ssh-config vagrant@node; then \ 29 | $(MAKE) up && ssh -F .ssh-config vagrant@node; \ 30 | fi \ 31 | else \ 32 | vagrant up && vagrant ssh; \ 33 | fi 34 | 35 | status: 36 | vagrant status 37 | 38 | destroy: up 39 | vagrant destroy --force --graceful --no-tty 40 | 41 | validate: up 42 | vagrant validate 43 | -------------------------------------------------------------------------------- /test/e2e/files/besteffort.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | labels: 6 | app: ${NAME} 7 | $(for lbl in ${!LABEL*}; do [[ "$lbl" == LABEL[0-9]* ]] && echo " 8 | ${!lbl} 9 | "; done) 10 | $([ -n "${!ANN*}" ] && echo " 11 | annotations: 12 | $(for ann in ${!ANN*}; do [[ "$ann" == ANN[0-9]* ]] && echo " 13 | ${!ann} 14 | "; done) 15 | ") 16 | spec: 17 | containers: 18 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 19 | - name: ${NAME}c$(( contnum - 1 )) 20 | image: quay.io/prometheus/busybox 21 | imagePullPolicy: IfNotPresent 22 | command: 23 | - sh 24 | - -c 25 | - echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 26 | "; done ) 27 | terminationGracePeriodSeconds: 1 28 | -------------------------------------------------------------------------------- /test/e2e/files/burstable.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | labels: 6 | app: ${NAME} 7 | $(for lbl in ${!LABEL*}; do [[ "$lbl" == LABEL[0-9]* ]] && echo " 8 | ${!lbl} 9 | "; done) 10 | $( ( [ -n "${!ANN*}" ] || [ -n "$MEMTYPE" ] ) && echo " 11 | annotations: 12 | $(for ann in ${!ANN*}; do [[ "$ann" == ANN[0-9]* ]] && echo " 13 | ${!ann} 14 | "; done) 15 | $( [ -n "$MEMTYPE" ] && echo " 16 | memory-type.resource-policy.nri.io: $MEMTYPE 17 | ") 18 | ") 19 | spec: 20 | containers: 21 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 22 | - name: ${NAME}c$(( contnum - 1 )) 23 | image: quay.io/prometheus/busybox 24 | imagePullPolicy: IfNotPresent 25 | command: 26 | - sh 27 | - -c 28 | - echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 29 | resources: 30 | requests: 31 | cpu: ${CPUREQ} 32 | memory: ${MEMREQ} 33 | limits: 34 | $( ( [ -n "$CPULIM" ] && [ "$CPULIM" != "0" ] ) && echo " 35 | cpu: ${CPULIM} 36 | ") 37 | $( ( [ -n "$MEMLIM" ] && [ "$MEMLIM" != "0" ] ) && echo " 38 | memory: ${MEMLIM} 39 | ") 40 | "; done ) 41 | terminationGracePeriodSeconds: 1 42 | -------------------------------------------------------------------------------- /test/e2e/files/containerd-nri-enable: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Enable containerd NRI plugin 4 | 5 | import tomli_w 6 | import toml 7 | 8 | data=toml.load("/etc/containerd/config.toml") 9 | ((data["plugins"])["io.containerd.nri.v1.nri"])["disable"]=False 10 | 11 | with open("/etc/containerd/config.toml", "wb") as f: 12 | tomli_w.dump(data, f) 13 | -------------------------------------------------------------------------------- /test/e2e/files/crio-nri-enable: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir -p /etc/crio/crio.conf.d 4 | 5 | cat > /etc/crio/crio.conf.d/10-enable-nri.conf <\e[0m "} 4 | HOST_LIB_DIR="$(dirname "${BASH_SOURCE[0]}")" 5 | HOST_PROJECT_DIR="$(dirname "$(dirname "$(realpath "$HOST_LIB_DIR")")")" 6 | 7 | host-command() { 8 | command-start "host" "$HOST_PROMPT" "$1" 9 | bash -c "$COMMAND" 2>&1 | command-handle-output 10 | command-end ${PIPESTATUS[0]} 11 | return $COMMAND_STATUS 12 | } 13 | 14 | host-wait-vm-ssh-server() { 15 | local _vagrantdir="$1" 16 | local _deadline=${deadline:-} 17 | local _once=1 18 | 19 | if [ -z "$_vagrantdir" ]; then 20 | echo 1>&2 "host-wait-vm-ssh-server: missing vagrant directory" 21 | return 1 22 | fi 23 | 24 | if [ -z "$_deadline" ]; then 25 | _deadline=$(( $(date +%s) + ${timeout:-30} )) 26 | fi 27 | 28 | while [ -n "$_once" ] || (( $(date +%s) < $_deadline )); do 29 | if [ ! -f $_vagrantdir/.ssh-config ]; then 30 | sleep 1 31 | else 32 | $SSH -o ConnectTimeout=1 node true 33 | if [ $? = 0 ]; then 34 | return 0 35 | fi 36 | fi 37 | _once="" 38 | done 39 | 40 | echo 1>&2 "host-wait-vm-ssh-server: timeout waiting for $_vagrantdir ssh server" 41 | return 1 42 | } 43 | -------------------------------------------------------------------------------- /test/e2e/memory.test-suite/memory-policy/n6-hbm-cxl/dram-hbm-cxl.helm-config.yaml.in: -------------------------------------------------------------------------------- 1 | config: 2 | injectMpolset: $( ( [[ "$MPOLSET" == "1" ]] && echo true ) || echo false ) 3 | classes: 4 | - name: prefer-one-cxl 5 | policy: 6 | mode: MPOL_PREFERRED 7 | nodes: 4 8 | flags: 9 | - MPOL_F_RELATIVE_NODES 10 | 11 | - name: prefer-all-cxls 12 | policy: 13 | mode: MPOL_PREFERRED_MANY 14 | nodes: 4,5 15 | 16 | - name: interleave-max-bandwidth 17 | policy: 18 | mode: MPOL_INTERLEAVE 19 | nodes: max-dist:19 20 | flags: 21 | - MPOL_F_STATIC_NODES 22 | 23 | - name: bind-hbm 24 | policy: 25 | mode: MPOL_BIND 26 | nodes: 2,3 27 | -------------------------------------------------------------------------------- /test/e2e/memory.test-suite/memory-policy/n6-hbm-cxl/test01-policies/code.var.sh: -------------------------------------------------------------------------------- 1 | helm-terminate 2 | MPOLSET=1 3 | helm_config=$(instantiate dram-hbm-cxl.helm-config.yaml) helm-launch memory-policy 4 | 5 | verify-policy() { 6 | local container=$1 7 | local expected=$2 8 | vm-command "for pid in \$(pgrep -f $container); do grep heap /proc/\$pid/numa_maps; done | head -n 1" 9 | local observed="$COMMAND_OUTPUT" 10 | if [[ "$observed" != *"$expected"* ]]; then 11 | command-error "expected memory policy: $expected, got: $observed" 12 | fi 13 | echo "verify $container memory policy is $expected: ok" 14 | } 15 | 16 | ANN0="class.memory-policy.nri.io: prefer-one-cxl" \ 17 | ANN1="class.memory-policy.nri.io/container.pod0c1: prefer-all-cxls" \ 18 | ANN2="class.memory-policy.nri.io/container.pod0c2: interleave-max-bandwidth" \ 19 | ANN3="class.memory-policy.nri.io/container.pod0c3: bind-hbm" \ 20 | ANN4="policy.memory-policy.nri.io/container.pod0c4: |+ 21 | mode: MPOL_BIND 22 | nodes: 4,5 23 | flags: 24 | - MPOL_F_STATIC_NODES" \ 25 | ANN5="policy.memory-policy.nri.io/container.pod0c5: \"\"" \ 26 | ANN6="class.memory-policy.nri.io/container.pod0c6: \"\"" \ 27 | CONTCOUNT=7 \ 28 | create besteffort 29 | 30 | verify-policy pod0c0 'prefer=relative:4' 31 | verify-policy pod0c1 'prefer (many):4-5' 32 | verify-policy pod0c2 'interleave=static:0-3' 33 | verify-policy pod0c3 'bind:2-3' 34 | verify-policy pod0c4 'bind=static:4-5' 35 | verify-policy pod0c5 'default' # unset pod-default with empty policy 36 | verify-policy pod0c6 'default' # unset pod-default with empty class 37 | -------------------------------------------------------------------------------- /test/e2e/memory.test-suite/memory-policy/n6-hbm-cxl/topology.var.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"mem": "2G", "threads":2, "cores": 2, "nodes": 1, "packages": 2}, 3 | {"mem": "1G", "node-dist": {"0": 15, "1": 30, "2": 10, "3": 35}}, 4 | {"mem": "1G", "node-dist": {"0": 30, "1": 15, "2": 35, "3": 10}}, 5 | {"mem": "4G", "node-dist": {"0": 60, "1": 70, "2": 62, "3": 72, "4": 10, "5": 75}}, 6 | {"mem": "4G", "node-dist": {"0": 70, "1": 60, "2": 72, "3": 62, "4": 75, "5": 10}} 7 | ] 8 | -------------------------------------------------------------------------------- /test/e2e/playbook/nri-balloons-plugin-deploy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | 4 | - name: deploy topology-aware policy plugin 5 | ansible.builtin.import_playbook: deploy-policy-plugin.yaml 6 | vars: 7 | cri_runtime: "{{ cri_runtime }}" 8 | plugin_name: "balloons" 9 | -------------------------------------------------------------------------------- /test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | 4 | - name: deploy topology-aware policy plugin 5 | ansible.builtin.import_playbook: deploy-policy-plugin.yaml 6 | vars: 7 | cri_runtime: "{{ cri_runtime }}" 8 | plugin_name: "topology-aware" 9 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/balloons-busybox.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | $(if [ -n "$POD_ANNOTATION" ]; then echo " 6 | annotations: 7 | $(for ann in "${POD_ANNOTATION[@]}"; do echo " 8 | $ann 9 | "; done) 10 | "; fi) 11 | labels: 12 | app: ${NAME} 13 | $(if [ -n "$POD_LABEL" ]; then echo " 14 | $POD_LABEL 15 | "; fi) 16 | spec: 17 | containers: 18 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 19 | - name: ${NAME}c$(( contnum - 1 )) 20 | image: quay.io/prometheus/busybox 21 | imagePullPolicy: IfNotPresent 22 | command: 23 | - sh 24 | - -c 25 | - ${WORK}echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 26 | $(if [ -n "${CPUREQ}" ]; then echo " 27 | resources: 28 | requests: 29 | cpu: ${CPUREQ} 30 | $(if [ -n "${MEMREQ}" ]; then echo " 31 | memory: '${MEMREQ}' 32 | "; fi) 33 | $(if [ -n "${CPULIM}" ]; then echo " 34 | limits: 35 | cpu: ${CPULIM} 36 | $(if [ -n "$MEMLIM" ]; then echo " 37 | memory: '${MEMLIM}' 38 | "; fi) 39 | "; fi) 40 | "; fi) 41 | "; done ) 42 | terminationGracePeriodSeconds: 1 43 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/cpuclass.cfg: -------------------------------------------------------------------------------- 1 | cpu: 2 | Classes: 3 | class2: 4 | MinFreq: 800 5 | MaxFreq: 3000 6 | class3: 7 | MinFreq: 800 8 | MaxFreq: 3000 9 | class4: 10 | MinFreq: 800 11 | MaxFreq: 3000 12 | EnergyPerformancePreference: 1 13 | 14 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/match-config.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: 750m 4 | pinCPU: true 5 | pinMemory: true 6 | idleCPUClass: normal 7 | allocatorTopologyBalancing: true 8 | preserve: 9 | matchExpressions: 10 | - key: name 11 | operator: In 12 | values: 13 | - pod1cX 14 | - pod2c1 15 | - pod2c2 16 | - pod3cX 17 | balloonTypes: 18 | - name: special 19 | matchExpressions: 20 | - key: pod/labels/app.kubernetes.io/component 21 | operator: Equals 22 | values: [ "precious" ] 23 | minCPUs: 2 24 | maxCPUs: 2 25 | - name: default 26 | namespaces: 27 | - default 28 | minCPUs: 1 29 | maxCPUs: 1 30 | allocatorPriority: normal 31 | reservedPoolNamespaces: 32 | - kube-system 33 | log: 34 | debug: 35 | - policy 36 | - expression 37 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test02-prometheus-metrics/balloons-metrics.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: "1" 4 | balloonTypes: 5 | - name: full-core 6 | minCPUs: 2 7 | maxCPUs: 2 8 | hideHyperthreads: true 9 | cpuClass: normal 10 | 11 | - name: fast-dualcore 12 | minCPUs: 4 13 | maxCPUs: 4 14 | cpuClass: turbo 15 | preferNewBalloons: true 16 | 17 | - name: flex 18 | maxCPUs: 8 19 | cpuClass: slow 20 | instrumentation: 21 | httpEndpoint: :8891 22 | prometheusExport: true 23 | log: 24 | debug: 25 | - policy 26 | klog: 27 | skip_headers: true 28 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test03-reserved/balloons-reserved.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: cpuset:0-2 4 | 5 | idleCPUClass: idle-class 6 | reservedPoolNamespaces: 7 | - "monitor-*" 8 | - "*-log*" 9 | balloonTypes: 10 | - name: reserved 11 | namespaces: 12 | - my-exact-name 13 | cpuClass: reserved-class 14 | minCPUs: 1 15 | - name: default 16 | minCPUs: 1 17 | - name: full-core 18 | minCPUs: 2 19 | maxCPUs: 2 20 | cpuClass: turbo 21 | minBalloons: 2 22 | 23 | instrumentation: 24 | httpEndpoint: ":8891" 25 | log: 26 | debug: 27 | - policy 28 | source: true 29 | klog: 30 | skip_headers: true 31 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test04-groupby/balloons-groupby.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | balloonTypes: 3 | - name: grouped-by-label 4 | groupBy: ${pod/namespace}-${pod/labels/balloon-instance} 5 | minCPUs: 2 6 | minBalloons: 2 7 | preferNewBalloons: true 8 | - name: default 9 | groupBy: ns=$pod/namespace 10 | preferNewBalloons: true 11 | instrumentation: 12 | httpEndpoint: :8891 13 | prometheusExport: true 14 | log: 15 | debug: 16 | - policy 17 | klog: 18 | skip_headers: true 19 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test05-namespace/balloons-namespace.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: "1" 4 | 5 | pinCPU: true 6 | pinMemory: true 7 | balloonTypes: 8 | - name: nsballoon 9 | namespaces: 10 | - "*" 11 | minCPUs: 2 12 | maxCPUs: 4 13 | preferPerNamespaceBalloon: true 14 | 15 | log: 16 | debug: 17 | - policy 18 | instrumentation: 19 | httpEndpoint: ":8891" 20 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test06-update-config/initial-balloons-config.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: 750m 4 | pinCPU: true 5 | pinMemory: true 6 | log: 7 | debug: 8 | - resource-manager 9 | - cache 10 | - policy 11 | source: true 12 | klog: 13 | skip_headers: true 14 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test07-maxballoons/balloons-maxballoons-impossible.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: "1" 4 | pinCPU: true 5 | pinMemory: true 6 | balloonTypes: 7 | - name: singleton 8 | minCPUs: 2 9 | maxCPUs: 2 10 | minBalloons: 1 11 | maxBalloons: 1 12 | - name: impossible 13 | minBalloons: 2 14 | maxBalloons: 1 15 | log: 16 | debug: 17 | - policy 18 | instrumentation: 19 | httpEndpoint: ":8891" 20 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test07-maxballoons/balloons-maxballoons.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: "1" 4 | pinCPU: true 5 | pinMemory: true 6 | balloonTypes: 7 | - name: singleton 8 | minCPUs: 2 9 | maxCPUs: 2 10 | minBalloons: 1 11 | maxBalloons: 1 12 | - name: dynamictwo 13 | maxCPUs: 1 14 | maxBalloons: 2 15 | preferNewBalloons: true 16 | log: 17 | debug: 18 | - policy 19 | instrumentation: 20 | httpEndpoint: ":8891" 21 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test08-numa/balloons-numa.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | availableResources: 3 | cpu: cpuset:0-15 4 | # Reserve one of our CPUs (cpu15) for kube-system tasks. 5 | reservedResources: 6 | cpu: "1" 7 | 8 | pinCPU: true 9 | pinMemory: true 10 | balloonTypes: 11 | - name: fit-in-numa 12 | # All (non-system) containers are assigned to this balloon 13 | # type 14 | namespaces: 15 | - "*" 16 | # Prevent a balloon to be inflated larger than a NUMA node 17 | minCPUs: 0 18 | maxCPUs: 4 19 | allocatorPriority: high 20 | preferNewBalloons: false 21 | 22 | instrumentation: 23 | httpEndpoint: ":8891" 24 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test09-isolated/balloons-isolated.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: cpuset:0 4 | 5 | balloonTypes: 6 | - name: isolated-pods 7 | minCPUs: 0 8 | maxCPUs: 2 9 | cpuClass: turbo 10 | minBalloons: 2 11 | preferNewBalloons: true 12 | preferSpreadingPods: false 13 | - name: isolated-ctrs 14 | minCPUs: 1 15 | maxCPUs: 1 16 | cpuClass: turbo 17 | minBalloons: 2 18 | preferNewBalloons: true 19 | preferSpreadingPods: true 20 | 21 | instrumentation: 22 | httpEndpoint: :8891 23 | prometheusExport: true 24 | log: 25 | debug: 26 | - policy 27 | klog: 28 | skip_headers: true 29 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test10-allocator-opts/balloons-allocator-opts.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: "1" 4 | 5 | allocatorTopologyBalancing: true 6 | preferSpreadOnPhysicalCores: true 7 | balloonTypes: 8 | - name: policydefaults 9 | minCPUs: 2 10 | minBalloons: 2 11 | - name: topo1cores0 12 | minCPUs: 2 13 | minBalloons: 1 14 | preferSpreadOnPhysicalCores: false 15 | - name: topo0cores1 16 | allocatorTopologyBalancing: false 17 | preferSpreadOnPhysicalCores: true 18 | - name: topo0cores0 19 | allocatorTopologyBalancing: false 20 | preferSpreadOnPhysicalCores: false 21 | - name: topo1cores1 22 | allocatorTopologyBalancing: true 23 | preferSpreadOnPhysicalCores: true 24 | - name: device-node2 25 | preferNewBalloons: true 26 | preferSpreadOnPhysicalCores: true 27 | preferCloseToDevices: 28 | - "/sys/devices/system/node/node2" 29 | 30 | instrumentation: 31 | httpEndpoint: :8891 32 | prometheusExport: true 33 | log: 34 | debug: 35 | - policy 36 | klog: 37 | skip_headers: true 38 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test11-match-expression/code.var.sh: -------------------------------------------------------------------------------- 1 | # Test placing containers with and without annotations to correct balloons 2 | # reserved and shared CPUs. 3 | 4 | helm-terminate 5 | helm_config=${TEST_DIR}/../../match-config.yaml helm-launch balloons 6 | 7 | cleanup() { 8 | vm-command "kubectl delete pods --all --now" 9 | return 0 10 | } 11 | 12 | cleanup 13 | 14 | # pod0: run precious workload 15 | POD_LABEL="app.kubernetes.io/component: precious" CONTCOUNT=1 create balloons-busybox 16 | report allowed 17 | verify 'len(cpus["pod0c0"]) == 2' 18 | 19 | # pod1: run ordinary workload 20 | CONTCOUNT=1 create balloons-busybox 21 | report allowed 22 | verify 'len(cpus["pod1c0"]) == 1' 23 | 24 | # pod2: run ordinary workload where pod2c1 and pod2c2 match the 25 | # preserve matchexpression in policy configuration. 26 | CONTCOUNT=4 create balloons-busybox 27 | report allowed 28 | verify 'len(cpus["pod2c0"]) == 1' \ 29 | 'len(cpus["pod2c1"]) == 16' \ 30 | 'len(cpus["pod2c2"]) == 16' \ 31 | 'len(cpus["pod2c3"]) == 1' 32 | 33 | cleanup 34 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test13-cacheclusters/balloons-2cpu-cacheclusters.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | allocatorTopologyBalancing: true 3 | reservedResources: 4 | cpu: 750m 5 | pinCPU: true 6 | pinMemory: true 7 | balloonTypes: 8 | - name: l2burst 9 | minCPUs: 1 10 | maxCPUs: 4 11 | shareIdleCPUsInSame: l2cache 12 | preferSpreadingPods: true # no "same pod" affinity 13 | preferNewBalloons: true # => every container to its own balloon instance 14 | - name: l2pack 15 | allocatorTopologyBalancing: false # create instances to the same L2 group 16 | shareIdleCPUsInSame: l2cache 17 | maxCPUs: 1 18 | log: 19 | debug: 20 | - resource-manager 21 | - cache 22 | - policy 23 | - sysfs 24 | source: true 25 | klog: 26 | skip_headers: true 27 | extraEnv: 28 | OVERRIDE_SYS_CACHES: '''[ 29 | {"cpusets": ["0-7", "8-15"], "level": 3, "size": "128M"}, 30 | 31 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 2, "size": "4M", "kind": "u"}, 32 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 2, "size": "4M", "kind": "u"}, 33 | 34 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 1, "size": "256k", "kind": "d"}, 35 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 1, "size": "128k", "kind": "i"}, 36 | 37 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 1, "size": "256k", "kind": "d"}, 38 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 1, "size": "128k", "kind": "i"} 39 | ]''' 40 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test13-cacheclusters/balloons-4cpu-cacheclusters.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | allocatorTopologyBalancing: true 3 | reservedResources: 4 | cpu: 750m 5 | pinCPU: true 6 | pinMemory: true 7 | balloonTypes: 8 | - name: l2burst 9 | minCPUs: 1 10 | maxCPUs: 4 11 | shareIdleCPUsInSame: l2cache 12 | preferSpreadingPods: true # no "same pod" affinity 13 | preferNewBalloons: true # => every container to its own balloon instance 14 | - name: l2pack 15 | allocatorTopologyBalancing: false # create instances to the same L2 group 16 | shareIdleCPUsInSame: l2cache 17 | maxCPUs: 1 18 | log: 19 | debug: 20 | - resource-manager 21 | - cache 22 | - policy 23 | - sysfs 24 | source: true 25 | klog: 26 | skip_headers: true 27 | extraEnv: 28 | OVERRIDE_SYS_CACHES: '''[ 29 | {"cpusets": ["0-7", "8-15"], "level": 3, "size": "128M"}, 30 | 31 | {"cpusets": ["0-3", "4-7"], "level": 2, "size": "8M"}, 32 | {"cpusets": ["8-11", "12-15"], "level": 2, "size": "8M"}, 33 | 34 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 1, "size": "256k", "kind": "d"}, 35 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 1, "size": "128k", "kind": "i"}, 36 | 37 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 1, "size": "256k", "kind": "d"}, 38 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 1, "size": "128k", "kind": "i"} 39 | ]''' 40 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test15-loadclasses/balloons-loadclasses.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | agent: 3 | nodeResourceTopology: true 4 | showContainersInNrt: true 5 | allocatorTopologyBalancing: false 6 | reservedResources: 7 | cpu: 750m 8 | pinCPU: true 9 | pinMemory: true 10 | balloonTypes: 11 | - name: pre-reserved-avx 12 | minCPUs: 2 13 | maxCPUs: 4 14 | minBalloons: 2 15 | loads: 16 | - avx 17 | - name: noload 18 | maxCPUs: 1 19 | - name: l2load 20 | loads: 21 | - membw 22 | preferSpreadingPods: true 23 | preferNewBalloons: true 24 | - name: l2htload 25 | loads: 26 | - membw 27 | - avx 28 | preferSpreadingPods: true 29 | preferNewBalloons: true 30 | loadClasses: 31 | - name: avx 32 | level: core 33 | overloadsLevelInBalloon: true 34 | - name: membw 35 | level: l2cache 36 | log: 37 | debug: 38 | - policy 39 | extraEnv: 40 | OVERRIDE_SYS_CACHES: '''[ 41 | {"cpusets": ["0-7", "8-15"], "level": 3, "size": "128M"}, 42 | 43 | {"cpusets": ["0-3", "4-7"], "level": 2, "size": "8M"}, 44 | {"cpusets": ["8-11", "12-15"], "level": 2, "size": "8M"}, 45 | 46 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 1, "size": "256k", "kind": "d"}, 47 | {"cpusets": ["0-1", "2-3", "4-5", "6-7"], "level": 1, "size": "128k", "kind": "i"}, 48 | 49 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 1, "size": "256k", "kind": "d"}, 50 | {"cpusets": ["8-9", "10-11", "12-13", "14-15"], "level": 1, "size": "128k", "kind": "i"} 51 | ]''' 52 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test16-composite-balloons/balloons-composite.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | agent: 3 | nodeResourceTopology: true 4 | allocatorTopologyBalancing: false 5 | reservedResources: 6 | cpu: 750m 7 | pinCPU: true 8 | pinMemory: true 9 | balloonTypes: 10 | - name: node0 11 | preferCloseToDevices: 12 | - /sys/devices/system/node/node0 13 | 14 | - name: node1 15 | preferCloseToDevices: 16 | - /sys/devices/system/node/node1 17 | 18 | - name: node2 19 | preferCloseToDevices: 20 | - /sys/devices/system/node/node2 21 | 22 | - name: node3 23 | preferCloseToDevices: 24 | - /sys/devices/system/node/node3 25 | 26 | - name: balance-all-nodes 27 | components: 28 | - balloonType: balance-pkg0-nodes 29 | - balloonType: balance-pkg1-nodes 30 | minCPUs: 4 31 | minBalloons: 1 32 | showContainersInNrt: true 33 | 34 | - name: balance-pkg0-nodes 35 | components: 36 | - balloonType: node0 37 | - balloonType: node1 38 | 39 | - name: balance-pkg1-nodes 40 | components: 41 | - balloonType: node2 42 | - balloonType: node3 43 | preferNewBalloons: true 44 | 45 | - name: kube-system-cpu-core 46 | preferCloseToDevices: 47 | - /sys/devices/system/cpu/cpu6/cache/index0 48 | 49 | - name: reserved 50 | components: 51 | - balloonType: kube-system-cpu-core 52 | log: 53 | debug: 54 | - policy 55 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test17-cstates/balloons-cstates.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | agent: 3 | nodeResourceTopology: true 4 | allocatorTopologyBalancing: false 5 | availableResources: 6 | cpu: cpuset:2-7,10-13 # policy must not touch C-states of unavailable CPUs 7 | reservedResources: 8 | cpu: 750m 9 | 10 | pinCPU: true 11 | 12 | idleCPUClass: default-class 13 | 14 | balloonTypes: 15 | - name: lowlatency-bln 16 | cpuClass: lowlatency-class 17 | 18 | control: 19 | cpu: 20 | classes: 21 | lowlatency-class: 22 | disabledCstates: [C4, C6, C8, C10] 23 | default-class: 24 | disabledCstates: [] 25 | log: 26 | debug: 27 | - policy 28 | - cpu 29 | extraEnv: 30 | OVERRIDE_SYS_CSTATES: '''[{"cpus": "0-15", "names": ["C1E", "C2", "C4", "C8"], "files": {"disable": "0"}}]''' 31 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test20-config-status/balloons.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: 750m 4 | allocatorTopologyBalancing: true 5 | balloonTypes: 6 | - name: dynamic 7 | maxCPUs: 32 8 | maxBalloons: 8 9 | preferNewBalloons: true 10 | shareIdleCPUsInSame: numa 11 | log: 12 | debug: 13 | - policy 14 | klog: 15 | skip_headers: true 16 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test20-config-status/broken-balloons-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.nri/v1alpha1 2 | kind: BalloonsPolicy 3 | metadata: 4 | name: default 5 | namespace: kube-system 6 | spec: 7 | reservedResources: 8 | cpu: 750m 9 | allocatorTopologyBalancing: true 10 | balloonTypes: 11 | - name: dynamic 12 | minCPUs: 33 13 | maxCPUs: 32 14 | maxBalloons: 8 15 | preferNewBalloons: true 16 | shareIdleCPUsInSame: numa 17 | log: 18 | debug: 19 | - policy 20 | klog: 21 | skip_headers: true 22 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test20-config-status/code.var.sh: -------------------------------------------------------------------------------- 1 | helm-terminate 2 | helm_config=$TEST_DIR/balloons.cfg helm-launch balloons 3 | 4 | sleep 1 5 | 6 | jsonpath="{.status.nodes['$VM_HOSTNAME'].status}" 7 | vm-command "kubectl wait -n kube-system balloonspolicies/default \ 8 | --for=jsonpath=\"$jsonpath\"=\"Success\" --timeout=5s" || { 9 | echo "Unexpected config status:" 10 | vm-command "kubectl get -n kube-system balloonspolicies/default \ 11 | -o jsonpath=\"{.status}\" | jq ." 12 | error "expected initial Success status" 13 | } 14 | 15 | host-command "$SCP $TEST_DIR/broken-balloons-config.yaml ${VM_HOSTNAME}:" 16 | vm-command "kubectl apply -f broken-balloons-config.yaml" 17 | 18 | sleep 1 19 | 20 | vm-command "kubectl wait -n kube-system balloonspolicies/default \ 21 | --for=jsonpath=\"$jsonpath\"=\"Failure\" --timeout=5s" || { 22 | echo "Unexpected config status:" 23 | vm-command "kubectl get -n kube-system balloonspolicies/default \ 24 | -o jsonpath=\"{.status}\" | jq ." 25 | error "expected post-update Failure status" 26 | } 27 | 28 | helm-terminate 29 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test21-controller-check/balloons-config.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | reservedResources: 3 | cpu: 750m 4 | pinCPU: true 5 | pinMemory: true 6 | 7 | instrumentation: 8 | httpEndpoint: :8891 9 | log: 10 | debug: 11 | - resource-manager 12 | - cache 13 | - policy 14 | - http 15 | source: true 16 | klog: 17 | skip_headers: true 18 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/test22-isolcpus/balloons-isolcpus.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | balloonTypes: 3 | - name: isolcpus 4 | minCPUs: 1 5 | minBalloons: 1 6 | preferIsolCpus: true 7 | namespaces: 8 | - isolcpus 9 | log: 10 | debug: 11 | - policy 12 | klog: 13 | skip_headers: true 14 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n4c16/topology.var.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"mem": "2G", "cores": 2, "nodes": 2, "packages": 2} 3 | ] 4 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n6-hbm-cxl/py_consts.var.py: -------------------------------------------------------------------------------- 1 | dram0 = "node0" 2 | dram1 = "node1" 3 | hbm0 = "node2" 4 | hbm1 = "node3" 5 | pmem0 = "node4" 6 | pmem1 = "node5" 7 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n6-hbm-cxl/test01-memory-types/balloons-memory-types.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | # Reserve one of our CPUs (cpu15) for kube-system tasks. 3 | reservedResources: 4 | cpu: "1" 5 | pinCPU: true 6 | pinMemory: true 7 | balloonTypes: 8 | - name: mem-types 9 | minCPUs: 2 10 | maxCPUs: 2 11 | preferNewBalloons: true 12 | memoryTypes: 13 | - HBM 14 | - PMEM 15 | 16 | - name: no-mem-types 17 | maxCPUs: 5 18 | allocatorPriority: none 19 | preferSpreadingPods: true 20 | preferNewBalloons: true 21 | 22 | - name: no-pin-mem 23 | minCPUs: 1 24 | maxCPUs: 1 25 | preferNewBalloons: true 26 | pinMemory: false 27 | 28 | instrumentation: 29 | httpEndpoint: ":8891" 30 | prometheusExport: true 31 | log: 32 | debug: 33 | - cache 34 | - policy 35 | - nri-plugin 36 | - libmem 37 | source: true 38 | klog: 39 | skip_headers: true 40 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n6-hbm-cxl/test04-nrt/balloons-nrt.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | pinCPU: true 3 | pinMemory: false 4 | allocatorTopologyBalancing: true 5 | reservedResources: 6 | cpu: cpuset:3 7 | agent: 8 | nodeResourceTopology: true 9 | log: 10 | debug: 11 | - resource-manager 12 | - policy 13 | - cache 14 | source: true 15 | klog: 16 | skip_headers: true 17 | instrumentation: 18 | reportPeriod: 60s 19 | samplingRatePerMillion: 1000000 20 | balloonTypes: 21 | - name: fullsocket 22 | pinMemory: true 23 | maxCPUs: 4 24 | minCPUs: 1 25 | minBalloons: 2 26 | maxBalloons: 2 27 | shareIdleCPUsInSame: package 28 | namespaces: 29 | - "*" 30 | showContainersInNrt: true 31 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/n6-hbm-cxl/topology.var.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"mem": "2G", "threads":2, "cores": 2, "nodes": 1, "packages": 2}, 3 | {"mem": "1G", "node-dist": {"0": 15, "1": 30, "2": 10, "3": 35}}, 4 | {"mem": "1G", "node-dist": {"0": 30, "1": 15, "2": 35, "3": 10}}, 5 | {"mem": "4G", "node-dist": {"0": 60, "1": 70, "2": 62, "3": 72, "4": 10, "5": 75}}, 6 | {"mem": "4G", "node-dist": {"0": 70, "1": 60, "2": 72, "3": 62, "4": 75, "5": 10}} 7 | ] 8 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/balloons/verify.source.sh: -------------------------------------------------------------------------------- 1 | # Utilities to verify data from metrics 2 | 3 | verify_metrics_url="http://localhost:8891/metrics" 4 | 5 | verify-metrics-has-line() { 6 | local expected_line="$1" 7 | vm-run-until --timeout 10 "echo 'waiting for metrics line: $expected_line' >&2; curl --silent $verify_metrics_url | grep -E '$expected_line'" || { 8 | command-error "expected line '$1' missing from the output" 9 | } 10 | } 11 | 12 | verify-metrics-has-no-line() { 13 | local unexpected_line="$1" 14 | vm-run-until --timeout 10 "echo 'checking absence of metrics line: $unexpected_line' >&2; ! curl --silent $verify_metrics_url | grep -Eq '$unexpected_line'" || { 15 | command-error "unexpected line '$1' found from the output" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/helm-config.yaml.in: -------------------------------------------------------------------------------- 1 | config: 2 | $([ -n "${AVAILABLE_CPU}" ] && echo " 3 | availableResources: 4 | cpu: ${AVAILABLE_CPU}") 5 | reservedResources: 6 | cpu: ${RESERVED_CPU:-750m} 7 | colocatePods: ${COLOCATE_PODS:-false} 8 | colocateNamespaces: ${COLOCATE_NAMESPACES:-false} 9 | pinCPU: ${PIN_CPU:-true} 10 | pinMemory: ${PIN_MEMORY:-true} 11 | $([ -n "${RESERVED_POOL_NAMESPACES}" ] && echo " 12 | reservedPoolNamespaces:$(for ns in ${RESERVED_POOL_NAMESPACES}; do echo " 13 | - $ns"; done) 14 | ") 15 | preferSharedCPUs: ${PREFER_SHARED_CPUS:-false} 16 | preferIsolatedCPUs: ${PREFER_ISOLATED_CPUS:-false} 17 | 18 | instrumentation: 19 | httpEndpoint: ":8891" 20 | log: 21 | debug: 22 | - nri-resource-policy 23 | - resource-manager 24 | - cache 25 | - libmem 26 | - policy 27 | source: true 28 | klog: 29 | skip_headers: true 30 | 31 | $([ -n "${!EXTRA_ENV_*}" ] && echo " 32 | extraEnv: 33 | $(for var in ${!EXTRA_ENV_*}; do [[ "${!var}" != "" ]] && echo " 34 | ${var#EXTRA_ENV_}: ${!var} 35 | "; done) 36 | ") 37 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test03-simple-affinity/guaranteed+affinity.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | labels: 6 | app: ${NAME} 7 | annotations: 8 | $([ -z "$(type -t inject-affinities)" ] || inject-affinities AFFINITIES) 9 | $([ -z "$(type -t inject-affinities)" ] || inject-affinities ANTI_AFFINITIES) 10 | $([ -z "$(type -t inject-annotations)" ] || inject-annotations ANNOTATIONS) 11 | spec: 12 | containers: 13 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 14 | - name: ${NAME}c$(( contnum - 1 )) 15 | image: quay.io/prometheus/busybox 16 | imagePullPolicy: IfNotPresent 17 | command: 18 | - sh 19 | - -c 20 | - echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 21 | resources: 22 | requests: 23 | cpu: ${CPU} 24 | memory: '${MEM}' 25 | limits: 26 | cpu: ${CPU} 27 | memory: '${MEM}' 28 | "; done ) 29 | terminationGracePeriodSeconds: 1 30 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test04-available-resources/code.var.sh: -------------------------------------------------------------------------------- 1 | # Test that AvailableResources are honored. 2 | 3 | # Test explicit cpuset in AvailableResources.CPU 4 | helm-terminate 5 | RESERVED_CPU="cpuset:11" 6 | AVAILABLE_CPU="cpuset:4-7,8-11" 7 | helm_config=$(instantiate helm-config.yaml) helm-launch topology-aware 8 | 9 | # pod0: exclusive CPUs 10 | CPU=3 create guaranteed 11 | verify "cpus['pod0c0'] == {'cpu04', 'cpu05', 'cpu06'}" \ 12 | "mems['pod0c0'] == {'node1'}" 13 | 14 | # pod1: shared CPUs 15 | CONTCOUNT=2 CPU=980m create guaranteed 16 | verify "cpus['pod1c0'] == {'cpu08', 'cpu09', 'cpu10'}" \ 17 | "cpus['pod1c1'] == {'cpu08', 'cpu09', 'cpu10'}" \ 18 | "mems['pod1c0'] == {'node2'}" \ 19 | "mems['pod1c1'] == {'node2'}" 20 | vm-command "kubectl delete pods --all --now" 21 | reset counters 22 | 23 | # cleanup, do not leave weirdly configured nri-resource-policy running 24 | helm-terminate 25 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test06-fuzz/codelib.sh: -------------------------------------------------------------------------------- 1 | container-exit0() { 2 | # Terminate a container by killing the "sleep inf" child process in 3 | # echo CONTNAME $(sleep inf) 4 | local contname="$1" 5 | vm-command "contpid=\$(ps axf | grep -A1 'echo $contname' | grep -v grep | awk '/_ sleep inf/{print \$1}'); kill -KILL \$contpid" 6 | } 7 | 8 | container-signal() { 9 | local contname="$1" 10 | local signal="$2" 11 | vm-command "pkill -$signal -f 'echo $contname'" 12 | } 13 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test06-fuzz/fuzz.fmbt.conf: -------------------------------------------------------------------------------- 1 | model = aal_remote(remote_pyaal --verbose-fmbt-log fuzz.aal) 2 | heuristic = mrandom(80,lookahead(1:2),20,random) 3 | coverage = perm(2) 4 | 5 | pass = coverage(10) 6 | pass = steps(100) 7 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test07-mixed-allocations/guaranteed-annotated.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | $(if [ -n "${ANNOTATIONS[0]}" ]; then echo " 6 | annotations: 7 | $(for annotation in "${ANNOTATIONS[@]}"; do echo " 8 | $annotation 9 | "; done) 10 | "; fi) 11 | labels: 12 | app: ${NAME} 13 | spec: 14 | containers: 15 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 16 | - name: ${NAME}c$(( contnum - 1 )) 17 | image: quay.io/prometheus/busybox 18 | imagePullPolicy: IfNotPresent 19 | command: 20 | - sh 21 | - -c 22 | - echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 23 | resources: 24 | requests: 25 | cpu: ${CPU} 26 | memory: '${MEM}' 27 | limits: 28 | cpu: ${CPU} 29 | memory: '${MEM}' 30 | "; done ) 31 | terminationGracePeriodSeconds: 1 32 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test11-reserved-cpu-annotations/reserved-annotated.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | $(if [ -n "${ANNOTATIONS[0]}" ]; then echo " 6 | annotations: 7 | $(for annotation in "${ANNOTATIONS[@]}"; do echo " 8 | $annotation 9 | "; done) 10 | "; fi) 11 | labels: 12 | app: ${NAME} 13 | spec: 14 | containers: 15 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 16 | - name: ${NAME}c$(( contnum - 1 )) 17 | image: quay.io/prometheus/busybox 18 | imagePullPolicy: IfNotPresent 19 | command: 20 | - sh 21 | - -c 22 | - echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 23 | resources: 24 | requests: 25 | cpu: ${CPU} 26 | memory: '${MEM}' 27 | limits: 28 | cpu: ${CPU} 29 | memory: '${MEM}' 30 | "; done ) 31 | terminationGracePeriodSeconds: 1 32 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test12-config-status/custom-config.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: config.nri/v1alpha1 2 | kind: TopologyAwarePolicy 3 | metadata: 4 | name: ${CONFIG_NAME:-default} 5 | namespace: kube-system 6 | spec: 7 | pinCPU: true 8 | pinMemory: true 9 | preferIsolatedCPUs: true 10 | preferSharedCPUs: false 11 | colocatePods: false 12 | colocateNamespaces: false 13 | reservedResources: 14 | cpu: ${RESERVED_CPU} 15 | log: 16 | debug: 17 | - resource-manager 18 | - policy 19 | - cache 20 | source: true 21 | klog: 22 | skip_headers: true 23 | instrumentation: 24 | reportPeriod: 60s 25 | samplingRatePerMillion: 1000000 26 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test14-global-shared-preference/code.var.sh: -------------------------------------------------------------------------------- 1 | cleanup-test-pods() { 2 | # Make sure all the pods in default namespace are cleared so we get a fresh start 3 | vm-command "kubectl delete pods --all --now" 4 | } 5 | 6 | # restart with a global shared CPU allocation preference 7 | PREFER_SHARED_CPUS=true helm_config=$(instantiate helm-config.yaml) helm-launch topology-aware 8 | 9 | # verify that an unannotated guaranteed containers get shared CPUs 10 | CONTCOUNT=1 CPU=1 create guaranteed 11 | report allowed 12 | verify `# pod0c0 has shared CPUs` \ 13 | "len(cpus['pod0c0']) > 1" 14 | 15 | CONTCOUNT=1 CPU=2 create guaranteed 16 | report allowed 17 | verify `# pod1c0 has shared CPUs` \ 18 | "len(cpus['pod1c0']) > 1" 19 | 20 | cleanup-test-pods 21 | 22 | # verify that a container can be annotated to opt out from shared allocation 23 | ANNOTATIONS=('prefer-shared-cpus.resource-policy.nri.io/pod: "false"') 24 | CONTCOUNT=1 CPU=1 create guaranteed-annotated 25 | report allowed 26 | verify `# pod2c0 has a single exclusive CPU allocated` \ 27 | "len(cpus['pod2c0']) == 1" 28 | 29 | # verify that a container can be annotated to opt out from shared allocation 30 | ANNOTATIONS=('prefer-shared-cpus.resource-policy.nri.io/pod: "false"') 31 | CONTCOUNT=1 CPU=2 create guaranteed-annotated 32 | report allowed 33 | verify `# pod3c0 has a single exclusive CPU allocated` \ 34 | "len(cpus['pod3c0']) == 2" 35 | 36 | cleanup-test-pods 37 | 38 | helm-terminate 39 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/test14-global-shared-preference/guaranteed-annotated.yaml.in: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ${NAME} 5 | $(if [ -n "${ANNOTATIONS[0]}" ]; then echo " 6 | annotations: 7 | $(for annotation in "${ANNOTATIONS[@]}"; do echo " 8 | $annotation 9 | "; done) 10 | "; fi) 11 | labels: 12 | app: ${NAME} 13 | spec: 14 | containers: 15 | $(for contnum in $(seq 1 ${CONTCOUNT}); do echo " 16 | - name: ${NAME}c$(( contnum - 1 )) 17 | image: quay.io/prometheus/busybox 18 | imagePullPolicy: IfNotPresent 19 | command: 20 | - sh 21 | - -c 22 | - echo ${NAME}c$(( contnum - 1 )) \$(sleep inf) 23 | resources: 24 | requests: 25 | cpu: ${CPU} 26 | memory: '${MEM}' 27 | limits: 28 | cpu: ${CPU} 29 | memory: '${MEM}' 30 | "; done ) 31 | terminationGracePeriodSeconds: 1 32 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n4c16/topology.var.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"mem": "2G", "cores": 2, "nodes": 2, "packages": 2} 3 | ] 4 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n6-hbm-cxl/py_consts.var.py: -------------------------------------------------------------------------------- 1 | dram0 = "node0" 2 | dram1 = "node1" 3 | hbm0 = "node2" 4 | hbm1 = "node3" 5 | pmem0 = "node4" 6 | pmem1 = "node5" 7 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n6-hbm-cxl/test02-fuzz-memallocs/codelib.sh: -------------------------------------------------------------------------------- 1 | container-exit0() { 2 | # Terminate a container by killing the "sleep inf" child process in 3 | # echo CONTNAME $(sleep inf) 4 | local contname="$1" 5 | vm-command "contpid=\$(ps axf | grep -A1 'echo $contname' | grep -v grep | tail -n 1 | awk '{print \$1}'); ( set -x; kill -KILL \$contpid; )" 6 | } 7 | 8 | container-signal() { 9 | local contname="$1" 10 | local signal="$2" 11 | vm-command "pkill -$signal -f 'echo $contname'" 12 | } 13 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n6-hbm-cxl/test02-fuzz-memallocs/fuzz.fmbt.conf: -------------------------------------------------------------------------------- 1 | model = aal_remote(remote_pyaal --verbose-fmbt-log fuzz.aal) 2 | heuristic = mrandom(80,lookahead(1:2),20,random) 3 | coverage = perm(2) 4 | 5 | pass = coverage(10) 6 | pass = steps(100) 7 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n6-hbm-cxl/test04-nrt/code.var.sh: -------------------------------------------------------------------------------- 1 | cleanup() { 2 | vm-command "kubectl delete pods --all --now" 3 | helm-terminate 4 | } 5 | 6 | cleanup 7 | helm_config=${TEST_DIR}/topology-aware-nrt.cfg helm-launch topology-aware 8 | 9 | get_nrt="kubectl get noderesourcetopologies.topology.node.k8s.io \$(hostname)" 10 | 11 | verify-zone-attribute() { 12 | local zone_name=$1 13 | local attribute_name=$2 14 | local expected_value=$3 15 | vm-command "$get_nrt -o json | jq -r '.zones[] | select (.name == \"$zone_name\").attributes[] | select(.name == \"$attribute_name\").value'" 16 | [[ "$COMMAND_OUTPUT" == "$expected_value" ]] || 17 | command-error "expected zone $zone_name attribute $attribute_name value $expected_value, got: $COMMAND_OUTPUT" 18 | } 19 | 20 | # Print full NRT yaml for debugging 21 | vm-command "$get_nrt -o yaml" 22 | 23 | # Verify selected zone attributes 24 | verify-zone-attribute "socket #0" "memory set" "0,2,4" 25 | verify-zone-attribute "socket #0" "shared cpuset" "0-2" 26 | verify-zone-attribute "socket #0" "reserved cpuset" "3" 27 | 28 | verify-zone-attribute "socket #1" "memory set" "1,3,5" 29 | verify-zone-attribute "socket #1" "shared cpuset" "4-7" 30 | 31 | # TODO: Perhaps IDSet.String() or maybe some other method could print 32 | # ranges so that "memory set" below would be just "0-5". 33 | verify-zone-attribute "root" "memory set" "0,1,2,3,4,5" 34 | verify-zone-attribute "root" "shared cpuset" "0-2,4-7" 35 | verify-zone-attribute "root" "reserved cpuset" "3" 36 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n6-hbm-cxl/test04-nrt/topology-aware-nrt.cfg: -------------------------------------------------------------------------------- 1 | config: 2 | pinCPU: true 3 | pinMemory: true 4 | reservedResources: 5 | cpu: cpuset:3 6 | agent: 7 | nodeResourceTopology: true 8 | log: 9 | debug: 10 | - resource-manager 11 | - policy 12 | - cache 13 | source: true 14 | klog: 15 | skip_headers: true 16 | instrumentation: 17 | reportPeriod: 60s 18 | samplingRatePerMillion: 1000000 19 | -------------------------------------------------------------------------------- /test/e2e/policies.test-suite/topology-aware/n6-hbm-cxl/topology.var.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"mem": "2G", "threads":2, "cores": 2, "nodes": 1, "packages": 2}, 3 | {"mem": "1G", "node-dist": {"0": 15, "1": 30, "2": 10, "3": 35}}, 4 | {"mem": "1G", "node-dist": {"0": 30, "1": 15, "2": 35, "3": 10}}, 5 | {"mem": "4G", "node-dist": {"0": 60, "1": 70, "2": 62, "3": 72, "4": 10, "5": 75}}, 6 | {"mem": "4G", "node-dist": {"0": 70, "1": 60, "2": 72, "3": 62, "4": 75, "5": 10}} 7 | ] 8 | -------------------------------------------------------------------------------- /test/e2e/report-test-status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Report the status of the e2e tests. The script will find all the summary 4 | # files under the current working directory and retrieve test case status. 5 | 6 | for i in `find . -name 'summary*'` 7 | do 8 | echo -n "`dirname $i | awk -F/ '{ print $2 " " $3 " " $4 " " $5 }'`: " 9 | tail -1 $i | awk '{ print $3 }' 10 | done 11 | -------------------------------------------------------------------------------- /test/statistics-analysis/manifests/jaeger-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: jaeger 5 | namespace: monitoring 6 | labels: 7 | app: jaeger 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: jaeger 13 | template: 14 | metadata: 15 | labels: 16 | app: jaeger 17 | spec: 18 | containers: 19 | - name: jaeger 20 | env: 21 | - name: COLLECTOR_OTLP_ENABLED 22 | value: "true" 23 | ports: 24 | - containerPort: 16686 25 | - containerPort: 4317 26 | - containerPort: 4318 27 | image: jaegertracing/all-in-one:1.44.0 28 | imagePullPolicy: IfNotPresent 29 | --- 30 | apiVersion: v1 31 | kind: Service 32 | metadata: 33 | name: jaeger 34 | namespace: monitoring 35 | spec: 36 | type: NodePort 37 | selector: 38 | app: jaeger 39 | ports: 40 | - name: otlp-grpc 41 | port: 4317 42 | nodePort: 30317 43 | - name: otlp-http 44 | port: 4318 45 | nodePort: 30318 46 | - name: frontend 47 | port: 16686 48 | nodePort: 30001 49 | -------------------------------------------------------------------------------- /test/statistics-analysis/manifests/sleep-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: sleep 5 | labels: 6 | app: sleep 7 | spec: 8 | replicas: ${NUMBER_OF_REPLICAS} 9 | selector: 10 | matchLabels: 11 | app: sleep 12 | template: 13 | metadata: 14 | labels: 15 | app: sleep 16 | spec: 17 | containers: 18 | - name: sleep 19 | image: quay.io/crio/busybox:latest 20 | imagePullPolicy: IfNotPresent 21 | command: 22 | - sh 23 | - -c 24 | - sleep 604800 25 | resources: 26 | requests: 27 | cpu: 10m 28 | memory: 20M 29 | limits: 30 | cpu: 10m 31 | -------------------------------------------------------------------------------- /test/statistics-analysis/manifests/stress-ng-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: stress-ng 5 | labels: 6 | app: stress-ng 7 | spec: 8 | replicas: ${NUMBER_OF_REPLICAS} 9 | selector: 10 | matchLabels: 11 | app: stress-ng 12 | template: 13 | metadata: 14 | labels: 15 | app: stress-ng 16 | spec: 17 | containers: 18 | - name: stress-ng 19 | image: alexeiled/stress-ng:latest 20 | imagePullPolicy: IfNotPresent 21 | command: ["/stress-ng"] 22 | args: ["--cpu", "1"] 23 | -------------------------------------------------------------------------------- /test/statistics-analysis/prometheus-values.yaml: -------------------------------------------------------------------------------- 1 | alertmanager: 2 | enabled: false 3 | kube-state-metrics: 4 | enabled: false 5 | prometheus-node-exporter: 6 | enabled: false 7 | prometheus-pushgateway: 8 | enabled: false 9 | server: 10 | global: 11 | scrape_interval: 15s 12 | evaluation_interval: 15s 13 | persistentVolume: 14 | enabled: false 15 | service: 16 | type: NodePort 17 | nodePort: 30000 18 | -------------------------------------------------------------------------------- /test/statistics-analysis/scripts/destroy-deployment.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" 4 | BASE_DIR="$(realpath "${SCRIPT_DIR}/..")" 5 | 6 | # This scripts simply deletes all possible deployments. 7 | # Deployments that do not exist will result in errors but they can be ignored. 8 | 9 | kubectl delete -f "${BASE_DIR}/manifests/" 10 | 11 | helm uninstall -n monitoring prometheus 12 | -------------------------------------------------------------------------------- /test/statistics-analysis/scripts/post-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # For plotting graphs. 4 | 5 | SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" 6 | BASE_DIR="$(realpath "${SCRIPT_DIR}/..")" 7 | 8 | if [ ! -z "$PREFIX" ]; then 9 | PREFIX="-p $PREFIX" 10 | fi 11 | 12 | python3 ${SCRIPT_DIR}/plot-graphs.py "$PREFIX" -o "${BASE_DIR}/output/traces.png" -l "topology_aware-jaeger,balloons-jaeger,template-jaeger,baseline-jaeger" "${BASE_DIR}/output" 13 | python3 ${SCRIPT_DIR}/plot-graphs.py "$PREFIX" -o "${BASE_DIR}/output/resource_usage.png" -l "topology_aware-prometheus,balloons-prometheus,template-prometheus" "${BASE_DIR}/output" 14 | -------------------------------------------------------------------------------- /test/statistics-analysis/scripts/pre-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # For deploying Prometheus and Jaeger tracing all-in-one. 4 | 5 | SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" 6 | BASE_DIR="$(realpath "${SCRIPT_DIR}/..")" 7 | 8 | USE_PROMETHEUS="true" 9 | 10 | usage () { 11 | echo "usage: $0 -p " 12 | exit 1 13 | } 14 | 15 | while getopts ":n:p:" option; do 16 | case ${option} in 17 | p) 18 | USE_PROMETHEUS="${OPTARG}" 19 | if [ "${OPTARG}" != "true" ] && [ "${OPTARG}" != "false" ]; then 20 | usage 21 | fi 22 | ;; 23 | \?) 24 | usage 25 | esac 26 | done 27 | 28 | kubectl create namespace monitoring 29 | kubectl apply -f "${BASE_DIR}/manifests/jaeger-deployment.yaml" 30 | 31 | if [ "${USE_PROMETHEUS}" == "true" ]; then 32 | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 33 | helm install prometheus prometheus-community/prometheus --version 19.7.2 -f prometheus-values.yaml --namespace monitoring --create-namespace 34 | fi 35 | 36 | # Wait for deployments to be ready. 37 | kubectl rollout status deployment -n monitoring prometheus-server 38 | kubectl rollout status deployment -n monitoring jaeger 39 | -------------------------------------------------------------------------------- /test/statistics-analysis/scripts/requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | matplotlib 3 | pandas --------------------------------------------------------------------------------