afeiszli 3 lat temu
rodzic
commit
5a121fb724

+ 27 - 0
docker/Dockerfile-netclient-userspace

@@ -0,0 +1,27 @@
+ARG NC_VERSION=
+
+FROM gravitl/builder as builder
+
+RUN apk add --update git build-base libmnl-dev iptables
+
+WORKDIR /root/
+RUN git clone https://git.zx2c4.com/wireguard-go && \
+    cd wireguard-go && \
+    make && \
+    make install
+
+ENV WITH_WGQUICK=yes
+RUN git clone https://git.zx2c4.com/wireguard-tools && \
+    cd wireguard-tools && \
+    cd src && \
+    make && \
+    make install
+
+FROM gravitl/netclient:${NC_VERSION}
+
+RUN apk add --no-cache --update bash libmnl iptables openresolv iproute2 && cp /etc/netclient/netclient /root/netclient
+COPY --from=builder /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/
+COPY scripts/netclient-userspace-entrypoint.sh ./entrypoint.sh
+
+ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]
+

+ 60 - 0
kube/netclient-daemonset-userspace.yaml

@@ -0,0 +1,60 @@
+apiVersion: apps/v1
+kind: DaemonSet
+metadata:
+  name: netclient
+  labels:
+    app: netclient
+spec:
+  selector:
+    matchLabels:
+      app: netclient
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: netclient
+    spec:
+      hostNetwork: true
+      containers:
+      - name: netclient
+        image: gravitl/netclient:v0.7.2
+        command: ['bash', '-c', "netclient checkin -n $NETWORK; sleep $SLEEP"]
+        env:
+        - name: ACCESS_TOKEN
+          value: "XXXX"
+        - name: NETWORK
+          value: "YYYY"
+        - name: SLEEP
+          value: 10
+        - name: WG_QUICK_USERSPACE_IMPLEMENTATION
+          value: "wireguard-go"
+        volumeMounts:
+        - mountPath: /etc/netclient
+          name: etc-netclient
+        - mountPath: /usr/bin/wg
+          name: wg
+        securityContext:
+          privileged: true
+      initContainers:
+      - name: netclient-join
+        image: gravitl/netclient:v0.7.2
+        command: ['bash', '-c', "netclient join -t $ACCESS_TOKEN --daemon off"]
+        env:
+        - name: ACCESS_TOKEN
+          value: "XXXX"
+        volumeMounts:
+        - mountPath: /etc/netclient
+          name: etc-netclient
+        - mountPath: /usr/bin/wg
+          name: wg
+        securityContext:
+          privileged: true
+  volumes:
+  - hostPath:
+      path: /etc/netclient
+      type: DirectoryOrCreate
+    name: etc-netclient
+  - hostPath:
+      path: /usr/bin/wg
+      type: File
+    name: wg

+ 1 - 1
kube/netclient-template.yaml

@@ -16,7 +16,7 @@ spec:
       hostNetwork: true
       containers:
       - name: netclient
-        image: gravitl/netclient:v0.5.11
+        image: gravitl/netclient:v0.8.5
         command: ['bash', '-c', "/root/netclient join -t $ACCESS_TOKEN --daemon off --name $(echo $NODE_NAME| sed -e s/.$NETWORK//); while true; do /root/netclient checkin --dns on -n $NETWORK; sleep $SLEEP; done"]
         env:
         - name: ACCESS_TOKEN

+ 15 - 0
scripts/netclient-userspace-entrypoint.sh

@@ -0,0 +1,15 @@
+echo "[netclient] joining network"
+
+/root/netclient join -t $ACCESS_TOKEN -daemon off -dnson no
+
+cp netclient /etc/netclient/netclient
+
+echo "[netclient] Starting netclient checkin"
+# loop and call checkin -n all
+while [ 1 ]; do
+    # add logs to netclient.logs
+    /etc/netclient/netclient checkin -n $NETWORK
+    sleep $SLEEP
+done
+echo "[netclient] exiting"
+

+ 1 - 1
scripts/userspace-entrypoint.sh

@@ -3,4 +3,4 @@ if [ ! -d /dev/net ]; then mkdir /dev/net; fi
 if [ ! -e /dev/net/tun ]; then  mknod /dev/net/tun c 10 200; fi
 
 # Wait and then run netmaker.
-/bin/sh -c "sleep 3; ./netmaker"
+/bin/sh -c "sleep 3; ./netmaker"