-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7f3d5da
Showing
15 changed files
with
659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2024 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2024 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
name: Lint Code Base | ||
# yamllint disable-line rule:truthy | ||
on: | ||
push: | ||
pull_request: | ||
jobs: | ||
check-broken-links: | ||
name: Check documentation external links | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4.1.1 | ||
- name: Check broken links | ||
uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 | ||
check-super-linter: | ||
name: Check syntax (super-linter) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4.1.1 | ||
- name: Run super-linter validation | ||
uses: github/super-linter@v5.0.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
LINTER_RULES_PATH: / | ||
KUBERNETES_KUBECONFORM_OPTIONS: '-ignore-missing-schemas' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2024 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
formatter: | ||
type: basic | ||
include_document_start: true | ||
pad_line_comments: 2 | ||
max_line_length: 160 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2024 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
|
||
DOCKER_CMD ?= $(shell which docker 2> /dev/null || which podman 2> /dev/null || echo docker) | ||
|
||
.PHONY: lint | ||
lint: | ||
sudo -E $(DOCKER_CMD) run --rm -v $$(pwd):/tmp/lint \ | ||
-e RUN_LOCAL=true \ | ||
-e LINTER_RULES_PATH=/ \ | ||
-e KUBERNETES_KUBECONFORM_OPTIONS='-ignore-missing-schemas' \ | ||
github/super-linter | ||
tox -e lint | ||
|
||
.PHONY: fmt | ||
fmt: | ||
sudo -E $(DOCKER_CMD) run --rm -u "$$(id -u):$$(id -g)" \ | ||
-v "$$(pwd):/mnt" \ | ||
-w /mnt mvdan/shfmt -l -w -i 4 -s . | ||
command -v yamlfmt > /dev/null || curl -s "https://i.jpillora.com/google/yamlfmt!!" | bash | ||
yamlfmt -dstar **/*.{yaml,yml} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Nephio PoCs | ||
<!-- markdown-link-check-disable-next-line --> | ||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
[![GitHub Super-Linter](https://github.com/electrocucaracha/nephio-pocs/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter) | ||
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) | ||
<!-- markdown-link-check-disable-next-line --> | ||
![visitors](https://visitor-badge.laobi.icu/badge?page_id=electrocucaracha.nephio-poc) | ||
|
||
The goal of this project is to provision a [Nephio Management cluster][1] for testing different use cases and scenarios. | ||
|
||
<!-- markdown-link-check-disable --> | ||
* Software Package hosting URL - <http://localhost:3000/> | ||
<!-- markdown-link-check-enable --> | ||
|
||
[1]: https://nephio.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# frozen_string_literal: true | ||
|
||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
############################################################################## | ||
# Copyright (c) 2024 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
|
||
host = RbConfig::CONFIG['host_os'] | ||
|
||
no_proxy = ENV['NO_PROXY'] || ENV['no_proxy'] || '127.0.0.1,localhost' | ||
(1..254).each do |i| | ||
no_proxy += ",10.0.2.#{i}" | ||
end | ||
|
||
case host | ||
when /darwin/ | ||
mem = `sysctl -n hw.memsize`.to_i / 1024 | ||
when /linux/ | ||
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i | ||
when /mswin|mingw|cygwin/ | ||
mem = `wmic computersystem Get TotalPhysicalMemory`.split[1].to_i / 1024 | ||
end | ||
|
||
# rubocop:disable Metrics/BlockLength | ||
Vagrant.configure('2') do |config| | ||
# rubocop:enable Metrics/BlockLength | ||
config.vm.provider :libvirt | ||
config.vm.provider :virtualbox | ||
|
||
config.vm.box = 'generic/ubuntu2204' | ||
config.vm.box_check_update = false | ||
config.vm.synced_folder './', '/vagrant' | ||
config.vm.network 'forwarded_port', guest: 3000, guest_ip: '172.18.0.200', host: 3000 | ||
config.vm.network 'forwarded_port', guest: 80, guest_ip: '172.18.0.202', host: 8080 | ||
|
||
# Initial setup | ||
config.vm.provision 'shell', privileged: false, inline: <<-SHELL | ||
if [ -f /etc/netplan/01-netcfg.yaml ] && ! grep -q '1.1.1.1, 8.8.8.8, 8.8.4.4' /etc/netplan/01-netcfg.yaml; then | ||
sudo sed -i "s/addresses: .*/addresses: [1.1.1.1, 8.8.8.8, 8.8.4.4]/g" /etc/netplan/01-netcfg.yaml | ||
sudo netplan apply | ||
fi | ||
# Create .bash_aliases | ||
echo 'cd /vagrant/' >> /home/vagrant/.bash_aliases | ||
chown vagrant:vagrant /home/vagrant/.bash_aliases | ||
SHELL | ||
|
||
# Install dependencies | ||
config.vm.provision 'shell', privileged: false do |sh| | ||
sh.env = { | ||
DEBUG: ENV.fetch('DEBUG', true), | ||
ENABLE_CLUSTER_API: 'true', | ||
ENABLE_NETWORK_CONFIG: 'true' | ||
} | ||
sh.inline = <<-SHELL | ||
set -o errexit | ||
set -o pipefail | ||
cd /vagrant/scripts | ||
./main.sh | tee ~/main.log | ||
SHELL | ||
end | ||
|
||
%i[virtualbox libvirt].each do |provider| | ||
config.vm.provider provider do |p| | ||
p.cpus = ENV['CPUS'] || 8 | ||
p.memory = ENV['MEMORY'] || mem / 1024 / 4 | ||
end | ||
end | ||
|
||
config.vm.provider 'virtualbox' do |v| | ||
v.gui = false | ||
v.customize ['modifyvm', :id, '--nictype1', 'virtio', '--cableconnected1', 'on'] | ||
# Enable nested paging for memory management in hardware | ||
v.customize ['modifyvm', :id, '--nestedpaging', 'on'] | ||
# Use large pages to reduce Translation Lookaside Buffers usage | ||
v.customize ['modifyvm', :id, '--largepages', 'on'] | ||
# Use virtual processor identifiers to accelerate context switching | ||
v.customize ['modifyvm', :id, '--vtxvpid', 'on'] | ||
end | ||
|
||
config.vm.provider :libvirt do |v, override| | ||
override.vm.synced_folder './', '/vagrant', type: 'nfs', | ||
nfs_version: ENV.fetch('VAGRANT_NFS_VERSION', 3) | ||
v.memorybacking :access, mode: 'shared' | ||
v.random_hostname = true | ||
v.management_network_address = '10.0.2.0/24' | ||
v.management_network_name = 'administration' | ||
v.cpu_mode = 'host-passthrough' | ||
end | ||
|
||
if !ENV['http_proxy'].nil? && !ENV['https_proxy'].nil? && Vagrant.has_plugin?('vagrant-proxyconf') | ||
config.proxy.http = ENV['http_proxy'] || ENV['HTTP_PROXY'] || '' | ||
config.proxy.https = ENV['https_proxy'] || ENV['HTTPS_PROXY'] || '' | ||
config.proxy.no_proxy = no_proxy | ||
config.proxy.enabled = { docker: false } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2024 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
|
||
set -o pipefail | ||
set -o errexit | ||
set -o nounset | ||
[[ ${DEBUG:-false} != "true" ]] || set -o xtrace | ||
|
||
# get_status() - Print the current status of the cluster | ||
function get_status { | ||
set +o xtrace | ||
printf "CPU usage: " | ||
grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage " %"}' | ||
printf "Memory free(Kb):" | ||
awk -v low="$(grep low /proc/zoneinfo | awk '{k+=$2}END{print k}')" '{a[$1]=$2} END{ print a["MemFree:"]+a["Active(file):"]+a["Inactive(file):"]+a["SReclaimable:"]-(12*low);}' /proc/meminfo | ||
if command -v kubectl >/dev/null; then | ||
echo "Kubernetes Events:" | ||
kubectl get events --sort-by='.lastTimestamp' -A --field-selector type!=Normal | ||
echo "Kubernetes Resources:" | ||
kubectl get all -A -o wide | ||
echo "Kubernetes Nodes:" | ||
kubectl describe nodes | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2023 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
|
||
set -o pipefail | ||
set -o errexit | ||
set -o nounset | ||
[[ ${DEBUG:-false} != "true" ]] || set -o xtrace | ||
|
||
# debug() - This function prints a debug message in the standard output | ||
function debug { | ||
_print_msg "DEBUG" "$1" | ||
echo "::debug::$1" | ||
} | ||
|
||
# info() - This function prints an information message in the standard output | ||
function info { | ||
_print_msg "INFO" "$1" | ||
echo "::notice::$1" | ||
} | ||
|
||
# warn() - This function prints a warning message in the standard output | ||
function warn { | ||
_print_msg "WARN" "$1" | ||
echo "::warning::$1" | ||
} | ||
|
||
# error() - This function prints an error message in the standard output | ||
function error { | ||
_print_msg "ERROR" "$1" | ||
echo "::error::$1" | ||
exit 1 | ||
} | ||
|
||
function _print_msg { | ||
echo "$(date +%H:%M:%S) - $1: $2" | ||
} |
Oops, something went wrong.