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.
-
Access Calm:
- In Prism Central, navigate to Services > Calm.
- Select Blueprints and click on + Create Blueprint > Multi VM/Pod Blueprint.
-
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.
- Name: Provide a name (e.g.,
-
Create Credentials:
- Credential Name:
CENTOS
. - Username:
centos
. - Secret Type:
SSH Private Key
. - Key: Use your own private key or the provided RSA private key.
- Credential Name:
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
- Service Name:
MySQL
. - OS: Linux.
- VM Name:
@@{User_initials}@@-MYSQL-@@{calm_array_index}@@-@@{calm_time}@@
. - Image:
CentOS_7_Cloud
. - vCPUs: 2, Memory: 4 GiB.
- Guest Customization:
- Type: Cloud-Init.
- Script:
#cloud-config users: - name: centos ssh-authorized-keys: - @@{INSTANCE_PUBLIC_KEY}@@ sudo: ['ALL=(ALL) NOPASSWD:ALL']
- Package Name:
MYSQL_PACKAGE
. - 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
- Service Name:
WebServer
. - OS: Linux.
- VM Name:
@@{User_initials}@@-WebServer-@@{calm_array_index}@@
. - Image:
CentOS_7_Cloud
. - vCPUs: 2, Memory: 4 GiB.
- Guest Customization:
- Type: Cloud-Init.
- Script:
#cloud-config users: - name: centos ssh-authorized-keys: - @@{INSTANCE_PUBLIC_KEY}@@ sudo: ['ALL=(ALL) NOPASSWD:ALL']
- Package Name:
WebServer_PACKAGE
. - 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)
- Service Name:
HAProxy
. - OS: Linux.
- VM Name:
@@{User_initials}@@-HAProxy-@@{calm_array_index}@@
. - Image:
CentOS_7_Cloud
. - vCPUs: 2, Memory: 4 GiB.
- Guest Customization:
- Type: Cloud-Init.
- Script:
#cloud-config users: - name: centos ssh-authorized-keys: - @@{INSTANCE_PUBLIC_KEY}@@ sudo: ['ALL=(ALL) NOPASSWD:ALL']
- Package Name:
HAPROXY_PACKAGE
. - 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:
-
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.
-
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.
-
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.
-
Creating a Blueprint:
- Navigate to
Calm
in Prism Central. - Select
Blueprints
and click+ Create Blueprint
. - Choose between a
Single-VM
orMulti-VM
blueprint depending on your application's architecture. - Define services, dependencies, and configurations for your application.
- Navigate to
-
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.
-
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:
-
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.
-
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.
-
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.