Skip to content

Commit

Permalink
test uodate
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Reynolds committed Apr 29, 2024
1 parent 3cc591b commit 22cf752
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 9 deletions.
18 changes: 9 additions & 9 deletions labapp/app/markdown/lb.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ Build an origin pool and load balancer based on the following criteria:


<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckDefault">
The URL for the cloud app hosted in AWS is <a href="https://aws-cloud-app.mcn-lab.f5demos.com">https://aws-cloud-app.mcn-lab.f5demos.com</a>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckCDefault">
The cloud app is only reachable from the "student-awsnet" site.
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckCDefault">
The cloud app is TLS enabled.
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckCDefault">
Use the wildcard cert provided in the shared NS, "mcn-lab-wildcard", to enable TLS on the LB.
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckCDefault">
The load balancer should only be advertised from your CE in UDF. Do not advertise this service on the Internet.
The load balancer should only be advertised from your CE in UDF. <b>Do not advertise this service on the Internet.</b>
</label>
</div>

Expand Down Expand Up @@ -118,19 +118,19 @@ For the second exercise, make the cloud application running in Azure available t
Create a new origin pool for the Azure cloud app. Reuse your load balancer.

<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckDefault">
The URL for the cloud app hosted in Azure is <a href="https://azure-cloud-app.mcn-lab.f5demos.com">https://aws-cloud-app.mcn-lab.f5demos.com</a>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckCDefault">
The cloud app is only reachable from the "student-azurenet" site.
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" checked>
<label class="form-check-label" for="flexCheckCDefault">
The cloud app is TLS enabled.
</label>
Expand Down
74 changes: 74 additions & 0 deletions labapp/labapp_installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Update apt
sudo DEBIAN_FRONTEND=noninteractive apt-get update --yes

# Check if Docker is installed, install it if it's not
if ! command -v pip &> /dev/null
then
echo "Docker could not be found, installing..."
sudo apt-get install -y python3-pip
fi

# Variable Declarations
IMAGE=ghcr.io/f5devcentral/f5xc-lab-mcn-practical/labapp:latest
SERVICE=mcn-practical-labapp.service
APPDIR=/opt/mcn-practical-labapp/app
SCRIPTDIR=/opt/mcn-practical-labapp/script
REPO_URL=https://github.com/f5devcentral/f5xc-lab-mcn-practical.git
BRANCH=dev

# Create directories
mkdir -p $SCRIPTDIR
mkdir -p $APPDIR

# Create the start_labapp.sh script
cat <<EOF >$SCRIPTDIR/start_app.sh
#!/bin/bash
if [ ! -d "$APPDIR/..git" ]; then
git clone -b $BRANCH $REPO_URL $APPDIR
else
# Discard any local changes (including untracked files)
cd $APPDIR
git checkout $BRANCH
git reset --hard origin/$BRANCH
git clean -fdx
# Pull the latest code from the specified branch
git pull origin $BRANCH
fi
# Install required Python packages
cd $APPDIR/labapp/app
pip install -r requirements.txt
# Start the Gunicorn server
gunicorn --workers 4 --bind 0.0.0.0:1337 app:app
EOF

# Make the script executable
chmod +x $SCRIPTDIR/start_app.sh

# Create systemd service file
cat <<EOF >/etc/systemd/system/$SERVICE
[Unit]
Description=MCN Practical Lab App
After=network.target
[Service]
WorkingDirectory=$APPDIR
ExecStart=/bin/bash $SCRIPTDIR/start_app.sh
Restart=always
[Install]
WantedBy=multi-user.target
EOF

# Reload systemd, enable and start the service
systemctl daemon-reload
systemctl enable $SERVICE
systemctl start $SERVICE

echo "$SERVICE has been installed and started as a systemd service."

0 comments on commit 22cf752

Please sign in to comment.