open-horizon / devops

Devops processes to build and deploy horizon components
Apache License 2.0
10 stars 43 forks source link

Problem with connect edge devices to managment hub on GCP #100

Closed TParashchuk closed 2 years ago

TParashchuk commented 2 years ago

I installed management hub using ‘all-in-one’ on the VM Ubuntu 18.04.6 LTS (Google cloud platform). All checks were successful after installation. I was moving 2 ways:

1.) I have 2 devices Raspberry Pi 4. I prepared my devices using ‘Preparing an edge device Linux on ARM (32-bit)’ for edge devices. Also, I added firewall rules for ports on the VM Ubuntu 18.04.6 LTS (management hub on the GCP) and I opened ports on my router for getting access Raspberry devices through management hub on the GCP. Now I stopped on “Advanced manual agent installation and registration”, on the step ‘add horizon agent trust to agent-install.crt’:

if grep -qE '^HZN_MGMT_HUB_CERT_PATH=' /etc/default/horizon; then sed -i.bak -e "s|^HZN_MGMT_HUB_CERT_PATH=[^ ]*|HZN_MGMT_HUB_CERT_PATH=${PWD}/agent-install.crt|" /etc/default/horizon; else echo "HZN_MGMT_HUB_CERT_PATH=${PWD}/agent-install.crt" >> /etc/default/horizon; fi

Where can I take ‘agent-install.crt’? Can I connect local edge devices (Raspberry Pi 4) to management hub, which hosted on the Google cloud platform?

2.) I created VM with Debian 10 (buster) for edge device on the Google cloud platform. And I installed docker and required dependencies by Agent. Also, I added firewall rules for ports on the VM Ubuntu 18.04.6 LTS (management hub on the GCP).

Path (Advanced manual agent installation and registration)

Firstly, I had got the agent (horizon-agent-linux-deb-amd64.tar.gz). After that, installed the Horizon Debian packages which I got (horizon-cli and horizon).

apt update && apt install ./horizon.deb

After that I did this (with my URL to management hub on GCP):

sed -i.bak -e "s|^HZN_EXCHANGE_URL=[^ ]|HZN_EXCHANGE_URL=${HZN_EXCHANGE_URL}|g" -e "s|^HZN_FSS_CSSURL=[^ ]|HZN_FSS_CSSURL=${HZN_FSS_CSSURL}|g" /etc/default/horizon

But I don’t know where I should take ‘agent-install.crt’ for next step:

if grep -qE '^HZN_MGMT_HUB_CERT_PATH=' /etc/default/horizon; then sed -i.bak -e "s|^HZN_MGMT_HUB_CERT_PATH=[^ ]*|HZN_MGMT_HUB_CERT_PATH=${PWD}/agent-install.crt|" /etc/default/horizon; else echo "HZN_MGMT_HUB_CERT_PATH=${PWD}/agent-install.crt" >> /etc/default/horizon; fi

TParashchuk commented 2 years ago

My little guide, how I solved my issues)

Docker Raspberry PI 4 or VM

curl -fsSL https://get.docker.com -o get-docker.sh
 sudo sh get-docker.sh

Install required dependencies by Agent.

sudo apt-get install jq

sudo -s -E

export HZN_ORG_ID=<org>
export HZN_EXCHANGE_USER_AUTH=<user>:<api-key>

For edge devices on the GCP:

export HZN_EXCHANGE_URL=http://<INTERNAL IP>:3090/v1/
export HZN_FSS_CSSURL=http://<INTERNAL IP>:9443/

For edge devices Raspberry Pi 4 (local), but you need open ports (below) in the console of firewall on GCP:

export HZN_EXCHANGE_URL=http://<External IP>:3090/v1/
export HZN_FSS_CSSURL=http://<External IP>:9443/

Run agent-install.sh to get the necessary files from CSS (Cloud Sync Service), install and configure the Horizon agent, and register your edge device to run the helloworld sample edge service: curl -sSL https://github.com/open-horizon/anax/releases/latest/download/agent-install.sh | bash -s -- -i anax: -k css: -c css: -p IBM/pattern-ibm.helloworld -w '*' -T 120

View the helloworld output: hzn service log -f ibm.helloworld

Checking: hzn exchange node list

Some helping links: