Skip to main content
Skip table of contents

Set up high availability for Digital Access component

This article is valid for Digital Access 6.1.0 and later and Smart ID 21.10 and later.

Smart ID Digital Access component supports distributed mode to enable high availability and failover that provides powerful flexibility and scalability. With this mode, Digital Access component will switch to a redundant service once the primary one has stopped working. Thereby, not only one but several redundant services are supported. Using high availability enables systems to meet high service-level agreement (SLA) requirements.

This article describes the setup of high availability for two Digital Access components with docker swarm and running services. See also High availability architecture for Digital Access component.

  • Manager node is the node that hosts the administration service.

  • Worker node is a node that hosts other services, not running the administration service.

Prerequisites

The following prerequisites apply:

  • The following ports shall be open to traffic to and from each Docker host participating on an overlay network:

    • TCP port 2377 for cluster management communications

    • TCP and UDP port 7946 for communication among nodes

    • UDP port 4789 for overlay network traffic

  • For more details refer to: https://docs.docker.com/network/overlay/

  • Keep a note of IP addresses of nodes where access point is running.

Step-by-step instruction

Get cluster join token and stop services - manager node

  1. SSH to the node running administration service, that is, the manager node.

  2. Get the cluster join token by running this command. This token will be used for joining worker nodes to the manager node.

    Get token

    CODE
    sudo docker swarm join-token worker

    Output of the command will be like:

     docker swarm join --token SWMTKN-1-5dxny21y4oslz87lqjzz4wj2wejy6vicjtqwq33mvqqni42ki2-1gvl9xiqcrlxuxoafesxampwq 192.168.253.139:2377

Stop services

  1. Stop the running services.

    Stop services

    CODE
    sudo docker stack rm <your da stack name>

Join as worker nodes

Do these steps on all worker nodes:

  1. SSH to the worker node(s).

  2. Stop the running services.

    CODE
    sudo docker stack rm <your da stack name>
  3. Get the node ID.

    CODE
    sudo docker node ls
  4. Remove the labels for running services.

    CODE
    sudo docker node update --label-rm  da-access-point <nodeid>
    sudo docker node update --label-rm  da-authentication-service <nodeid>
    sudo docker node update --label-rm  da-distribution-service <nodeid>
    sudo docker node update --label-rm  da-policy-service <nodeid>
  5. if you are using PostgreSQL as database then remove label using this command (not to run on PostgreSQL node):

    CODE
    sudo docker node update --label-rm  postgres <nodeid>
  6. Remove the node from the current swarm.

    CODE
    sudo docker swarm leave --force
  7. Join to manager swarm using the command output from "Get cluster join token" above.

    CODE
    docker swarm join --token SWMTKN-1-5dxny21y4oslz87lqjzz4wj2wejy6vicjtqwq33mvqqni42ki2-1gvl9xiqcrlxuxoafesxampwq 192.168.253.139:2377
    
  8. On success, the output will be: This node joined a swarm as a worker.

Remove labels at manager node

  1. SSH to manager node.

  2. Remove label for all services which are not required on this node.

    Remove label

    CODE
    sudo docker node update --label-rm  da-access-point <nodeid>

Edit configuration files - Manager node

CODE
policy:
    # configure image tag from versiontag.yaml
    hostname: policy
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
         #If you need to set constraints using node name
         #- node.hostname ==<node name> 
         # use node label
         [node.labels.da-policy-service == true ]
      resources:
        limits:
          cpus: "0.50"
          memory: 512M
        reservations:
          cpus: "0.10"
          memory: 128M
    volumes:
      - /opt/nexus/config/policy-service:/etc/nexus/policy-service:z
      - /etc/localtime:/etc/localtime
      - /etc/timezone:/etc/timezone
    logging:
    options:
     max-size: 10m
policy1:
  # configure image tag from versiontag.yaml
  hostname: policy1
   deploy:
    mode: replicated
    replicas: 1
    placement:
      constraints:
      #If you need to set constraints using node name
      #- node.hostname ==<node name> 
      # use node label
      [node.labels.da-policy-service1 == true ]
    resources:
      limits:
        cpus: "0.50"
        memory: 512M
      reservations:
        cpus: "0.10"
        memory: 128M
  volumes:
    - /opt/nexus/config/policy-service:/etc/nexus/policy-service:z
    - /etc/localtime:/etc/localtime
    - /etc/timezone:/etc/timezone
  logging:
    options:
     max-size: 10m

network.yml

For each service add network configuration in the network.yml file. For example, if you want to deploy two policy services on two nodes you will have two blocks of configuration as shown below.

Example:

Change the value of:

  • Service name: Service name should be identical to what is mentioned in docker-compose.yml

CODE
policy: 
    ports: 
      - target: 4443 
        published: 4443 
        mode: host 
    networks: 
      - da-overlay 
policy1: 
  ports: 
    - target: 4443 
      published: 4443 

Also make sure all the listeners that are used for access point Load balance are exposed on network.yml.

versiontag.yml

Add one line for each service in this file also.

For example, if you have two policy services with name policy1 and policy2, you will have two lines for each service.

Example:

policy:
image: http://nexusimages.azurecr.io/smartid-digitalaccess/policy-service:6.0.5.60259
policy1:
image: http://nexusimages.azurecr.io/smartid-digitalaccess/policy-service:6.0.5.60259

At manager node

Verify and identify nodes

  1. Verify if all nodes are part of cluster by running this command.

    Verify if all nodes are part of cluster

    CODE
    sudo docker node ls 
  2. Identify nodes ID, master and worker where the service will be distributed.

    Identify nodes

    CODE
    sudo docker node inspect --format '{{ .Status }}' h9u7iiifi6sr85zyszu8xo54l
  3. Output from this command:

    {ready 192.168.86.129}

    IP address will help to identify the Digital Access node

Add new labels for each service

Add new labels for each service which you want to run in worker nodes. In this example, we have used “1” as postfix for each service name. You can choose any name based on your requirement, but make sure they are in accordance with what we have defined in constraints section in the docker-compose.yml file.

  1. Use these commands to add label for each service:

    Commands to add labels

    CODE
    sudo docker node update --label-add da-policy-service1=true <worker node ID>
    sudo docker node update --label-add da-access-point1=true <worker node ID>
  2. Deploy your stack using this command. To run the command your working directory should be docker-compose.

    Deploy DA stack

    CODE
    sudo docker stack deploy --compose-file docker-compose.yml -c network.yml -c versiontag.yml <your da stack name>

    Here: 

    • docker stack deploy is the command to deploy services as stack. 

    • compose file flag is used to provide the file name of base docker-compose file. 

    • -c is short for –compose-file flag. It is used to provide override files for docker -compose. 

    • <your da stack name> is the name of the stack. You can change it based on requirements.

Updates in Digital Access Admin

  1. Log in to Digital Access Admin and change the internal host and port for each added service according to the docker-compose.yml and network.yml files.

  2. Go to Manage System > Distribution Services and

    1. Check Listen on all interfaces in case of the ports that are to be exposed

    2. Also check Distribute key files automatically.

  3. Go to Manage System >Access Points and provide the IP address instead of the service name. Also enable the "Listen on all Interfaces" option.

Final steps

  1. Make sure all services are stopped, else remove stack using this command in the manager node:

    Remove stack

    CODE
    sudo docker stack rm <da/stack Name> 
  2. In worker node, edit service Local Configuration file, and provide values for:

    <core>      <id>6</id>    </core>

    <attribute name="mHost" type="string" value="policy1"/>

    <attribute name="mId" type="integer" value="6"/>

  3. Copy the keys from manager node to worker node services.

For access point: copy only shared key.

For all services enabled in worker node: copy internal and shared keys.

Example: Copy keys

CODE
In manager node -> copy the keys to the home directory of the worker node.
/opt/nexus/config/administration-service/keys# scp internal.key agadmin@<worker node Ip>:/home/agadmin
opt/nexus/config/administration-service/keys# scp shared.key agadmin@@<worker node Ip>:/home/agadmin
In worker node -> 
/home/agadmin# cp internal.key opt/nexus/config/policy-service/keys/
/home/agadmin# cp shared.key opt/nexus/config/policy-service/keys/
  1. Deploy your stack using this command. To run the command your working directory should be docker-compose.

    Deploy DA stack

    CODE
    sudo docker stack deploy --compose-file docker-compose.yml -c network.yml -c versiontag.yml <your da stack name>
  2. For Database connection issue, restart postgres container 

    Database connection issue

    CODE
    docker stop <postgres container ID> 

    Check connection in Digital Access Admin for IP and password provided.

Related information

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.