Nutanix_Home_Lab_Mentor_12 - itnett/FTD02H-N GitHub Wiki

To set up and automate the deployment of a 3-tier Linux application using Nutanix Calm, we'll follow a step-by-step guide, covering everything from creating blueprints to launching the application. This process will include the creation and configuration of VMs, setting up services, and ensuring that dependencies between different layers of the application are correctly managed.

1. Prerequisites

  • Nutanix Cluster with AHV: Ensure your Nutanix cluster is up and running.
  • Nutanix Prism Central: Access to Prism Central is necessary to use Calm.
  • Cloud-Init Enabled Linux Image: Upload a cloud-enabled Linux distribution, like CentOS 7 Cloud Image, to Nutanix Image Service.

2. Network and Project Verification

  • Network Verification: Ensure that the virtual network is configured and that IP Address Management (IPAM) or DHCP is available.
  • Project Verification: In Prism Central, ensure your cluster is selected under the “default” project and that a local network is selected.

3. Creating a Blueprint in Calm

Blueprints are templates that define the architecture, provisioning steps, and lifecycle management of applications.

  1. Access Calm:

    • In Prism Central, navigate to Services > Calm.
    • Select Blueprints and click on + Create Blueprint > Multi VM/Pod Blueprint.
  2. Define Blueprint Information:

    • Name: Provide a name (e.g., Initials-CalmLinuxIntro).
    • Description: Use macros like @@{HAProxy.address}@@ for dynamic values.
    • Project: Select the default project.
  3. Create Credentials:

    • Credential Name: CENTOS.
    • Username: centos.
    • Secret Type: SSH Private Key.
    • Key: Use your own private key or the provided RSA private key.

4. Define Variables

Variables enable customization of blueprints and are case-sensitive.

  • User_initials: Set this to your initials (e.g., xyz).
  • Mysql_user: root.
  • Mysql_password: Set as secret, e.g., nutanix/4u.
  • Database_name: homestead.
  • INSTANCE_PUBLIC_KEY: Your public SSH key.

5. Add a Downloadable Image

  • Image Name: CentOS_7_Cloud.
  • Source URI: Use the URI for the CentOS 7 Cloud image (http://download.nutanix.com/calm/CentOS-7-x86_64-GenericCloud.qcow2).

6. Creating Services

Services represent the VMs that you will deploy and configure as part of the application.

Creating the Database Service

  1. Service Name: MySQL.
  2. OS: Linux.
  3. VM Name: @@{User_initials}@@-MYSQL-@@{calm_array_index}@@-@@{calm_time}@@.
  4. Image: CentOS_7_Cloud.
  5. vCPUs: 2, Memory: 4 GiB.
  6. Guest Customization:
    • Type: Cloud-Init.
    • Script:
      #cloud-config
      users:
        - name: centos
          ssh-authorized-keys:
            - @@{INSTANCE_PUBLIC_KEY}@@
          sudo: ['ALL=(ALL) NOPASSWD:ALL']
      
  7. Package Name: MYSQL_PACKAGE.
  8. Install Script:
    #!/bin/bash
    set -ex
    sudo yum install -y "http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm"
    sudo yum update -y
    sudo setenforce 0
    sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config
    sudo systemctl stop firewalld || true
    sudo systemctl disable firewalld || true
    sudo yum install -y mysql-community-server.x86_64
    sudo systemctl start mysqld
    sudo systemctl enable mysqld
    mysql -u root<<EOF
    UPDATE mysql.user SET Password=PASSWORD('@@{Mysql_password}@@') WHERE User='@@{Mysql_user}@@';
    DELETE FROM mysql.user WHERE User='' OR Host NOT IN ('localhost', '127.0.0.1', '::1');
    FLUSH PRIVILEGES;
    EOF
    

Creating the Web Server Service

  1. Service Name: WebServer.
  2. OS: Linux.
  3. VM Name: @@{User_initials}@@-WebServer-@@{calm_array_index}@@.
  4. Image: CentOS_7_Cloud.
  5. vCPUs: 2, Memory: 4 GiB.
  6. Guest Customization:
    • Type: Cloud-Init.
    • Script:
      #cloud-config
      users:
        - name: centos
          ssh-authorized-keys:
            - @@{INSTANCE_PUBLIC_KEY}@@
          sudo: ['ALL=(ALL) NOPASSWD:ALL']
      
  7. Package Name: WebServer_PACKAGE.
  8. Install Script:
    #!/bin/bash
    set -ex
    sudo yum install -y epel-release
    sudo yum install -y nginx php-fpm php-cli php-mcrypt php-mysql php-mbstring php-dom git unzip
    sudo systemctl enable nginx
    sudo systemctl start nginx
    sudo git clone https://github.com/ideadevice/quickstart-basic.git /var/www/laravel
    sudo sed -i 's/DB_HOST=.*/DB_HOST=@@{MySQL.address}@@/' /var/www/laravel/.env
    sudo chown -R nginx:nginx /var/www/laravel
    sudo chmod -R 777 /var/www/laravel
    sudo systemctl restart nginx
    

Creating the Load Balancer Service (HAProxy)

  1. Service Name: HAProxy.
  2. OS: Linux.
  3. VM Name: @@{User_initials}@@-HAProxy-@@{calm_array_index}@@.
  4. Image: CentOS_7_Cloud.
  5. vCPUs: 2, Memory: 4 GiB.
  6. Guest Customization:
    • Type: Cloud-Init.
    • Script:
      #cloud-config
      users:
        - name: centos
          ssh-authorized-keys:
            - @@{INSTANCE_PUBLIC_KEY}@@
          sudo: ['ALL=(ALL) NOPASSWD:ALL']
      
  7. Package Name: HAPROXY_PACKAGE.
  8. Install Script:
    #!/bin/bash
    set -ex
    sudo yum install -y haproxy
    sudo bash -c 'cat > /etc/haproxy/haproxy.cfg <<EOF
    global
        log 127.0.0.1 local0
        log 127.0.0.1 local1 notice
    defaults
        log global
        mode http
        option httplog
        option dontlognull
    frontend http
        bind *:80
        default_backend servers
    backend servers
        balance roundrobin
    EOF'
    hosts=$(echo "@@{WebServer.address}@@" | tr "," "\n")
    for host in $hosts; do
        echo "    server ${host} ${host}:80 check" | sudo tee -a /etc/haproxy/haproxy.cfg
    done
    sudo systemctl enable haproxy
    sudo systemctl start haproxy
    

7. Adding Dependencies

To ensure the correct order of service startup:

  • Create dependencies where the WebServer depends on MySQL and HAProxy depends on WebServer.

8. Launching the Application

  • From the Blueprint Editor, click Launch.
  • Monitor the application deployment through the Audit tab.
  • Once deployed, access the HAProxy IP to verify the application is functioning.

Takeaways

  • Nutanix Calm simplifies the deployment of complex, multi-tier applications.
  • The Blueprint Editor allows for easy modeling and configuration of services.
  • Calm enables repeatable and scalable deployment processes, integrating both development and infrastructure teams.

This guide automates the deployment of a LEMP stack with HAProxy load balancing using Nutanix Calm, making it easy to manage, scale, and repeat deployments.

It seems you're navigating the Nutanix Calm documentation, likely looking for detailed information on setting up, managing, or upgrading Nutanix Calm or its related services. Here's a general overview to guide you through the steps based on what you're exploring:

Nutanix Calm Overview

Nutanix Calm is an application management framework that enables you to automate the deployment and lifecycle management of applications across private, public, and hybrid cloud infrastructures. It allows users to create blueprints that encapsulate the deployment and management of multi-tier applications, making it easier to manage complex environments.

Setting Up Nutanix Calm

Before you start using Nutanix Calm, ensure that your environment is ready:

  1. Enable Calm in Prism Central:

    • Access Prism Central.
    • Navigate to Settings > Enable Calm.
    • Follow the prompts to enable Calm if it's not already active.
  2. Network and Project Verification:

    • Verify that your cluster has a virtual network configured.
    • Ensure the necessary IP address management (IPAM) or DHCP services are in place.
  3. Deploying Calm VM:

    • Calm VMs can be deployed on AHV, vSphere, or other supported hypervisors.
    • For AHV, use the Prism Central interface to deploy the Calm VM, ensuring it’s configured with a static IP if necessary.

Creating and Managing Blueprints

Blueprints are central to how Nutanix Calm operates. They define the infrastructure, deployment steps, and lifecycle management of applications.

  1. Creating a Blueprint:

    • Navigate to Calm in Prism Central.
    • Select Blueprints and click + Create Blueprint.
    • Choose between a Single-VM or Multi-VM blueprint depending on your application's architecture.
    • Define services, dependencies, and configurations for your application.
  2. Adding Services and Configurations:

    • For each service (e.g., a database or web server), define the VM specifications, guest customization using Cloud-Init, and any required software packages.
    • Use Calm's built-in macros to dynamically assign IP addresses, variables, and other configuration details.
  3. Launching the Application:

    • Once your blueprint is ready, launch it to deploy the application.
    • Calm will orchestrate the deployment, ensuring that all dependencies are respected.

Upgrading Nutanix Calm

To keep Nutanix Calm up to date, you have several options:

  1. Using Life Cycle Manager (LCM):

    • LCM allows you to upgrade Calm (and related components like Epsilon) from within Prism Central.
    • Navigate to Settings > Life Cycle Management to start the upgrade process.
  2. Calm VM Upgrades:

    • You can also upgrade the Calm VM directly via the Calm VM GUI or by SSHing into the VM and following the manual upgrade steps.
  3. Handling Upgrades at a Dark Site:

    • If your environment does not have internet access, you can perform upgrades by manually downloading the necessary files from the Nutanix portal and using a local web server to host the update files.

Further Actions and Customization

  • Automation with Runbooks: Use Calm's Runbook feature to automate tasks within your environment, beyond just application deployment.
  • Credential Management: Store and manage credentials securely within Calm, ensuring your applications and scripts have the necessary access during deployment.

Troubleshooting and Support

If you encounter issues, the Nutanix documentation and community forums are excellent resources for troubleshooting. Additionally, the Calm interface provides logging and audit trails to help diagnose problems with deployments or upgrades.


This overview should help you understand the basic steps and actions required to work with Nutanix Calm. For more detailed information, you would need to log in to the Nutanix portal or reference the specific sections of the documentation you are interested in.