From a2457e8006a73293a6013d77f4a5c7bc061030bd Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Mon, 29 Jul 2024 18:20:51 +0300 Subject: [PATCH] notes --- dev/sample mermaid.mmd | 31 +++++++++++++++ linux/docker install.md | 4 ++ linux/setup forticlient.sh | 15 +++++++- python/appveyor.mmd | 41 ++++++++++++++++++++ python/deployments_graph.py | 29 +++++++++----- windows/wsl.cmd | 76 +++++++++++++++++++++++++++++++++++++ 6 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 dev/sample mermaid.mmd create mode 100644 windows/wsl.cmd diff --git a/dev/sample mermaid.mmd b/dev/sample mermaid.mmd new file mode 100644 index 0000000..be830ac --- /dev/null +++ b/dev/sample mermaid.mmd @@ -0,0 +1,31 @@ +``` mermaid +graph TD + A[Common Configuration] --> B[master] + A[Common Configuration] --> C[stable] + A[Common Configuration] --> D[deployment] + A[Common Configuration] --> E[GAT-5073] + A[Common Configuration] --> F[GAT-5098] + + B --> B1[Release_ProfessionalTestServer] + B --> B2[Release_TestServer] + B --> B3[Release_DemoServer] + B1 --> G[TESTPRO on master] + B2 --> H[TEST on master] + B3 --> I[DEMO on master] + + C --> C1[Release_DemoServer] + C --> C2[Release_ProfessionalTestServer] + C1 --> J[DEMO on stable] + C2 --> K[TESTPRO on stable] + + D --> D1[Release_ProductionServer] + D --> D2[Release_ProfessionalServer] + D1 --> L[PROD Staging on deployment] + D2 --> M[PRO on deployment] + + E --> E1[Staging_TestServer] + E1 --> N[TEST-Staging on GAT-5073] + + F --> F1[Staging_DemoServer] + F1 --> O[DEMO-Staging on GAT-5098] +``` \ No newline at end of file diff --git a/linux/docker install.md b/linux/docker install.md index cac3c86..19b9101 100644 --- a/linux/docker install.md +++ b/linux/docker install.md @@ -28,3 +28,7 @@ sudo docker build -t your-image-name . # attach to container docker exec -it potainer /bin/sh +# on windows - setup port forwarding +#netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=9000 connectaddress=172.29.111.255 connectport=9000 +netsh interface portproxy add v4tov4 listenport=9000 listenaddress=0.0.0.0 connectport=9000 connectaddress=172.29.104.23 +netsh interface portproxy delete v4tov4 listenaddress=127.0.0.1 listenport=9000 diff --git a/linux/setup forticlient.sh b/linux/setup forticlient.sh index 80fe0bb..c2fe637 100644 --- a/linux/setup forticlient.sh +++ b/linux/setup forticlient.sh @@ -2,7 +2,20 @@ #wget https://filestore.fortinet.com/forticlient/forticlient_vpn_7.0.7.0246_amd64.deb apt update apt install -y openfortivpn ppp -openfortivpn vpn.gateway.one:10443 -u 'dobromir.popov@gateway.one' --trusted-cert bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +openfortivpn vpn.gateway.one:10443 -u 'dobromir.popov@gateway.one' --trusted-cert bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +U6n4A7^8^c7dX&p6s + + +or +nano /etc/openfortivpn/config +> +host = vpn.gateway.one +port = 10443 +trusted-cert = bd26362cc802a27102fcdbf7e7e9328f3dede58aa44c125ede4aadb9e39da8c8 +pppd-use-peerdns = 1 +set-routes = 1 +username = dobromir.popov@gateway.one +password = U6n4A7^8^c7dX&p6s #ERROR: pppd: The kernel does not support PPP, for example, the PPP kernel driver is not included or cannot be loaded. diff --git a/python/appveyor.mmd b/python/appveyor.mmd index 84ab1a8..dcbdd43 100644 --- a/python/appveyor.mmd +++ b/python/appveyor.mmd @@ -33,3 +33,44 @@ graph TD style C1 fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5 style C2 fill:#bbf,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5 + + +%% graph TD +%% A[Branches] --> B[master] +%% A --> C[stable] +%% A --> D[deployment] +%% A --> E[GAT-5073] +%% A --> F[GAT-5098] + +%% B --> G[Release_ProfessionalTestServer] +%% B --> H[Release_DemoServer] + +%% C --> I[Release_DemoServer] +%% C --> J[Release_ProfessionalTestServer] + +%% D --> K[Release_ProductionServer] +%% D --> L[Release_ProfessionalServer] + +%% E --> M[Staging_TestServer] + +%% F --> N[Staging_DemoServer] + +%% G --> O[TESTPRO - production] +%% H --> P[DEMO - production] + +%% I --> Q[DEMO - production] +%% J --> R[TESTPRO - production] + +%% K --> S[PROD - staging] +%% L --> T[PRO - production] + +%% M --> U[TEST - staging] + +%% N --> V[DEMO - staging] + +%% style A fill:#f9f,stroke:#333,stroke-width:2px +%% style B fill:#bbf,stroke:#333,stroke-width:2px +%% style C fill:#bbf,stroke:#333,stroke-width:2px +%% style D fill:#bbf,stroke:#333,stroke-width:2px +%% style E fill:#bbf,stroke:#333,stroke-width:2px +%% style F fill:#bbf,stroke:#333,stroke-width:2px \ No newline at end of file diff --git a/python/deployments_graph.py b/python/deployments_graph.py index f6d9e0e..8eddfbd 100644 --- a/python/deployments_graph.py +++ b/python/deployments_graph.py @@ -34,10 +34,15 @@ if 'branches' in config: # Check for inactive branches and configurations in the comments lines = appveyor_yml.splitlines() for i, line in enumerate(lines): + # Check for commented branches if re.match(r'#\s*-\s*(\w+)', line): - inactive_configs.setdefault(lines[i-1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_')) - if line.strip().startswith('#') and i + 2 < len(lines) and 'branches:' in lines[i + 1] and 'only:' in lines[i + 2]: - inactive_branches.append(lines[i + 2].split(':')[1].strip().replace('-', '_')) + branch_name = re.findall(r'#\s*-\s*(\w+)', line)[0] + if 'branches' in lines[i - 1] and 'only:' in lines[i - 2]: + inactive_branches.append(branch_name.replace('-', '_')) + + # Check for commented configurations + if re.match(r'#\s*-\s*(\w+)', line): + inactive_configs.setdefault(lines[i - 1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_')) # Extract deployment configurations if 'deploy' in config: @@ -67,14 +72,18 @@ for branch in branches.keys(): for branch, configs in branches.items(): branch_id = branch.replace('-', '_') for idx, config in enumerate(configs): - config_id = f"{branch_id}{idx+1}" + config_id = f"{branch_id}{idx + 1}" mermaid_graph += f" {branch_id} --> {config_id}[{config}]\n" - # Add deployments to the configurations - for deploy in deployments.get(branch, []): - configuration = deploy.get('configuration') - if configuration == config: - service = deploy.get('service', '') - mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('on', {}).get('configuration', '')} on {branch}]\n" + +# Add deployments to the configurations +for branch, deploys in deployments.items(): + branch_id = branch.replace('-', '_') + for deploy in deploys: + configuration = deploy.get('configuration') + if configuration: + config_id = f"{branch_id}{branches[branch].index(configuration) + 1}" + service_id = deploy.get('website', '').replace('-', '_') + mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('provider', '')} on {branch}]\n" # Highlight inactive branches and configurations with a dotted style for branch in inactive_branches: diff --git a/windows/wsl.cmd b/windows/wsl.cmd new file mode 100644 index 0000000..769cdf8 --- /dev/null +++ b/windows/wsl.cmd @@ -0,0 +1,76 @@ +@REM run image (alpine) as root user + wsl -d Alpine -u root + + +@REM wsl install docker cuda +# Update the package list and install dependencies +sudo apt update +sudo apt install -y ca-certificates curl gnupg lsb-release + +# Add Docker’s official GPG key +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + +# Set up the Docker repository +echo \ +"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ +$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +# Update the package list +sudo apt update + +# Install Docker Engine +sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + +# Start Docker +sudo service docker start + +# Enable Docker to start at boot +sudo systemctl enable docker + +# Allow Docker commands without sudo +sudo usermod -aG docker $USER + + +@REM Install WSL-Ubuntu Package for CUDA: + +@REM Follow the instructions to install the CUDA toolkit specifically designed for WSL. Do not install the default CUDA toolkit that includes the drivers. + + +wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin +sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 +wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-wsl-ubuntu-12-2-local_12.2.0-1_amd64.deb +sudo dpkg -i cuda-repo-wsl-ubuntu-12-2-local_12.2.0-1_amd64.deb +sudo cp /var/cuda-repo-wsl-ubuntu-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/ +sudo apt-get update +sudo apt-get install cuda +Install NVIDIA Container Toolkit: + +@REM Set up the package repository and install the NVIDIA Container Toolkit: + +distribution=$(. /etc/os-release;echo $ID$VERSION_ID) +curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - +curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list + +sudo apt-get update +sudo apt-get install -y nvidia-docker2 + + +# Create/update Docker daemon configuration +mkdir -p /etc/docker +echo '{ + "runtimes": { + "nvidia": { + "path": "nvidia-container-runtime", + "runtimeArgs": [] + } + } +}' > /etc/docker/daemon.json + + +sudo systemctl restart docker + + +@REM Run a test container to ensure everything is set up correctly: + +sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi \ No newline at end of file