mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-27 17:42:57 +08:00
commit
2e3de8da3e
7 changed files with 268 additions and 79 deletions
48
.github/workflows/publish-docker.yml
vendored
48
.github/workflows/publish-docker.yml
vendored
|
@ -13,7 +13,8 @@ jobs:
|
|||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set tag
|
||||
-
|
||||
name: Set tag
|
||||
run: |
|
||||
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
|
||||
TAG=${{ github.event.inputs.tag }}
|
||||
|
@ -23,21 +24,54 @@ jobs:
|
|||
TAG="${{ github.base_ref }}"
|
||||
fi
|
||||
echo "TAG=${TAG}" >> $GITHUB_ENV
|
||||
- name: Checkout
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push latest
|
||||
-
|
||||
name: Build x86 and export to Docker
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
tags: ${{ env.TAG }}
|
||||
-
|
||||
name: Test x86
|
||||
run: |
|
||||
docker run --rm ${{ env.TAG }}&
|
||||
sleep 10
|
||||
kill %1
|
||||
-
|
||||
name: Build arm and export to Docker
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
load: true
|
||||
platforms: linux/arm64
|
||||
tags: ${{ env.TAG }}
|
||||
-
|
||||
name: Test arm
|
||||
run: |
|
||||
docker run --rm ${{ env.TAG }}&
|
||||
sleep 10
|
||||
kill %1
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64, linux/arm64
|
||||
push: true
|
||||
tags: gravitl/netmaker:${{ env.TAG }}
|
||||
tags: ${{ github.repository }}:${{ env.TAG }}
|
||||
|
|
51
.github/workflows/test-artifacts.yml
vendored
Normal file
51
.github/workflows/test-artifacts.yml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
name: Build artifacts for deployment testing
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'testing'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and Push test
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: ghcr.io/${{ github.repository }}:testing
|
||||
netclient:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: build client
|
||||
run: |
|
||||
cd netclient
|
||||
go build -ldflags="-X 'main.version=testing'" .
|
||||
curl -H 'Authorization: Bearer ${{ secrets.NUSAK_MASTERKEY }}' \
|
||||
-H 'Content-Type: multipart/form-data' --form upload='./netclient' \
|
||||
-X POST https://dashboard.nusak.ca/api/file/netclient
|
||||
#deploy:
|
||||
#runs-on: ubuntu-latest
|
||||
#steps:
|
||||
#- name: Deploy Testing Server and Client(s)
|
||||
# run: |
|
||||
# curl -X POST https://api.github.com/mattkasun/terraform-test/dispatches \
|
||||
# -H 'Accept: application/vnd.github.everest-preview+json' \
|
||||
# -u ${{ secrets.ACCESS_TOKEN }}
|
15
Dockerfile
15
Dockerfile
|
@ -1,26 +1,19 @@
|
|||
#first stage - builder
|
||||
FROM gravitl/builder as builder
|
||||
|
||||
FROM golang:1.15-alpine as builder
|
||||
ARG version
|
||||
RUN apk add build-base
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV GO111MODULE=auto
|
||||
|
||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go build -ldflags="-w -s" -o netmaker main.go
|
||||
|
||||
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
|
||||
FROM alpine:3.13.6
|
||||
# add a c lib
|
||||
RUN apk add gcompat iptables
|
||||
# set the working directory
|
||||
WORKDIR /root/
|
||||
|
||||
RUN mkdir -p /etc/netclient/config
|
||||
|
||||
COPY --from=builder /app/netmaker .
|
||||
COPY --from=builder /app/config config
|
||||
|
||||
EXPOSE 8081
|
||||
EXPOSE 50051
|
||||
|
||||
ENTRYPOINT ["./netmaker"]
|
||||
|
|
15
README.md
15
README.md
|
@ -39,14 +39,14 @@
|
|||
**For production-grade installations, visit the [Install Docs](https://netmaker.readthedocs.io/en/master/install.html).**
|
||||
**For an HA install using helm on k8s, visit the [Helm Repo](https://github.com/gravitl/netmaker-helm/).**
|
||||
1. Get a cloud VM with Ubuntu 20.04 and a public IP.
|
||||
2. Open ports 443, 53, and 51821-51830/udp on the VM firewall and in cloud security settings.
|
||||
2. Open ports 443, 80, 53, and 51821-51830/udp on the VM firewall and in cloud security settings.
|
||||
3. Run the script **(see below for optional configurations)**:
|
||||
|
||||
`sudo wget -qO - https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/nm-quick.sh | bash`
|
||||
|
||||
<img src="./docs/images/install-server.gif" width="50%" /><img src="./docs/images/visit-website.gif" width="50%" />
|
||||
|
||||
Upon completion, the logs will display the instructions to connect various devices. These can also be retrived from the UI under "Acess Keys."
|
||||
Upon completion, the logs will display the instructions to connect various devices. These can also be retrived from the UI under "Access Keys."
|
||||
|
||||
After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://netmaker.readthedocs.io/en/master/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://gravitl.com/resources) for different use cases, including Kubernetes.
|
||||
|
||||
|
@ -88,6 +88,17 @@ After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting
|
|||
|
||||
- [Learning Resources](https://gravitl.com/resources)
|
||||
|
||||
# Community Projects
|
||||
|
||||
- [Netmaker + Traefik Proxy](https://github.com/bsherman/netmaker-traefik)
|
||||
|
||||
- [OpenWRT Netclient Packager](https://github.com/sbilly/netmaker-openwrt)
|
||||
|
||||
- [Golang GUI](https://github.com/mattkasun/netmaker-gui)
|
||||
|
||||
- [CoreDNS Plugin](https://github.com/SekoiaLab/netmaker-coredns)
|
||||
|
||||
|
||||
## Disclaimer
|
||||
[WireGuard](https://wireguard.com/) is a registered trademark of Jason A. Donenfeld.
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ new-module -name netclient-install -scriptblock {
|
|||
Function Netclient-Install() {
|
||||
param ($version='latest', $token)
|
||||
|
||||
|
||||
if($token -eq $null -or $token -eq ""){
|
||||
Quit "-token required"
|
||||
}
|
||||
|
@ -48,6 +47,9 @@ new-module -name netclient-install -scriptblock {
|
|||
$loc = Get-Location
|
||||
Copy-Item -Path "$env:userprofile\Downloads\netclient.exe" -Destination "$loc\netclient.exe"
|
||||
}
|
||||
$runNum = "one","two"
|
||||
foreach ($run in $runNum) {
|
||||
|
||||
$NetArgs = @("join","-t",$token)
|
||||
Start-Process -Filepath $outpath -ArgumentList $NetArgs -Wait
|
||||
Add-MpPreference -ExclusionPath "C:\ProgramData\Netclient"
|
||||
|
@ -62,6 +64,12 @@ new-module -name netclient-install -scriptblock {
|
|||
$env:Path += ";C:\ProgramData\Netclient\bin"
|
||||
}
|
||||
}
|
||||
if($run -eq "one"){
|
||||
Write-Host "re-running setup to confirm all components are installed."
|
||||
Start-Sleep -s 1
|
||||
}
|
||||
}
|
||||
Write-Host "'netclient' is installed."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,15 +10,30 @@ echo "checking dependencies..."
|
|||
OS=$(uname)
|
||||
|
||||
if [ -f /etc/debian_version ]; then
|
||||
dependencies="wireguard wireguard-tools"
|
||||
update_cmd='apt update'
|
||||
install_cmd='apt-get install -y'
|
||||
elif [ -f /etc/alpine-release ]; then
|
||||
dependencies="wireguard"
|
||||
update_cmd='apk update'
|
||||
install_cmd='apk --update add'
|
||||
elif [ -f /etc/centos-release ]; then
|
||||
dependencies="wireguard"
|
||||
update_cmd='yum update'
|
||||
install_cmd='yum install -y'
|
||||
elif [ -f /etc/fedora-release ]; then
|
||||
dependencies="wireguard"
|
||||
update_cmd='dnf update'
|
||||
install_cmd='dnf install -y'
|
||||
elif [ "${OS}" = "FreeBSD" ]; then
|
||||
dependencies="wireguard"
|
||||
update_cmd='pkg update'
|
||||
install_cmd='pkg install -y'
|
||||
elif [ -f /etc/openwrt_release ]; then
|
||||
dependencies="wireguard-tools"
|
||||
OS="OpenWRT"
|
||||
update_cmd='opkg update'
|
||||
install_cmd='opkg install'
|
||||
else
|
||||
install_cmd=''
|
||||
fi
|
||||
|
@ -27,7 +42,7 @@ if [ -z "${install_cmd}" ]; then
|
|||
echo "OS unsupported for automatic dependency install"
|
||||
exit 1
|
||||
fi
|
||||
dependencies="wireguard"
|
||||
|
||||
set -- $dependencies
|
||||
while [ -n "$1" ]; do
|
||||
echo $1
|
||||
|
@ -49,16 +64,24 @@ while [ -n "$1" ]; do
|
|||
echo " " This may break functionality.
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ "${OS}" = "OpenWRT" ]; then
|
||||
is_installed=$(opkg list-installed $1 | grep $1)
|
||||
else
|
||||
is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed")
|
||||
if [ "${is_installed}" = "install ok installed" ]; then
|
||||
fi
|
||||
if [ "${is_installed}" != "" ]; then
|
||||
echo " " $1 is installed
|
||||
else
|
||||
echo " " $1 is not installed. Attempting install.
|
||||
${install_cmd} $1
|
||||
sleep 5
|
||||
if [ "${OS}" = "OpenWRT" ]; then
|
||||
is_installed=$(opkg list-installed $1 | grep $1)
|
||||
else
|
||||
is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed")
|
||||
if [ "${is_installed}" = "install ok installed" ]; then
|
||||
fi
|
||||
if [ "${is_installed}" != "" ]; then
|
||||
echo " " $1 is installed
|
||||
elif [ -x "$(command -v $1)" ]; then
|
||||
echo " " $1 is installed
|
||||
|
@ -105,7 +128,7 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
|
|||
dist=netclient-arm64
|
||||
;;
|
||||
armv7l)
|
||||
dist=netclient-armv7
|
||||
dist=netclient-arm7
|
||||
;;
|
||||
arm*)
|
||||
dist=netclient-$CPU_ARCH
|
||||
|
@ -155,18 +178,23 @@ esac
|
|||
echo "Binary = $dist"
|
||||
|
||||
url="https://github.com/gravitl/netmaker/releases/download/$VERSION/$dist"
|
||||
curl_opts='-nv'
|
||||
if [ "${OS}" = "OpenWRT" ]; then
|
||||
curl_opts='-q'
|
||||
fi
|
||||
|
||||
if curl --output /dev/null --silent --head --fail "$url"; then
|
||||
echo "Downloading $dist $VERSION"
|
||||
wget -nv -O netclient $url
|
||||
wget $curl_opts -O netclient $url
|
||||
else
|
||||
echo "Downloading $dist latest"
|
||||
wget -nv -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist
|
||||
wget $curl_opts -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist
|
||||
fi
|
||||
|
||||
chmod +x netclient
|
||||
|
||||
EXTRA_ARGS=""
|
||||
if [ "${OS}" = "FreeBSD" ]; then
|
||||
if [ "${OS}" = "FreeBSD" ] || [ "${OS}" = "OpenWRT" ]; then
|
||||
EXTRA_ARGS="--daemon=off"
|
||||
fi
|
||||
|
||||
|
@ -201,6 +229,58 @@ END_OF_FILE
|
|||
sudo chmod +x /usr/local/etc/rc.d/netclient
|
||||
sudo /usr/local/etc/rc.d/netclient enable
|
||||
sudo /usr/local/etc/rc.d/netclient start
|
||||
|
||||
elif [ "${OS}" = "OpenWRT" ]; then
|
||||
mv ./netclient /etc/netclient/netclient
|
||||
cat << 'END_OF_FILE' > ./netclient.service.tmp
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
EXTRA_COMMANDS="status"
|
||||
EXTRA_HELP=" status Check service is running"
|
||||
START=99
|
||||
|
||||
LOG_FILE="/tmp/netclient.logs"
|
||||
|
||||
start() {
|
||||
if [ ! -f "${LOG_FILE}" ];then
|
||||
touch "${LOG_FILE}"
|
||||
fi
|
||||
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')
|
||||
if [ "${PID}" ];then
|
||||
echo "service is running"
|
||||
return
|
||||
fi
|
||||
bash -c "while [ 1 ]; do /etc/netclient/netclient checkin -n all >> ${LOG_FILE} 2>&1;sleep 15;\
|
||||
if [ $(ls -l ${LOG_FILE}|awk '{print $5}') -gt 10240000 ];then tar zcf "${LOG_FILE}.tar" -C / "tmp/netclient.logs" && > $LOG_FILE;fi;done &"
|
||||
echo "start"
|
||||
}
|
||||
|
||||
stop() {
|
||||
pids=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')
|
||||
for i in "${pids[@]}"
|
||||
do
|
||||
if [ "${i}" ];then
|
||||
kill "${i}"
|
||||
fi
|
||||
done
|
||||
echo "stop"
|
||||
}
|
||||
|
||||
status() {
|
||||
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')
|
||||
if [ "${PID}" ];then
|
||||
echo -e "netclient[${PID}] is running \n"
|
||||
else
|
||||
echo -e "netclient is not running \n"
|
||||
fi
|
||||
}
|
||||
|
||||
END_OF_FILE
|
||||
mv ./netclient.service.tmp /etc/init.d/netclient
|
||||
chmod +x /etc/init.d/netclient
|
||||
/etc/init.d/netclient enable
|
||||
/etc/init.d/netclient start
|
||||
else
|
||||
rm -f netclient
|
||||
fi
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ fi
|
|||
echo "checking dependencies..."
|
||||
|
||||
declare -A osInfo;
|
||||
osInfo[/etc/debian_version]="apt-get install -y"
|
||||
osInfo[/etc/debian_version]="apt-get install -y"u
|
||||
osInfo[/etc/alpine-release]="apk --update add"
|
||||
osInfo[/etc/centos-release]="yum install -y"
|
||||
osInfo[/etc/fedora-release]="dnf install -y"
|
||||
|
@ -40,8 +40,20 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
if [ -f /etc/debian_version ]; then
|
||||
apt update
|
||||
elif [ -f /etc/alpine-release ]; then
|
||||
apk update
|
||||
elif [ -f /etc/centos-release ]; then
|
||||
yum update
|
||||
elif [ -f /etc/fedora-release ]; then
|
||||
dnf update
|
||||
fi
|
||||
|
||||
dependencies=("docker.io" "docker-compose" "wireguard" "jq")
|
||||
|
||||
|
||||
|
||||
for dependency in ${dependencies[@]}; do
|
||||
is_installed=$(dpkg-query -W --showformat='${Status}\n' ${dependency} | grep "install ok installed")
|
||||
|
||||
|
|
Loading…
Reference in a new issue