Configure Federations

  1. Create a user with a federations role (User Admin ‣ Users ‣ ‘+’ button). This user will need the ability to:

    • Create/edit/delete federations
    • Add IPV4 resolvers
    • Add IPV6 resolvers
    ../../_images/014.png
  2. As a user with administrative privileges, create a Federation Mapping by going to Services ‣ :term:`Delivery Services –> More –> Federations` and then clicking Add Federation Mapping.

  3. Choose the Delivery Service to which the federation will be mapped and assign it to the Federation-role user; click Add.

    ../../_images/024.png
  4. After the Federation is added, Traffic Ops will display the Federation. Changes can be made at this time or the Federation can be deleted. Notice that no resolvers have been added to the Federation yet. This can only be done by the Federation-role user to whom the Federated Delivery Service was assigned. If no further action is necessary, the Close button will close the window and display the list of all Federations.

    ../../_images/034.png
  5. The federation user logs into either the Traffic Ops API or the Traffic Portal UI and stores the Mojolicious cookie. The Mojolicious cookie can be obtained manually using the debug tools on a web browser or via a command line utility like curl(1).

    #69 Example cURL Command
    curl -i -XPOST "http://localhost:3000/api/1.1/user/login" -H "Content-Type: application/json" -d '{ "u": "federation_user1", "p": "password" }'
    
    #70 Example API Response
    HTTP/1.1 200 OK
    Date: Wed, 02 Dec 2015 21:12:06 GMT
    Content-Length: 65
    Access-Control-Allow-Credentials: true
    Content-Type: application/json
    Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
    Set-Cookie: mojolicious=eyJleHBpcmVzIjoxNDQ5MTA1MTI2LCJhdXRoX2RhdGEiOiJmZWRlcmF0aW9uX3VzZXIxIn0---06b4f870d809d82a91433e92eae8320875c3e8b0; expires=Thu, 03 Dec 2015 01:12:06 GMT; path=/; HttpOnly
    Server: Mojolicious (Perl)
    Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
    Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    Connection: keep-alive
    Access-Control-Allow-Origin: http://localhost:8080
    
    {"alerts":[{"level":"success","text":"Successfully logged in."}]}
    
  6. The federation user sends a request to Traffic Ops to add IPV4 and/or IPV6 resolvers

    #71 Example cURL Command
    curl -ki -H "Cookie: mojolicious=eyJleHBpcmVzIjoxNDQ5MTA1MTI2LCJhdXRoX2RhdGEiOiJmZWRlcmF0aW9uX3VzZXIxIn0---06b4f870d809d82a91433e92eae8320875c3e8b0;" -XPUT 'http://localhost:3000/api/1.2/federations' -d '
    {"federations": [
            { "deliveryService": "images-c1",
              "mappings":
                    { "resolve4": [ "8.8.8.8/32", "8.8.4.4/32" ],
                      "resolve6": ["2001:4860:4860::8888/128", "2001:4860:4860::8844"]
                    }
            }
    ]}'
    
    #72 Example API Response
    HTTP/1.1 200 OK
    Set-Cookie: mojolicious=eyJleHBpcmVzIjoxNDQ5MTA1OTQyLCJhdXRoX2RhdGEiOiJmZWRlcmF0aW9uX3VzZXIxIn0---b42be0749415cefd1d14e1a91bb214845b4de556; expires=Thu, 03 Dec 2015 01:25:42 GMT; path=/; HttpOnly
    Server: Mojolicious (Perl)
    Date: Wed, 02 Dec 2015 21:25:42 GMT
    Content-Length: 74
    Access-Control-Allow-Credentials: true
    Content-Type: application/json
    Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
    Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    Access-Control-Allow-Origin: http://localhost:8080
    Connection: keep-alive
    Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
    
    {"response":"federation_user1 successfully created federation resolvers."}
    
  7. The resolvers added by the Federation-user will now visible in Traffic Portal.

    ../../_images/042.png

Any requests made from a client that resolves to one of the federation resolvers will now be given a CNAME Record from Traffic Router.

#73 Example DNS request (via dig)
dig @tr.kabletown.net foo.images-c1.kabletown.net
#74 Example Resolver Response
; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> @tr.kabletown.net foo.images-c1.kabletown.net
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45110
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;foo.images-c1.kabletown.net.   IN A

;; ANSWER SECTION:
foo.images-c1.kabletown.net.    30 IN CNAME img.mega-cdn.net.

;; Query time: 9 msec
;; SERVER: 10.10.10.10#53(10.10.10.10)
;; WHEN: Wed Dec  2 22:05:26 2015
;; MSG SIZE  rcvd: 84