From eb84daff873dcac28918d7bef01b1493f6de36ca Mon Sep 17 00:00:00 2001 From: Maxime Mouchet Date: Tue, 29 Mar 2022 15:11:30 +0200 Subject: [PATCH] add EdgeNet@home configuration --- edgenet-at-home-node.yml | 8 ++++++++ main.go | 13 ++++--------- roles/edgenet-kubernetes/tasks/main.yml | 6 ++++++ .../templates/edgenet-config.yaml.j2 | 1 + roles/edgenet-ssh/tasks/main.yml | 2 +- vars/edgenet-at-home.yml | 6 ++++++ vars/edgenet-production.yml | 2 +- 7 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 edgenet-at-home-node.yml create mode 100644 roles/edgenet-kubernetes/templates/edgenet-config.yaml.j2 create mode 100644 vars/edgenet-at-home.yml diff --git a/edgenet-at-home-node.yml b/edgenet-at-home-node.yml new file mode 100644 index 0000000..716b0a4 --- /dev/null +++ b/edgenet-at-home-node.yml @@ -0,0 +1,8 @@ +--- +- hosts: all + become: true + roles: + - edgenet-ssh + - edgenet-kubernetes + vars_files: + - vars/edgenet-at-home.yml diff --git a/main.go b/main.go index df43fab..3996567 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,6 @@ import ( "time" ) -const defaultKubeconfigURL = "https://raw.githubusercontent.com/EdgeNet-project/edgenet/master/configs/public.cfg" const defaultVPNNetworkV4 = "10.183.0.0/20" const defaultVPNNetworkV6 = "fdb4:ae86:ec99:4004::/64" const edgenetConfigFile = "/opt/edgenet/config.yaml" @@ -157,10 +156,6 @@ func main() { config.load(edgenetConfigFile) log.Printf("config=%+v\n", config) - if config.KubeconfigURL == "" { - config.KubeconfigURL = defaultKubeconfigURL - } - if config.Platform == "" { log.Println("step=detect-platform") config.Platform = platforms.Detect() @@ -188,7 +183,7 @@ func main() { check(err) _, vpnNetworkV6, err := net.ParseCIDR(defaultVPNNetworkV6) check(err) - config.VPNIPv4, config.VPNIPv6 = cluster.FindVPNIPs(defaultKubeconfigURL, *vpnNetworkV4, *vpnNetworkV6) + config.VPNIPv4, config.VPNIPv6 = cluster.FindVPNIPs(config.KubeconfigURL, *vpnNetworkV4, *vpnNetworkV6) } if config.VPNPrivateKey == "" { @@ -219,9 +214,9 @@ func main() { network.AssignVPNIP(vpnLinkName, *config.VPNIPv4, *config.VPNIPv6) privateKey, err := wgtypes.ParseKey(config.VPNPrivateKey) check(err) - cluster.CreateVPNPeer(defaultKubeconfigURL, hostname, config.PublicIPv4, config.VPNIPv4.IP, config.VPNIPv6.IP, config.VPNListenPort, privateKey.PublicKey().String()) + cluster.CreateVPNPeer(config.KubeconfigURL, hostname, config.PublicIPv4, config.VPNIPv4.IP, config.VPNIPv6.IP, config.VPNListenPort, privateKey.PublicKey().String()) // Pre-establish the tunnels before the VPNPeer controller gets started. - peers := cluster.ListVPNPeer(defaultKubeconfigURL) + peers := cluster.ListVPNPeer(config.KubeconfigURL) for _, peer := range peers { network.AddPeer(vpnLinkName, peer) } @@ -239,5 +234,5 @@ func main() { network.SetKubeletNodeIP(kubeletEnvFileRedHat, nodeIP) log.Println("step=join-cluster") - cluster.Join(defaultKubeconfigURL, hostname, nodeIP) + cluster.Join(config.KubeconfigURL, hostname, nodeIP) } diff --git a/roles/edgenet-kubernetes/tasks/main.yml b/roles/edgenet-kubernetes/tasks/main.yml index 3e88507..93f6000 100644 --- a/roles/edgenet-kubernetes/tasks/main.yml +++ b/roles/edgenet-kubernetes/tasks/main.yml @@ -102,6 +102,12 @@ state: directory mode: "0755" +- name: Ensure EdgeNet configuration is present + template: + src: edgenet-config.yaml.j2 + dest: /opt/edgenet/config.yaml + mode: 0644 + - name: Ensure EdgeNet binary is present get_url: url: "{{ edgenet_node_url }}" diff --git a/roles/edgenet-kubernetes/templates/edgenet-config.yaml.j2 b/roles/edgenet-kubernetes/templates/edgenet-config.yaml.j2 new file mode 100644 index 0000000..f4fa2d0 --- /dev/null +++ b/roles/edgenet-kubernetes/templates/edgenet-config.yaml.j2 @@ -0,0 +1 @@ +kubeconfigURL: {{ kubeconfig_url }} diff --git a/roles/edgenet-ssh/tasks/main.yml b/roles/edgenet-ssh/tasks/main.yml index a95a01d..1567683 100644 --- a/roles/edgenet-ssh/tasks/main.yml +++ b/roles/edgenet-ssh/tasks/main.yml @@ -28,7 +28,7 @@ groups: wheel append: true createhome: true - comment: EdgeNet (edge-net.org) + comment: edge-net.org - name: Ensure the .ssh directory is present file: diff --git a/vars/edgenet-at-home.yml b/vars/edgenet-at-home.yml new file mode 100644 index 0000000..9824a2e --- /dev/null +++ b/vars/edgenet-at-home.yml @@ -0,0 +1,6 @@ +# edgenet-kubernetes +containerd_version: 1.6 +kubernetes_version: 1.23 +edgenet_node_version: 1.0.13 +# edgenet-ssh +edgenet_ssh_public_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD0yU5EV3zQaP/2Ln4do32sHLm9NdU7p3vQUIKY/AttBp+91equT2jA7SD+71aOYiEp8TzjNCCN98DJxwyhT4MM0FRkd0KbgB3djk4rDJ4ePSeqPtmEXwzRfbnrMqfs9pt0STGWLqpCkPrX7Vfo89PyNMi3fGJaKJ+8AcYf40uLQm5MrPS1XZIOYi+UOru7VlgA53UxGkG0NorjCMYw5Sqt0q4Ds1pURBGq+dorbwgur4SgtYLURXvEqJG8q32Ta6q2hLQ6jJ3/hPaEs5Uc/pEmAoS5QMK5HLQtJxTlNQ3WfMz+Oz1NZRAaZO3TrrGKs4J2bUu9d6fbn1XIYtCF9ABXI+cBYPMk8RtOyNR8Rl9mxa1qN6KDgeCJR897Bo/IIIBwdthfK3kpQsK/PvPJIlTbga/e7r6fnYfXpa1Ycs36AfwZko6W5BorxMXza7asRLNvDa2TgZmfTsTEBut8Jw1BRIJWkvZRWbAmS13XE/bUPO3win0nq4CPO/8Q2UlqzudaDEWqrnlB7bgrEUoMSyTp0yG9JG1DAgKXOk9Z0dcUZ/XyhwSeR/nET7avKO2ixWX+1CPqPIHA3Ya3BYlWwYBkdEStA5k3c/7lrSRVzbBhsW9x8InyeLh+Tiv4VNG9V0BnsDzS6zppk+QpvlVfJBpNGfFTvoEsaSf6HcA8+V12Pw== root@ehome.planet-lab.eu diff --git a/vars/edgenet-production.yml b/vars/edgenet-production.yml index 9c83a09..843d617 100644 --- a/vars/edgenet-production.yml +++ b/vars/edgenet-production.yml @@ -1,4 +1,4 @@ # edgenet-kubernetes containerd_version: 1.4 kubernetes_version: 1.21 -edgenet_node_version: 1.0.12 +edgenet_node_version: 1.0.13