MultiCloud Classroom notes 11/mar/2026

Follow class recording to create vmss

Task:

  1. create VM and install apache tomcat 10 (check status tomcat)
  2. create image with name apache-tomcat , 10.0.0 version delete vm
  3. vmss creation:
    • image : apache-tomcat
    • security rules:
      • 8080
      • 22
      • 443
    • create loadbalancer
    • enable auto scaling
      • min 2 vms
      • max 3 vms
    • create rule for autoscalling ref

ref

#!/bin/bash

# Update system packages
sudo apt update -y

# Install Java (Tomcat requires Java)
sudo apt install -y default-jdk

# Set Tomcat version
TOMCAT_VERSION=10.1.52
TOMCAT_DIR=/opt/tomcat

# Download Tomcat
wget https://dlcdn.apache.org/tomcat/tomcat-10/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz -P /tmp
# Create Tomcat directory
sudo mkdir -p $TOMCAT_DIR

# Extract Tomcat
sudo tar -xvzf /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz -C $TOMCAT_DIR --strip-components=1

# Set permissions
sudo chown -R $USER:$USER $TOMCAT_DIR
sudo chmod +x $TOMCAT_DIR/bin/*.sh

# Create systemd service file
sudo tee /etc/systemd/system/tomcat.service > /dev/null <<EOF
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
Environment=CATALINA_PID=$TOMCAT_DIR/temp/tomcat.pid
Environment=CATALINA_HOME=$TOMCAT_DIR
Environment=CATALINA_BASE=$TOMCAT_DIR
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=$TOMCAT_DIR/bin/startup.sh
ExecStop=$TOMCAT_DIR/bin/shutdown.sh

User=$USER
Group=$USER
Restart=always

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd and enable Tomcat
sudo systemctl daemon-reload
sudo systemctl enable tomcat
sudo systemctl start tomcat

# Print status
sudo systemctl status tomcat --no-pager
echo "Tomcat installation completed. Access it at http://localhost:8080"

test VMSS by execute below cmds


#!/bin/bash

sudo apt update && sudo apt install stress -y 

while true; do
  stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 60s -v
  sleep 30s
done

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube