Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Install and configure a k3s edge cluster

<DAB> This looks pretty close to what's documented in OH, what are the differences? <DAB>

This content provides a summary of how to install k3s, a lightweight and small Kubernetes cluster, on Ubuntu 18.04. For more information, see the k3s documentation.

...

  1. Log in to your edge cluster as root

  2. Export your Hub exchange credentials if not already done:

    export HZN_EXCHANGE_USER_AUTH=<your-exchange-username>:<your-exchange-password>
    export HZN_ORG_ID=<your-exchange-organization>
  3. Run the following commands to export the HZN_EXCHANGE_URL, HZN_FSS_CSSURL, HZN_AGBOT_URL and HZN_SDO_SVC_URL needed to configure the agent to be able to talk to the Hub resources.

    export HZN_EXCHANGE_URL=http://$(docker network inspect hzn_horizonnet | jq -r '.[].Containers | to_entries[] | select (.value.Name == "exchange-api") | .value.IPv4Address' | cut -d'/' -f1):8080/v1
    export HZN_FSS_CSSURL=http://$(docker network inspect hzn_horizonnet | jq -r '.[].Containers | to_entries[] | select (.value.Name == "css-api") | .value.IPv4Address' | cut -d'/' -f1):9443/
    export HZN_AGBOT_URL=http://$(docker network inspect hzn_horizonnet | jq -r '.[].Containers | to_entries[] | select (.value.Name == "agbot") | .value.IPv4Address' | cut -d'/' -f1):3111
    export HZN_SDO_SVC_URL=http://$(docker network inspect hzn_horizonnet | jq -r '.[].Containers | to_entries[] | select (.value.Name == "sdo-owner-services") | .value.IPv4Address' | cut -d'/' -f1):9008/api
  4. Download the latest agent-install.sh script to your new edge cluster

    curl -sSLO https://github.com/open-horizon/anax/releases/latest/download/agent-install.sh
    chmod +x agent-install.sh
  5. The agent-install.sh script will store the Open Horizon agent in the edge cluster image registry. Set the full image path (minus the tag) that should be used.

    On k3s: <DAB> The REGISTRY_ENDPOINT var is duplicate of step already performed. </DAB>

    REGISTRY_ENDPOINT=$(kubectl get service docker-registry-service | grep docker-registry-service | awk '{print $3;}'):5000
    export IMAGE_ON_EDGE_CLUSTER_REGISTRY=$REGISTRY_ENDPOINT/openhorizon-agent/amd64_anax_k8s
    

    On microk8s:

    export IMAGE_ON_EDGE_CLUSTER_REGISTRY= localhost:32000/openhorizon-agent/amd64_anax_k8s
  6. Instruct agent-install.sh to use the default storage class:

    On k3s:

    export EDGE_CLUSTER_STORAGE_CLASS=local-path
    

    On microk8s:

    export EDGE_CLUSTER_STORAGE_CLASS=microk8s-hostpath
  7. Run agent-install.sh to get the necessary files from Github, install and configure the Horizon agent, and register your edge cluster with policy.

    Since this install guide does not enable SSL on the All-in-1 Management Hub, run the following commands to create a fake certificate and install the agent. (The install script currently requires a certificate to be present even if SSL is disabled)

    touch agent-install.crt
    ./agent-install.sh -D cluster -i 'anax:'
  8. Verify that the agent pod is running:

    kubectl get namespaces
    kubectl -n openhorizon-agent get pods
  9. Use the following command to connect to a bash instance on the agent pod to execute hzn commands

    kubectl exec -it $(kubectl get pod -l app=agent -n openhorizon-agent | grep "agent-" | cut -d " " -f1) -n openhorizon-agent – bash
  10. As a test, execute the following hzn command on the agent pod:

    hzn node ls
  11. The OpenHorizon cluster agent is now successfully installed and ready to deploy services