Deploying PO Box on a Linux VM
Overview
Zilla PO Box is a container that simplifies integration with on-prem applications by extending into customer environments and making outbound API calls to push user and account information to Zilla. The shell script is used to manage and deploy containers for PO Box using either Podman or Docker.
This article is designed as a playbook for completing prerequisite activities, configuring and deploying the PO Box container, and setting up a cron job to restart the container with the latest released image on a daily basis.
- 1 Overview
- 2 Option 1: Zilla Client ID and Secret-based Deployment (Recommended)
- 2.1 Prerequisites
- 2.1.1 Machine Specs
- 2.1.2 Libraries
- 2.1.3 PO Box Directory
- 2.1.4 Whitelist URLs
- 2.1.5 Generate Client ID and Secret
- 2.2 Configuring and Deploying PO Box
- 2.3 Re-Configuring PO Box Deployment
- 2.4 Scheduling a cron Job
- 2.1 Prerequisites
- 3 Option 2: Zilla_API_key-based Deployment (Not Recommended)
- 3.1 Prerequisites
- 3.1.1 Machine Specs
- 3.1.2 Libraries
- 3.1.3 PO Box Directory
- 3.1.4 Whitelist URLs
- 3.2 Configuring and Deploying PO Box
- 3.3 Re-Configuring PO Box Deployment
- 3.4 Scheduling a cron Job
- 3.1 Prerequisites
- 4 Troubleshooting
Option 1: Zilla Client ID and Secret-based Deployment (Recommended)
This option comes highly recommended.
Prerequisites
Machine Specs
2vCPU
4GB RAM
25GB Disk
Libraries
Either Podman or Docker is installed to run the container
Get started and install Docker
If necessary, see this post for additional guidance on setting up Docker
jq is installed to parse the JSON response
curl is installed to make the necessary API calls
PO Box Directory
User needs to create an empty
pobox
directory. This directory will be used as a volume mount for the POBox container.mkdir pobox
Print the absolute path of the
pobox
directory using below command. Keep the directory path handy. Example -/home/user/pobox
pwd
Whitelist URLs
Customers may need to whitelist certain URLs to successfully deploy PO Box. This list includes but is not limited to:
Zilla Application URL
US East Service endpoints and Docker endpoints
Generate Client ID and Secret
To generate Client ID and Secret, see https://zilla.atlassian.net/wiki/spaces/ZILLA/pages/3651141644
Configuring and Deploying PO Box
Download the tar file on the target VM. Use below curl command to download the tar file.
curl -O https://zus-in-the-cloud-deployment.s3.us-east-1.amazonaws.com/prod/pobox-client-credentials/pobox-deployment.tar
Run the command below to extract the
pobox_deployment
directory.tar -xvf pobox-deployment.tar
Open the
pobox-deployment
directory. You will see thepobox_client_credentials.sh
shell script file.Run the command below to deploy the PO Box container.
bash pobox_client_credentials.sh
After running the pobox_client_credentials.sh
script, you are prompted for the configuration inputs.
The script asks you to input:
CONTAINER_TOOL: This is the container tool used (either Podman or Docker).
TENANT_DOMAIN: This is the domain of your tenant. To find your tenant domain, click
Settings
navigation menu in Zilla and expand theYour Domains
section. Your tenant domain is the first domain listed under that section.ZILLA_URL: This is the host URL of the Zilla server based on your tenant. Zilla has different host URLs for different tenants, including:
VOLUME_MOUNT_DIRECTORY_PATH: This is the absolute path to the
pobox
directory outlined in the PO Box Directory section above.ZILLA_CLIENT_ID: This is the Client ID generated during the prerequisite activities.
ZILLA_CLIENT_SECRET: This is the Client Secret generated during the prerequisite activities.
The configuration is saved as pobox_environment_config to your script directory.
path/where/you/have/extracted/script/ ├── pobox-environment-config
Once the PO Box deployment is complete, run one of the two commands below based on whether Podman or Docker was used to validate that it was deployed correctly.
For Podman installs, run the command below at the Linux $ prompt.podman ps
For Docker installs, run the command below at the Linux $ prompt.docker ps
The output will look similar to the below and and will show a running container with a name similar to508384223771.dkr.ecr.us-east-1.amazonaws.com/zinc:latest
.ubuntu@ip-172-26-13-73:~/pobox/pobox-deployment$ podman ps ID IMAGE COMMAND CREATED STATUS PORTS NAMES 508384223771.dkr.ecr.us-east-1.amazonaws.com/zinc:latest node app/dist/src... 7 minutes ago Up 7 minutes ago zilla_pobox
Re-Configuring PO Box Deployment
If you need to update your configuration, run the command below.
./pobox_client_credentials.sh reconfigure
Scheduling a cron Job
The next step is to set the POBox deployment as a daily cron job, which is required to restart the container with the latest released image that will be pulled-down from the container registry at http://508384223771.dkr.ecr.us-east-1.amazonaws.com/
.
Once the cron job has been set, the shell script pobox_client_credentials.sh
will initialize the config variable and execute two tasks daily:
pull_image
to pull the latest PO Box imagelaunch
to run/restart the PO Box container
Run the command below to open the crontab. If you are prompted to select a crontab editor, enter
nano
.crontab -e
In the crontab editor, run the command below replacing the
/absolute/directory/path/of/pobox-deployment
directory path with correct value.
In the example below, the script will be executed daily at 01:00 AM UTC.0 1 * * * cd /absolute/directory/path/of/pobox-deployment && bash pobox_client_credentials.sh
Option 2: Zilla_API_key-based Deployment (Not Recommended)
This option is not recommended.
Prerequisites
Machine Specs
2vCPU
4GB RAM
25GB Disk
Libraries
Either Podman or Docker is installed to run the container
Get started and install Docker
If necessary, refer to this post for additional guidance on setting up Docker
jq is installed to parse the JSON response
curl is installed to make the necessary API calls
PO Box Directory
User needs to create a PO Box directory based on the structure given below:
pobox/ ├── pobox-config/ └── pobox-output/
The
Zilla_API_Key
file has been saved under thepobox-config
directory for authenticating and managing deploymentsTo get the value for
Zilla_API_Key
via a secure credentials link, please reach out to the Zilla Customer Success Team
Whitelist URLs
Customers may need to whitelist certain URLs to successfully deploy PO Box. This list includes but is not limited to:
Zilla Application URL
US East Service endpoints and Docker endpoints
Configuring and Deploying PO Box
Download the tar file on the target VM. Use below curl command to download the tar file.
curl -O https://zus-in-the-cloud-deployment.s3.us-east-1.amazonaws.com/prod/pobox-zilla-api-key/pobox-deployment.tar
Run the command below to extract the
pobox_deployment
directory.tar -xvf pobox-deployment.tar
Open the
pobox-deployment
directory. You will see thepobox_zilla_api_key.sh
, shell script file.Run the command below to deploy the PO Box container.
bash pobox_zilla_api_key.sh
After running the pobox_zilla_api_key.sh
script, you will be prompted for the configuration inputs.
Set the values for the variables listed below.
CONTAINER_TOOL: This is the container tool used (either Podman or Docker).
TENANT_DOMAIN: This is the domain of your tenant. To find your tenant domain, click
Settings
navigation menu in Zilla and expand theYour Domains
section. Your tenant domain is the first domain listed under that section.ZILLA_URL: This is the host URL of the Zilla server based on your tenant; Zilla has different host URLs for different tenants including:
VOLUME_MOUNT_DIRECTORY_PATH: This is the absolute path to the
pobox
directory, as outlined in the PO Box Directory section above.
The configuration will be saved as pobox_environment_config to your script directory.
path/where/you/have/extracted/script/ ├── pobox-environment-config
Once the PO Box deployment is complete, run one of the two commands below based on whether Podman or Docker was used to validate that it was deployed correctly.
For Podman installs, run the command below at the Linux $ prompt.podman ps
For Docker installs, run the command below at the Linux $ prompt.docker ps
The output will look similar to the below and and will show a running container with a name similar to508384223771.dkr.ecr.us-east-1.amazonaws.com/zinc:latest
.ubuntu@ip-172-26-13-73:~/pobox/pobox-deployment$ podman ps ID IMAGE COMMAND CREATED STATUS PORTS NAMES 508384223771.dkr.ecr.us-east-1.amazonaws.com/zinc:latest node app/dist/src... 7 minutes ago Up 7 minutes ago zilla_pobox
Re-Configuring PO Box Deployment
If you need to update your configuration, run the command below.
./pobox_zilla_api_key.sh reconfigure
Scheduling a cron Job
The next step is to set the PO Box deployment as a daily cron job, which is required to restart the container with the latest released image that will be pulled-down from the container registry at http://508384223771.dkr.ecr.us-east-1.amazonaws.com/
.
Once the cron job has been set, the shell script pobox_zilla_api_key.sh
will initialize the config variable and execute two tasks daily:
pull_image
to pull the latest PO Box imagelaunch
to run/restart the PO Box container
Run the command below to open the crontab. If you are prompted to select a crontab editor, enter
nano
.crontab -e
In the crontab editor, run the command below replacing the
/absolute/directory/path/of/pobox-deployment
directory path with correct value.
In the example below, the script will be executed daily at 01:00 AM UTC.0 1 * * * cd /absolute/directory/path/of/pobox-deployment && bash pobox_zilla_api_key.sh
Troubleshooting
Access Denied Error for Zilla_API_Key
In order to run the PO Box container, the user inside the container needs to be able to access the Zilla_API_Key
file. If the owner of the mounted directory is not the same as the container’s user, the container exits with an access denied error for the Zilla_API_Key
file.
pobox/
├── pobox-config/
├──Zilla_API-Key
└── pobox-output/
Docker Solution
When working with Docker the User-Namespace-Mapping is disabled by default. The UID-GID (user ID and group ID) of the user inside the container and the UID-GID of the owner of the PO Box directory on the host machine must be the same.
Rootless Podman Solution
When working with Rootless Podman the User-Namespace-Mapping is strictly enabled. The owner on the PO Box directory must be updated to the mapped user inside the container.
SELinux Flag Solution
Z
: SELinux policies can restrict access based on labels, so theZ
flag helps to apply the correct label automatically to prevent access denials or potential security risks.U
: TheU
flag ensures that when a volume is mounted between the host and a container, the user and group IDs (UIDs and GIDs) inside the container are properly mapped to the corresponding UIDs and GIDs on the host system.