Versions Compared

Key

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

...

                                                        Others

Prepare for building

...

an image

...

  • The needed files can be obtained from the

...

  • TIER github repository
    • It's best to be in a new empty directory.  You can create a new one with a name you like and/or the command below will create a new child directory in your current directory named shib-idp_noVM
    • git clone https://github.internet2.edu/docker/shib-idp_noVM
  • Decide on a config type

    • Burned

      • All configuration is supplied when the image is built and is “burned” into the resulting image.  The image stands alone and has no external dependencies, but contains sensitive information in the images (like passwords, private keys, etc.).  To update the configuration, new images are built and rotated into production.  This image cannot take advantage of the IdP’s automatic configuration reloading features.

    • Mounted

      • All configuration is dynamically mounted at run-time.  The resulting image will

...

      • be dependent upon the presence of local configuration files on all docker nodes that run the container (so, as a result, the image does not stand alone).

...

      •  These types of images do not contain sensitive information.

...

      •  Further, these images are able to take advantage of the IdP’s automatic configuration reloading features.  To update the configuration, it is necessary to sync the updated file(s) to each docker node running the container (a script is provided for this).

...

      •  The script's synchronization process

...

      • requires a regular user account on all swarm nodes to

...

      • be used for syncing files.  The critical part of this is that a single public/private keypair will need to be used for this user on all nodes and the syncFilesToAllNodes.sh script will need access to the private key from this keypair (the script will only run on the manager node).

...

      •  Steps to create this user account are:

        • On Manager node(s):

          • useradd -m -d /home/swarmuser -s /bin/bash swarmuser

          • sudo -u swarmuser ssh-keygen

...

          •                    (leave password blank)

          • sudo -u swarmuser cp ~swarmuser/.ssh/id_rsa.pub ~swarmuser/.ssh/authorized_keys

          • cat ~swarmuser/.ssh/authorized_keys         (then copy/paste to worker nodes)

        • On Worker node(s):

          • useradd -m -d /home/swarmuser -s /bin/bash swarmuser

          • sudo -u swarmuser mkdir -p ~swarmuser/.ssh

          • sudo -u swarmuser chmod 700 ~swarmuser/.ssh

          • sudo -u swarmuser vi ~swarmuser/.ssh/authorized_keys        (then paste the key from above)

    • Hybrid

...

      • This type of configuration looks mostly like the ‘burned’ type detailed above, with the exception that all sensitive information, along with the most dynamic config files for the IdP, has been

...

      • removed from the built image and will instead be supplied at run-time

...

      • using docker secrets.  Therefore, these images do not contain sensitive information.

...

      •  They can use the IdP’s automatic configuration reloading

...

      • , but only if the changed configuration file was previously defined as a docket secret (and the secret had been updated in the docker swarm).  Unlike the mounted type of configuration, this config type does not require manually syncing config files to all docker nodes (or the creation of user accounts to enable

...

      • such syncing).

...

      •  For the default hybrid configuration, the following IdP files are defined as secrets:
          • idp-signing.key
          • idp-signing.crt
          • idp-encryption.key
          • idp-encryption.crt
          • keystore.jks (tomcat/SSL)
          • sealer.jks
          • sealer.kver
          • idp.properties
          • ldap.properties
          • relying-party.xml
          • attribute-filter.xml
          • attribute-resolver.xml
          • metadata-providers.xml
  • Build your config

      1. Use the configBuilder.sh script (in the files from github)

        1. After building your IdP config, this script will create a timestamped archive/zipfile with all of your config bits (including sensitive information).

        2. If you choose a ‘hybrid’ build type, then this script also creates a new child directory named ‘ConfigNoSecrets’ which contains your configuration, but with all secrets moved to a separate directory (including some of the more dynamic config files).

      2. Info you’ll need for this script:

        1. FQDN of your IdP

        2. Attribute scope value for your IdP (typically your main domain name)

        3. LDAP info

          1. LDAP URL

          2. LDAP Base DN

          3. LDAP service account DN for the IdP

          4. Password on the above account

        4. Config type (see above)

  1. BUILD your image

    (run

     

    1. Do this work from the same directory

    as above
    1. where

    the
    1. your Dockerfile is located

    )
    1. Mounted (you’ll need to transfer your built config to your manager VM if you built it elsewhere)

      1. docker build --rm -t my/shibb-idp-tier .

    2. Burned (assuming default directories generated by the configBuilder.sh script)

      1. docker build --rm -t my/shibb-idp-tier .

    3. Hybrid (you’ll need to transfer your secrets to your manager VM)

      1. The first command below establishes an alternate location for the config bits (which then gets used in the subsequent ‘docker build’ command).  The default directory referenced is produced by the configBuilder.sh script and has the secrets extracted from the main config.  This means that the resulting image will be burned with an incomplete config (some files will be missing).  That config will be completed at run-time when the predefined secrets are added by docker.

      2. export ALTCFG=ConfigNoSecrets

      3. docker build --rm -t my/shibb-idp-tier --build-arg TOMCFG=${ALTCFG}/config/tomcat \
                        --build-arg TOMLOG=${ALTCFG}/logs/tomcat \
                        --build-arg TOMCERT=${ALTCFG}/credentials/tomcat \
                        --build-arg TOMWWWROOT=${ALTCFG}/wwwroot \
                        --build-arg SHBCFG=${ALTCFG}/config/shib-idp/conf \
                        --build-arg SHBCREDS=${ALTCFG}/credentials/shib-idp \
                        --build-arg SHBVIEWS=${ALTCFG}/config/shib-idp/views \
                        --build-arg SHBEDWAPP=${ALTCFG}/config/shib-idp/edit-webapp \
                        --build-arg SHBMSGS=${ALTCFG}/config/shib-idp/messages \
                        --build-arg SHBMD=${ALTCFG}/config/shib-idp/metadata \
                        --build-arg SHBLOG=${ALTCFG}/logs/shib-idp .

  2. Tag your new image for shipping to the private repository

    1. docker tag my/shibb-idp-tier repo.training.incommon.org:5000/shib-idp-tier:<your userID>

  3. SHIP your image to the private repo for this training class (an instance of the Docker Private Repo)

    1. First, add an entry to your /etc/hosts file (on both manager and worker nodes)

      1. 172.31.10.102   repo.training.incommon.org

    2. docker login repo.training.incommon.org:5000

      1. Username: incommontrain

      2. Password: CheckWithMe

    3. docker push repo.training.incommon.org:5000/shib-idp-tier:<your userID>

  4. Start a new docker swarm with your 2 VMs

    1. If needed, set rules in firewalld on all swarm nodes (and disable selinux, if applicable)

...

    1. *For a “mounted” config type

      1. First sync config content to all swarm nodes (from Dockerfile dir)

        1. ./syncFilesToAllNodes.sh build swarm-idp-config swarmuser swarmuser

  1. RUN a new service on your swarm

    1. Burned

docker login idp.training.incommon.org:5000

...

  1. Check your new service

    1. docker service ls

    2. docker service inspect shib-idp

    3. docker service ps shib-idp

    4. docker ps       (on a node running the new service)

    5. To get a shell in one of your containers:

      1. docker exec -it <containerID> bash



Changing the configuration of an existing service

Burned

  • Update the appropriate config file in the directories setup by the configBuilder.sh script (child directories from the Dockerfile directory).  Most Shib-IdP config is in ‘config/shib-idp/conf’.

  • Re-run the same build command from step 2.b above, with the change below, to build and push a new image.

    • Modify the build command slightly (apply a tag as in ‘newBuild’ below) to ensure your new build has a unique name

  • Apply a service update to your swarm to roll in the new image

    • docker service update --update-parallelism 1 --update-delay 60s --image repo.training.incommon.org:5000/shib-idp-tier-newbuild:<your userID> shib-idp

...