Skip to content

Commit

Permalink
Add documentation for install.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Morales <[email protected]>
  • Loading branch information
electrocucaracha committed Nov 9, 2022
1 parent 99498f9 commit 609cd4d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ DOCKER_CMD ?= $(shell which docker 2> /dev/null || which podman 2> /dev/null ||
lint:
sudo -E $(DOCKER_CMD) run --rm -v $$(pwd):/tmp/lint \
-e RUN_LOCAL=true \
-e LINTER_RULES_PATH=/ \
-e VALIDATE_KUBERNETES_KUBEVAL=false \
-e LINTER_RULES_PATH=.github/linters \
-e KUBERNETES_KUBEVAL_OPTIONS=--ignore-missing-schemas \
github/super-linter

.PHONY: fmt
Expand Down
18 changes: 17 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,23 @@ Vagrant.configure('2') do |config|
config.vm.box_check_update = false
config.vm.synced_folder './', '/vagrant'

config.vm.provision 'shell', privileged: false, path: './scripts/install.sh', reset: true
config.vm.provision 'shell', privileged: false do |sh|
sh.env = {
DEBUG: ENV.fetch('DEBUG', true)
}
sh.inline = <<-SHELL
set -o errexit
set -o pipefail
if [ -f /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
cd /vagrant/scripts
./install.sh | tee ~/install.log
SHELL
end

%i[virtualbox libvirt].each do |provider|
config.vm.provider provider do |p|
Expand Down
30 changes: 30 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# install.sh

This bash script installs the following dependencies required for the creation
of a multi-cluster environment.

- [KinD](https://kind.sigs.k8s.io/)
- [kubectl](https://kubernetes.io/docs/reference/kubectl/kubectl/)
- [Docker](https://www.docker.com/)
- [kpt](https://kpt.dev/)

The following diagram shows the result after its execution.

```text
+---------------------------------+ +---------------------------------+ +---------------------------------+ +---------------------------------+
| nephio (k8s) | | regional (k8s) | | edge-1 (k8s) | | edge-2 (k8s) |
| +-----------------------------+ | | +-----------------------------+ | | +-----------------------------+ | | +-----------------------------+ |
| | nephio-control-plane | | | | regional-control-plane | | | | edge-1-control-plane | | | | edge-2-control-plane | |
| | podSubnet: 10.196.0.0/16 | | | | podSubnet: 10.197.0.0/16 | | | | podSubnet: 10.198.0.0/16 | | | | podSubnet: 10.199.0.0/16 | |
| | serviceSubnet: 10.96.0.0/16 | | | | serviceSubnet: 10.97.0.0/16 | | | | serviceSubnet: 10.98.0.0/16 | | | | serviceSubnet: 10.99.0.0/16 | |
| +-----------------------------+ | | +-----------------------------+ | | +-----------------------------+ | | +-----------------------------+ |
| | eth0(172.88.0.2/16) | | | | eth0(172.89.0.2/16) | | | | eth0(172.90.0.2/16) | | | | eth0(172.91.0.2/16) | |
| +-----------------------------+ | | +-----------------------------+ | | +-----------------------------+ | | +-----------------------------+ |
| | | | | | | |
+--------------+------------------+ +--------------+------------------+ +--------------+------------------+ +--------------+------------------+
| | | |
+=========+============+ +=========+============+ +=========+===========+ +=========+===========+
| net-nephio(bridge) | | net-regional(bridge) | | net-edge-1(bridge) | | net-edge-2(bridge) |
| 172.88.0.0/16 | | 172.89.0.0/16 | | 172.90.0.0/16 | | 172.91.0.0/16 |
+======================+ +======================+ +=====================+ +=====================+
```
11 changes: 7 additions & 4 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if [[ ${DEBUG:-false} == "true" ]]; then
fi

export PKG_KREW_PLUGINS_LIST=" "
export PKG_KIND_VERSION=0.17.0
export PKG_KUBECTL_VERSION=1.25.3
KPT_VERSION=1.0.0-beta.23

declare -A clusters
clusters=(
Expand All @@ -31,10 +34,9 @@ clusters=(
curl -fsSL http://bit.ly/install_pkg | PKG_COMMANDS_LIST="kind,docker,kubectl" bash

if ! command -v kpt; then
curl -s 'https://i.jpillora.com/GoogleContainerTools/kpt@v1.0.0-beta.23!' | bash
curl -s "https://i.jpillora.com/GoogleContainerTools/kpt@v$KPT_VERSION!" | bash
kpt completion bash | sudo tee /etc/bash_completion.d/kpt >/dev/null
fi
exit

function deploy_k8s_cluster {
local name="$1"
Expand All @@ -43,9 +45,9 @@ function deploy_k8s_cluster {
local svc_subnet="$4"

newgrp docker <<EONG
docker network create --driver bridge --subnet=$node_subnet net-$name ||:
if ! kind get clusters -q | grep -q $name; then
docker network create --driver bridge --subnet=$node_subnet $name
cat << EOF | KIND_EXPERIMENTAL_DOCKER_NETWORK=$name kind create cluster --name $name --config=-
cat << EOF | KIND_EXPERIMENTAL_DOCKER_NETWORK=net-$name kind create cluster --name $name --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
Expand All @@ -54,6 +56,7 @@ networking:
serviceSubnet: "$svc_subnet"
nodes:
- role: control-plane
image: kindest/node:v$PKG_KUBECTL_VERSION
EOF
fi
EONG
Expand Down

0 comments on commit 609cd4d

Please sign in to comment.