Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds edge-proxy service in preparation for kubelet and docker #160

Merged
merged 1 commit into from Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions recipes-core/images/console-image.bb
Expand Up @@ -152,6 +152,7 @@ WIGWAG_STUFF = " \
deviceoswd \
emacs \
fftw \
edge-proxy \
imagemagick \
lcms \
virtual/mbed-edge-core \
Expand Down
9 changes: 9 additions & 0 deletions recipes-core/netbase/netbase/hosts
@@ -0,0 +1,9 @@
127.0.0.1 localhost.localdomain localhost
127.0.0.1 gateways.local

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
2 changes: 2 additions & 0 deletions recipes-core/netbase/netbase_%.bbappend
@@ -0,0 +1,2 @@
#prepend to take precedence over poky/meta
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
49 changes: 49 additions & 0 deletions recipes-wigwag/edge-proxy/edge-proxy_git.bb
@@ -0,0 +1,49 @@
DESCRIPTION = "Tunneling proxy for all FOG services"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"

inherit go pkgconfig gitpkgv systemd

PR = "r0"
SRC_URI = "git://git@github.com/armPelionEdge/edge-proxy.git;protocol=ssh;name=ep;depth=1\
file://edge-proxy.service\
file://edge-proxy-watcher.service\
file://edge-proxy.path\
file://launch-edge-proxy.sh\
file://edge-proxy.conf.json\
"

SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE_${PN} = "edge-proxy.service"
SYSTEMD_AUTO_ENABLE_${PN} = "enable"

SRCREV_FORMAT = "ep"
SRCREV_ep = "e0a7389ae4322ce8ceede6e2051d1832eb17cab4"
GO_IMPORT = "github.com/armPelionEdge/edge-proxy"

RDEPENDS_${PN} = "jq"

wbindir = "/wigwag/system/bin"
wetcdir = "/wigwag/etc"
FILES_${PN} = "\
${wbindir}/edge-proxy\
${wbindir}/launch-edge-proxy.sh\
${wetcdir}/edge-proxy.conf.json\
${systemd_system_unitdir}/edge-proxy.service\
${systemd_system_unitdir}/edge-proxy-watcher.service\
${systemd_system_unitdir}/edge-proxy.path\
"

do_install () {
install -d ${D}${wbindir}
install -m 0755 ${B}/${GO_BUILD_BINDIR}/edge-proxy ${D}${wbindir}/
install -m 0755 ${WORKDIR}/launch-edge-proxy.sh ${D}${wbindir}/
install -d ${D}${wetcdir}
install -m 0755 ${WORKDIR}/edge-proxy.conf.json ${D}${wetcdir}/
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/edge-proxy.service ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/edge-proxy-watcher.service ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/edge-proxy.path ${D}${systemd_system_unitdir}
}

do_package_qa[noexec] = "1"
9 changes: 9 additions & 0 deletions recipes-wigwag/edge-proxy/files/edge-proxy-watcher.service
@@ -0,0 +1,9 @@
[Unit]
Description=edge-proxy restarter

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart edge-proxy.service

[Install]
WantedBy=network.target
3 changes: 3 additions & 0 deletions recipes-wigwag/edge-proxy/files/edge-proxy.conf.json
@@ -0,0 +1,3 @@
{
"edge_proxy_uri_relative_path": "/edge-proxy/connect"
}
9 changes: 9 additions & 0 deletions recipes-wigwag/edge-proxy/files/edge-proxy.path
@@ -0,0 +1,9 @@
[Unit]
Description=Monitor the changes to identity.json file and restart edge-proxy

[Path]
PathChanged=/userdata/edge_gw_config/identity.json
Unit=edge-proxy-watcher.service

[Install]
WantedBy=network.target
12 changes: 12 additions & 0 deletions recipes-wigwag/edge-proxy/files/edge-proxy.service
@@ -0,0 +1,12 @@
[Unit]
Descritpion=Tunneling Proxy for gateways
Requires=wait-for-pelion-identity.service
After=wait-for-pelion-identity.service

[Service]
Restart=always
RestartSec=5
ExecStart=/wigwag/system/bin/launch-edge-proxy.sh

[Install]
WantedBy=network.target
36 changes: 36 additions & 0 deletions recipes-wigwag/edge-proxy/files/launch-edge-proxy.sh
@@ -0,0 +1,36 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright (c) 2020, Arm Limited and affiliates.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

EDGE_K8S_ADDRESS=$(jq -r .edgek8sServicesAddress /userdata/edge_gw_config/identity.json)
GATEWAYS_ADDRESS=$(jq -r .gatewayServicesAddress /userdata/edge_gw_config/identity.json)
EDGE_PROXY_URI_RELATIVE_PATH=$(jq -r .edge_proxy_uri_relative_path /wigwag/etc/edge-proxy.conf.json)




exec /wigwag/system/bin/edge-proxy \
-proxy-uri=${EDGE_K8S_ADDRESS} \
-proxy-listen=0.0.0.0:8080 \
-tunnel-uri=ws://gateways.local$EDGE_PROXY_URI_RELATIVE_PATH \
-cert-strategy=tpm \
-cert-strategy-options=socket=/tmp/edge.sock \
-cert-strategy-options=path=/1/pt \
-cert-strategy-options=device-cert-name=mbed.LwM2MDeviceCert \
-cert-strategy-options=private-key-name=mbed.LwM2MDevicePrivateKey \
-forwarding-addresses={\"gateways.local\":\"${GATEWAYS_ADDRESS#"https://"}\"}
2 changes: 1 addition & 1 deletion recipes-wigwag/maestro/maestro/rpi3/devicejs.template.conf
@@ -1,6 +1,6 @@
{
"modulesDirectory": "/wigwag/etc/devicejs/modules",
"port": 8080,
"port": 8081,
"cloudAddress": "{{ARCH_GW_SERVICES_URL}}/devicejs/socket.io",
"databaseConfig": {
"uri": "https://127.0.0.1:{{LOCAL_DEVICEDB_PORT}}",
Expand Down