Saturday, May 11, 2024

CommValut API Integration commonly used APIs along with their HTTP methods and endpoints DevOps SRE Automations

  1. Authentication

    • POST /login: Authenticate and obtain an AuthToken for subsequent API requests.
  2. Jobs

    • GET /Job: Retrieve a list of jobs and their statuses.
    • GET /Job/{jobId}: Retrieve details of a specific job.
    • POST /Job: Create a new job.
    • PUT /Job/{jobId}: Modify an existing job.
    • DELETE /Job/{jobId}: Delete a job.
  3. Backups

    • GET /Backup: Retrieve a list of backups and their statuses.
    • GET /Backup/{backupId}: Retrieve details of a specific backup.
    • POST /Backup: Create a new backup.
    • PUT /Backup/{backupId}: Modify an existing backup.
    • DELETE /Backup/{backupId}: Delete a backup.
  4. Clients

    • GET /Client: Retrieve a list of clients.
    • GET /Client/{clientId}: Retrieve details of a specific client.
    • POST /Client: Add a new client.
    • PUT /Client/{clientId}: Modify an existing client.
    • DELETE /Client/{clientId}: Delete a client.
    • ID

      GET <webservice>/Client/{clientId} HTTP/1.1
      
    • Name

      GET <webservice>/Client/byName(clientName='{clientName}') HTTP/1.1
  5. Agents

    • GET /Agent: Retrieve a list of agents.
    • GET /Agent/{agentId}: Retrieve details of a specific agent.
    • POST /Agent: Add a new agent.
    • PUT /Agent/{agentId}: Modify an existing agent.
    • DELETE /Agent/{agentId}: Delete an agent.
  6. Media

    • GET /Media: Retrieve a list of media (tapes, disks, etc.).
    • GET /Media/{mediaId}: Retrieve details of a specific media.
    • POST /Media: Add a new media.
    • PUT /Media/{mediaId}: Modify an existing media.
    • DELETE /Media/{mediaId}: Delete a media.
  7. Storage Pools

    • GET /StoragePool: Retrieve a list of storage pools.
    • GET /StoragePool/{storagePoolId}: Retrieve details of a specific storage pool.
    • POST /StoragePool: Add a new storage pool.
    • PUT /StoragePool/{storagePoolId}: Modify an existing storage pool.
    • DELETE /StoragePool/{storagePoolId}: Delete a storage pool.
  8. Alerts

    • GET /Alert: Retrieve a list of alerts.
    • GET /Alert/{alertId}: Retrieve details of a specific alert.
    • POST /Alert: Add a new alert.
    • PUT /Alert/{alertId}: Modify an existing alert.
    • DELETE /Alert/{alertId}: Delete an alert.
  9. Reports

    • GET /Report: Retrieve a list of available reports.
    • POST /Report: Generate a new report.
  10. Schedules

    • GET /Schedule: Retrieve a list of schedules.
    • GET /Schedule/{scheduleId}: Retrieve details of a specific schedule.
    • POST /Schedule: Add a new schedule.
    • PUT /Schedule/{scheduleId}: Modify an existing schedule.
    • DELETE /Schedule/{scheduleId}: Delete a schedule.
  11.  APIs that you can use to find cluster details:

    1. GET /commcell/entities/clients

      • This API retrieves information about all the clients registered with the CommCell environment, including cluster clients.
    2. GET /commcell/entities/clients/{clientId}

      • This API retrieves detailed information about a specific client, including cluster clients, based on the provided clientId.
    3. GET /commcell/entities/virtualservers

      • This API retrieves information about all the virtual servers configured in the CommCell environment, which can include cluster nodes.
    4. GET /commcell/entities/virtualservers/{virtualServerId}

      • This API retrieves detailed information about a specific virtual server, which can be a cluster node, based on the provided virtualServerId.
    5. GET /commcell/entities/mediaagents

      • This API retrieves information about all the media agents configured in the CommCell environment, which can include cluster nodes acting as media agents.
    6. GET /commcell/entities/mediaagents/{mediaAgentId}

      • This API retrieves detailed information about a specific media agent, which can be a cluster node, based on the provided mediaAgentId.
    7. GET /commcell/entities/commservers

      • This API retrieves information about all the CommServers configured in the CommCell environment, which can include cluster nodes acting as CommServers.
    8. GET /commcell/entities/commservers/{commServerId}

      • This API retrieves detailed information about a specific CommServer, which can be a cluster node, based on the provided commServerId.

Please note that the actual endpoint URLs and request/response formats may vary depending on the CommVault version and configuration. It's recommended to refer to the official CommVault documentation or API reference for the most up-to-date and accurate information.



  1. After the authentication request, we check the status code of the response. If it's 200 (OK), we proceed with the API requests. Otherwise, we print an error message with the status code.
  2. For the agent jobs API request, we check the status code of the response. If it's 200 (OK), we process the response data. Otherwise, we print an error message with the status code.
  3. For the backups API request, we check the status code of the response. If it's 200 (OK), we process the response data. Otherwise, we print an error message with the status code.

By checking the status codes, we can handle different error scenarios and provide more informative error messages if something goes wrong with the API requests.


=============================================

import requests
import json

# CommVault API endpoint and credentials
api_endpoint = "https://commvault.example.com/webconsole/api"
username = "your_username"
password = "your_password"

# Authentication
auth_url = f"{api_endpoint}/login"
auth_payload = {
    "username": username,
    "password": password
}
auth_response = requests.post(auth_url, json=auth_payload, verify=False)
auth_token = auth_response.headers.get("AuthToken")

# Set headers for subsequent API requests
headers = {
    "AuthToken": auth_token,
    "Content-Type": "application/json"
}

# Monitor agent jobs
agent_jobs_url = f"{api_endpoint}/Job"
agent_jobs_response = requests.get(agent_jobs_url, headers=headers, verify=False)
agent_jobs_data = agent_jobs_response.json()

for job in agent_jobs_data["jobSummariesValue"]:
    job_id = job["jobId"]
    job_status = job["jobStatus"]["status"]
    if job_status == "failed" or job_status == "stopped":
        print(f"Job {job_id} is {job_status}")

# Monitor backups
backups_url = f"{api_endpoint}/Backup"
backups_response = requests.get(backups_url, headers=headers, verify=False)
backups_data = backups_response.json()

for backup in backups_data["backupSummariesValue"]:
    backup_id = backup["backupId"]
    backup_status = backup["backupStatus"]["status"]
    if backup_status == "failed" or backup_status == "stopped":
        print(f"Backup {backup_id} is {backup_status}")

Here's how the code works:

  1. First, we define the CommVault API endpoint and provide our username and password for authentication.
  2. We send a POST request to the /login endpoint to obtain an authentication token.
  3. We set the AuthToken and Content-Type headers for subsequent API requests.
  4. To monitor agent jobs, we send a GET request to the /Job endpoint and iterate through the jobSummariesValue list in the response. If a job has a status of "failed" or "stopped", we print a message with the job ID and status.
  5. To monitor backups, we send a GET request to the /Backup endpoint and iterate through the backupSummariesValue list in the response. If a backup has a status of "failed" or "stopped", we print a message with the backup ID and status.

Note that you'll need to replace "your_username" and "your_password" with your actual CommVault credentials, and "https://commvault.example.com/webconsole/api" with the correct API endpoint for your CommVault instance.

Also, make sure you have the requests library installed (pip install requests) before running this code.

In Commvault, you can use the following APIs to check job statuses:

  1. Job Manager API: This API provides endpoints to retrieve information about jobs, including their statuses. You can use endpoints like /JobManager/Job to list all jobs or filter by specific criteria such as client, agent, or job status.

  2. Client Computer Group API: If you have client computer groups set up in Commvault, you can use this API to retrieve information about them, including the status of associated jobs.

  3. Alerts API: The Alerts API allows you to query for alerts generated by Commvault, which may include alerts related to job failures or other issues.

  4. Event Viewer API: This API provides access to events generated by Commvault operations, including job-related events that can indicate success or failure.

By leveraging these APIs, you can effectively monitor job statuses and identify any failed agents or other issues within your Commvault environment.

-----------------------------------------------------------------------------------------

Ensuring the health of a Commvault environment via API involves checking various aspects such as job statuses, storage usage, client connectivity, and more. Here are several ways to do this along with examples in Python:

  1. Check Job Statuses:
    • API Endpoint: /JobManager/Job
    • Objective: Ensure backup, restore, and other jobs are completing successfully.
    • Example Code:
import requests

url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/JobManager/Job"

headers = {
    "Content-Type": "application/json",
    "Authtoken": "Your_Auth_Token"
}

response = requests.get(url, headers=headers)
jobs = response.json().get("jobs")

for job in jobs:
    print("Job ID:", job.get("jobId"))
    print("Status:", job.get("status"))
    # Add more job details as needed


  1. Check Storage Usage:
    • API Endpoint: /MediaAgent/Media
    • Objective: Ensure storage utilization is within acceptable limits.
    • Example Code:
url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/MediaAgent/Media" response = requests.get(url, headers=headers) media = response.json().get("media") for m in media: print("Media ID:", m.get("mediaId")) print("Used Capacity:", m.get("usedCapacity")) # Add more media details as needed


  1. Check Client Connectivity:
    • API Endpoint: /Client
    • Objective: Ensure clients are connected and communicating properly.
    • Example Code:
url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/Client" response = requests.get(url, headers=headers) clients = response.json().get("clients") for client in clients: print("Client Name:", client.get("clientName")) print("Status:", client.get("clientStatus")) # Add more client details as needed


  1. Check Storage Policy Usage:
    • API Endpoint: /StoragePolicy
    • Objective: Ensure storage policies are being applied correctly.
    • Example Code:
url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/StoragePolicy" response = requests.get(url, headers=headers) storage_policies = response.json().get("storagePolicies") for sp in storage_policies: print("Storage Policy Name:", sp.get("storagePolicyName")) print("Status:", sp.get("status")) # Add more storage policy details as needed

------------------------------------------------------------------------

Below are examples of how you can use different Commvault APIs to check the health of the environment across various scenarios:
  1. Event Viewer API:
    • API Endpoint: /EventViewer/Events
    • Objective: Monitor system events and errors.
    • Example Code:
url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/EventViewer/Events" response = requests.get(url, headers=headers) events = response.json().get("events") for event in events: print("Event ID:", event.get("eventId")) print("Severity:", event.get("severity")) print("Description:", event.get("description")) # Add more event details as needed


  1. Alerts API:
    • API Endpoint: /Alerts
    • Objective: Check for any active alerts in the system.
    • Example Code:
url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/Alerts" response = requests.get(url, headers=headers) alerts = response.json().get("alerts") for alert in alerts: print("Alert ID:", alert.get("alertId")) print("Severity:", alert.get("severity")) print("Description:", alert.get("description")) # Add more alert details as needed

  1. Client Computer Group API:
    • API Endpoint: /ClientGroup
    • Objective: Ensure client computers are organized into groups properly.
    • Example Code:

url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/ClientGroup" response = requests.get(url, headers=headers) client_groups = response.json().get("clientGroups") for group in client_groups: print("Group Name:", group.get("groupName")) print("Number of Clients:", group.get("numberOfClients")) # Add more group details as needed


  1. Agent API:
    • API Endpoint: /Agent
    • Objective: Check the status and health of agents installed on client computers.
    • Example Code:
url = "https://your-commvault-server:81/SearchSvc/CVWebService.svc/Agent" response = requests.get(url, headers=headers) agents = response.json().get("agents") for agent in agents: print("Agent ID:", agent.get("agentId")) print("Status:", agent.get("status")) # Add more agent details as needed

  1. Backup Recovery API:
    • API Endpoint: /JobManager/Job
    • Objective: Monitor backup and recovery jobs for success and failure.
    • Example Code: (Already provided in previous response)

These examples demonstrate how you can use Python with the requests library to query different aspects of the Commvault environment via API and ensure its health across various scenarios. Adjust the endpoints and parameters based on your specific requirements and API documentation.

=======================================

import requests # Replace with your Commvault environment details commvault_url = "https://<your_commvault_server>/webservice/" username = "<your_username>" password = "<your_password>" # Client and VM details client_name = "<client_name>" vm_name = "<vm_name>" # Define the subclient details (replace with your desired values) subclient_name = "My Subclient" backup_set_name = "DefaultBackupSet" content_type = "VMName" # Can be "VMName" or "DATASTORE" for Datastore content def get_auth_token(): """ Retrieves an authentication token from Commvault. """ url = commvault_url + "login" auth = (username, password) headers = {"Content-Type": "application/json"} response = requests.post(url, auth=auth, headers=headers) response.raise_for_status() # Raise exception for non-200 status codes return response.json()["authenticationToken"] def add_subclient(): """ Adds a subclient to the specified client VM. """ auth_token = get_auth_token() headers = { "Authorization": f"AuthToken {auth_token}", "Content-Type": "application/xml" # Body format for add subclient } # Prepare the XML request body (replace with your specific content details) body = f""" <subclient> <appName>Virtual Server</appName> <subClientEntity> <subClientProperties> <clientName>{client_name}</clientName> <subClientName>{subclient_name}</subClientName> <backupsetName>{backup_set_name}</backupsetName> <instanceName>DefaultInstanceName</instanceName> <content> <vmContent> <type>{content_type}</type> <displayName>{vm_name}</displayName> </vmContent> </content> </subClientProperties> </subClientEntity> </subclient> """ url = commvault_url + "Subclient" response = requests.post(url, headers=headers, data=body) response.raise_for_status() print(f"Subclient '{subclient_name}' added successfully!") if __name__ == "__main__": add_subclient()

=============================================================

import requests import json # Commvault API credentials cv_username = "your_username" cv_password = "your_password" cv_domain = "your_domain" # e.g., "cv" # Commvault API base URL cv_base_url = "https://your_commvault_server/webconsole/api" # Authentication endpoint auth_endpoint = f"{cv_base_url}/login" # Authenticate and get the session ID auth_payload = { "domain": cv_domain, "login": cv_username, "password": cv_password } auth_response = requests.post(auth_endpoint, json=auth_payload, verify=False) session_id = auth_response.headers.get("Set-Cookie").split(";")[0] # Set headers for subsequent API requests headers = { "Cookie": session_id, "Content-Type": "application/json", "Accept": "application/json" } # Client VM details client_name = "your_client_vm_name" client_id = "your_client_vm_id" # You can get this from the Commvault console or API # Subclient details subclient_name = "your_subclient_name" subclient_type = "your_subclient_type" # e.g., "Virtual Server" backup_set_name = "your_backup_set_name" content_path = "your_content_path" # e.g., "/" # Endpoint to add a subclient add_subclient_endpoint = f"{cv_base_url}/Client/{client_id}/Subclient" # Payload for adding a subclient add_subclient_payload = { "subClientProperties": { "clientName": client_name, "subclientName": subclient_name, "subclientType": subclient_type, "backupSetName": backup_set_name, "contentPath": { "path": [ content_path ] } } } # Send the request to add the subclient add_subclient_response = requests.post(add_subclient_endpoint, headers=headers, json=add_subclient_payload, verify=False) # Check the response status code if add_subclient_response.status_code == 200: print("Subclient added successfully.") else: print(f"Failed to add subclient. Error: {add_subclient_response.text}")

===========================================================
import requests
import json

# Replace with your Commvault server details and credentials
commvault_base_url = 'http://your-commvault-server:port'
username = 'your_username'
password = 'your_password'
client_name = 'your_client_vm_name'
backupset_name = 'your_backupset_name'  # Typically 'defaultBackupSet'
subclient_name = 'your_subclient_name'
content_path = 'path_to_include_in_subclient'  # The path to include in the subclient

# Step 1: Authenticate and get the token
auth_url = f'{commvault_base_url}/webconsole/api/Login'
auth_payload = {
    'username': username,
    'password': password
}
response = requests.post(auth_url, json=auth_payload)
if response.status_code != 200:
    raise Exception(f"Authentication failed: {response.text}")

token = response.json()['token']

# Step 2: Get client ID
clients_url = f'{commvault_base_url}/webconsole/api/Client'
headers = {
    'Authtoken': token,
    'Accept': 'application/json'
}
response = requests.get(clients_url, headers=headers)
if response.status_code != 200:
    raise Exception(f"Failed to retrieve clients: {response.text}")

clients = response.json()['clients']
client_id = next((client['clientId'] for client in clients if client['clientName'] == client_name), None)
if not client_id:
    raise Exception(f"Client VM '{client_name}' not found")

# Step 3: Get the backupset ID
backupsets_url = f'{commvault_base_url}/webconsole/api/Client/{client_id}/Backupset'
response = requests.get(backupsets_url, headers=headers)
if response.status_code != 200:
    raise Exception(f"Failed to retrieve backupsets: {response.text}")

backupsets = response.json()['backupsets']
backupset_id = next((backupset['backupsetId'] for backupset in backupsets if backupset['backupsetName'] == backupset_name), None)
if not backupset_id:
    raise Exception(f"Backupset '{backupset_name}' not found for client '{client_name}'")

# Step 4: Add the subclient
subclients_url = f'{commvault_base_url}/webconsole/api/Backupset/{backupset_id}/Subclient'
subclient_payload = {
    'subClientProperties': {
        'subClientEntity': {
            'subclientName': subclient_name
        },
        'contentOperationType': 1,
        'content': [{
            'path': content_path
        }]
    }
}
response = requests.post(subclients_url, headers=headers, json=subclient_payload)
if response.status_code != 200:
    raise Exception(f"Failed to add subclient: {response.text}")

print(f"Subclient '{subclient_name}' added successfully to client '{client_name}'")

Monday, May 6, 2024

Google Cloud Certified Associate Cloud Engineer Study Guide GCP Beginners With Questions Answer and Explanations with hands labs step by step dumps DevOps DevSecOps SRE


https://www.linkedin.com/pulse/google-cloud-certified-associate-engineer-study-guide-tt1gc
Putty Automation

Chapter 1: Overview of Google Cloud Platform  

- Introduction to GCP services: compute, storage, networking, and specialized services like machine learning products.

- Comparison between cloud computing and on-premise computing.

Review Questions GCP Dump 1

Types of Cloud Services : 

Compute Resources : Virtual Machines (VMs): Managed Kubernetes Clusters: Serverless Computing: App Engine : Cloud Functions 

Google-cloud-gcp-storage-public-clouds-types-services

Google-cloud-networking-overview

Chapter 2: Google Cloud Computing Services  

Review Questions and Answers

Overview of infrastructure services: computing, storage, and networking.

storage-components-google-cloud-platform-gcp-exam-job

Gcp-projects-service-accounts-and Billing Q &A

- Introduction to identity management and related services.

- DevOps topics and tools for deploying and monitoring applications.

- Introduction to specialized services like machine learning.

- Explanation of Google Cloud’s organizational structure, regions, and zones.

- Discussion on Cloud Launcher for deploying packaged applications.


Chapter 3: Projects, Service Accounts, and Billing  

- Organizing resources into organizations, folders, and projects.

- Enabling APIs for projects and managing user access controls.

- Creating billing accounts, linking them to projects, and managing costs with budgets and alerts.

- Setting up Stackdriver accounts for monitoring.


Chapter 4: Introduction to Computing in Google Cloud  

Introduction-computing-google-cloud

gcp-preemptible-virtual-machines-vms-custom-machine-o2qmc

gcp-introduction-computing-google-cloud

- Overview of computing options: Compute Engine, App Engine, containers, Kubernetes Engine, Cloud Functions, and Firebase.

- Details on each computing option and their use cases.


Chapter 5: Computing with Compute Engine Virtual Machines  

- Configuring VMs, selecting CPU, memory, and storage options.

- Using GCP Console, Cloud Shell, and command-line interface to work with VMs.

- Enabling network access to VMs.

- Model Questions

Chapter 6: Managing Virtual Machines  

- Managing single instances and groups of VMs.

- Overview of instance groups,

- managed vs. unmanaged, and preemptible instances.

- Q & A for managing VMs effectively.


Chapter 7: Computing with Kubernetes  

- Introduction to Kubernetes Engine.

- Basics of containers, container orchestration, and Kubernetes architecture.

- Monitoring a Kubernetes cluster with Stackdriver.

- Deploying a Kubernetes cluster and applications.


Chapter 8: Managing Kubernetes Clusters  

- Viewing cluster status, managing nodes, pods, and services.

- Management operations using GCP Console, Cloud Shell, and SDK.

- Best practices for managing Kubernetes clusters.


Chapter 9: Computing with App Engine  

- Overview of App Engine components and configuration.

- Traffic splitting and autoscaling in App Engine.


Chapter 10: Computing with Cloud Functions  

- Introduction to Cloud Functions for event-driven serverless computations.

- Use cases and integration with Pub/Sub and Cloud Storage.

- Monitoring Cloud Function executions with Stackdriver.


Chapter 11: Planning Storage in the Cloud  

- Characteristics of storage systems and cost-benefit trade-offs.

- Overview of GCP storage options and guidance for choosing a data store.


Chapter 12: Deploying Storage in Google Cloud Platform  

- Creating databases in various GCP storage systems.

- Overview of Cloud Pub/Sub and Cloud Dataproc.

- Guidance on choosing a data store.


Chapter 13: Loading Data into Storage  

- Methods for loading data into various GCP storage services.

- Common data loading patterns.


Chapter 14: Networking in the Cloud: Virtual Private Clouds and Virtual Private Networks  

- Introduction to basic networking concepts.

- Creating and managing VPCs, VPNs, and load balancers.


Chapter 15: Networking in the Cloud: DNS, Load Balancing, and IP Addressing  

- Network management tasks using Cloud Console, Cloud Shell, and Cloud SDK.


Chapter 16: Deploying Applications with Cloud Launcher and Deployment Manager  

- Introduction to Cloud Launcher and Deployment Manager.

- Deploying applications and automating deployment with templates.


Chapter 17: Configuring Access and Security  

- Identity management, roles, and service accounts.

- Viewing audit logs and guidelines for configuring access control security.


Chapter 18: Monitoring, Logging, and Cost Estimating  

- Overview of Stackdriver services for monitoring, logging, and debugging.

- Using Pricing Calculator for estimating costs in GCP.



--


47

gcloud command structure - Playing with Services

gcloud GROUP SUBGROUP ACTION

⁃ GROUP -config or compute or container or dataflow or functions or iam or ..

○ Which service group are you playing with?

SUBGROUP - instances or images or instance-templates or machine-types or regions or zones

○ Which sub group of the service do you want to play with?

ACTION - create or list or start or stop or describe or

...

○ What do you want to do?

Examples:    https://cloud.google.com/sdk/gcloud/reference/compute/instances/create

gcloud compute instances list

gcloud compute zones list

gcloud compute regions list

gcloud compute machine-types list

gcloud compute machine-types list --filter="zone:us-central1-b"

gcloud compute machine-types list --filter="zone:( us-central1-b europe-west1-d )"

-

49

-

Creating Compute Instances

gcloud compute instances create

gcloud compute instances create [NAME]

Options:

-machine-type (default type is n1-standard-1- gcloud compute machine-types list)

--custom-cpu --custom-memory --custom-vm-type(n1/n2) (Custom Machine)

○ -- custom-cpu 6 --custom-memory 3072MB--custom-vm-type n2

--image or --image-family or --source-snapshot or --source-instance-template or --source-machine-image (beta)

--service-account or --no-service-account

--zone=us-central1-b

--tags (List of tags - Allow network firewall rules alia and routes routes to to be be applied applied to VM instances)

-preemptiblen

--restart-on-failure(default)--no-restart-on-failure--maintenance-policy(MIGRATE(default)/TERMINATE)

--boot-disk-size, --boot-disk-type --boot-disk-auto-delete(default) --no-boot-disk-auto-delete

--deletion-protection -- no-deletion-protection(default)

-- metadata/metadata-from-file startup-script/startup-script-url

--metadata-from-file startup-script=/local/path/to/script/startup OR metadata startup-script="echo "hello world'"

shutdown-script

--network--subnet--netyork-tier (PREMIUM (default), STANDARD)

--accelerator="type=nvidia-tesla-v100,count=8"--metadata="install-nvidia-driver=True" (GPU)

-

50

-

Compute Instances - Default Region and Zone

Three Options:

Option 1 (Centralized Configuration): gcloud compute project-info add-metadata

-metadata= [google-compute-default-region=REGION | google-compute-default-zone=ZONE]

Option 2 (Local gcloud configuration): gcloud config set compute/region REGION

Option 3 (Command Specific): --zone or --region in the command

Priority: Option 3 (if exists) overrides Option 2 (if exists) overrides

Option 1

---

51

--

List and Describe commands

Typically list commands are used to list a set of resources

gcloud compute RESOURCES list

◦ gcloud compute images/regions/zones/disk-types list

gcloud compute instances/disks/snapshots list

Most list commands support a few common options

--filter="zone:VALUE"

O

○ --sort-by (NAME, ~NAME)

(https://www.googleapis.com/compute/v1/projects/windows-sql-cloud/global/images/sql-2019-3 dwohIlimages/sal-2019-web-

--uri

windows-2019-dc-v20210112)

gcloud compute images list --sort-by NAME --filter "PROJECT:(windows-cloud ubuntu-os-cloud)"

Typically describe commands are used to describe a specific resource

gcloud compute images describe ubuntu-1604-xenial- v20210203 --project ubuntu-

os-cloud

gcloud compute regions describe us-central1

---

52

--

Playing with Compute Instances - gcloud

Playing with compute instances

gcloud compute instances list/start/stop/delete/reset/describe/move

○ gcloud compute instances start example-instance

gcloud compute instances stop example-instance-1 example-instance-2

gcloud compute instances delete example-instance

○ --delete-disks=VALUE (all or data or boot)

O --keep- disks=VALUE (alld or data or boot)

gcloud compute instances move example-instance-1 --zone us-central1-b --destination-zonf

US-

central1-f

Move a VM from one zone to another

---

53

---

gcloud compute instances create

Creating Compute Instances

gcloud compute instances create [NAME]

Options:

-machine-type (default type is n1-standard-1- gcloud compute machine-types list)

--custom-cpu --custom-memory --custom-vm-type(n1/n2) (Custom Machine)

○ caustom-cpu 6 --custom-memory 3072MB --custom-vm-type n2

--image or --image-family or --source-snapshot or --source-instance-template or --source-machine-image (beta)

--service-account or --no-service-account

--zone=us-central1-b

--tags (List of tags - Allow network firewall rules and routes to be applied to VM instances)

-preemptible

○ --restart-on-failure(default)--no-restart-on-failure--maintenance-policy(MIGRATE(default)/TERMINATE)

--boot-disk-size, --boot-disk-type --boot-disk-auto-delete(default) --no-boot-disk-auto-delete

--deletion-protection -- no-deletion-protection(default)

--metadata/metadata-from-file startup-script/startup-script-url

--metadata-from-file startup-script=/local/path/to/script/startup OR -metadata startup-script="echo 'hello world'"

shutdown-script

--network--subnet --network-tier (PREMIUM (default), STANDARD)

--accelerator="type=nvidia-tesla-v100,count=8" --metadata="install-nvidia-driver=True" (GPU)

*****

Playing with Instance Templates

gcloud compute instance-templates create/delete/describe/list

gcloud compute instance-templates create INSTANCE-TEMPLATE

--source-instance=SOURCE_INSTANCE --source-instance-zone (Which instance to create a template

from?)

Supports almost all options supported by gcloud compute instances create [NAME]

--image or - image-family or --source-snapshot or --source-instance-template

--service-account or --no-service-account

--tags

--preemptible

-- restart-on-failure(default) --no-restart-on-failure --maintenance-policy(MIGRATE(default)/TERMINATE)

--boot-disk-size,--boot-disk-type --boot-disk-auto-delete(default)--no-boot-disk-auto-delete

--deletion-protection--no-deletion-protection(default)

◦ metadata/metadata-from-file startup-script/startup-script-url

○ --network--subnet--network-tier (PREMIUM (default), STANDARD)

--accelerator="type=nvidia-tesla-v100,count=8"--metadata="install-nvidia-driver=True" (GPU)

----

55

--------

How do you create a group of VM instances?

Instance Group - Group of VM instances managed as a single entity

○ Manage group ofsimilar VMs having similar lifecycle as ONE UNIT

Two Types of Instance Groups:

Managed:Identical VMs created using a template:

◦ Features: Auto scaling, auto healing and managed releases

Unmanaged:Different configuration for VMs in same group:

◦ Does NOT offer auto scaling, auto healing & other services

◦ NOT Recommended unless you need different kinds of VMs

Location can be Zonal or Regional

Regional gives you higher availability (RECOMMENDED)

Compute Engine

---

56

----

Managed Instance Groups (MIG)

Managed Instance Group - Identical VMs created

using an instance template

Important Features:

Maintain certain number of instances

○ If an instance crashes, MIG launches another instance

Detect application failures using health checks (Self Healing)

Increase and decrease instances based on load (Auto Scaling)

Add Load Balancer to distribute load

Create instances in multiple zones (regional MIGs)

○ Regional MIGs provide higher availability compared to zonal MIGs

Release new application versions without downtime

Rolling updates: Release new version step by step (gradually). Update a

percentage of instances to the new version at a time

◦ Canary Deployment: Test new version with a group of instances before releasing it across all instances.

Compute Engine

---

57

---

Creating Managed Instance Group (MIG)

Instance template is mandatory

Configure auto-scaling to automatically adjust number of

instances based on load:

Minimum number of instances

Maximum number of instances

Autoscaling metrics: CPU Utilization target or Load Balancer Utilization

target or Any other metric from Stack Driver

○ Cool-down period: How long to wait before looking at auto scaling metrics again?

◦ Scale In Controls: Prevent a sudden drop in no of VM instances

Example: Don't scale in by more than 10% or 3 instances in 5 minutes

Autohealing: Configure a Health check with Initial delay (How long should

you wait for your app to initialize before running a health check?)

Time for a Demo MIG

---

59

---

Updating a Managed Instance Group (MIG)

Rolling update - Gradual update of instances in an

instance group to the new instance template

Specify new template:

○ (OPTIONAL) Specify a template for canary testing

Specify how you want the update to be done:

When should the update happen?

Start the update immediately (Proactive) or hen instance roup i resized

later(Opportunistic)

How should the update happen?

○ Maximum surge: How many instances are added at any point in time?

○ Maximum unavailable: How many instances can be offline during the update?

Rolling Restart/replace: Gradual restart or replace of

all instances in the group

No change in template BUT replace/restart existing VMs

Configure Maximum surge, Maximum unavailable and What you

want to do? (Restart/Replace)

---

60

---


Thursday, May 2, 2024

Grade 6 Civic 1.3 Self identity, Special individual, Focus your attentio...



Health & Physical Education


  1. Identity and Self-Recognition:

    • Students are encouraged to understand and embrace their own identities.
    • Good qualities and characteristics help in self-recognition.
    • Examples include respect, patience, honesty, and kindness.
  2. Life Story of Dr. C.W.W. Kannangara:

    • Born in 1884, Kannangara was a prominent figure in Sri Lankan education.
    • Overcame personal challenges to excel academically and serve society.
    • Instrumental in establishing free education in Sri Lanka.
  3. Talent Development:

    • Students are urged to identify and nurture their talents.
    • Suggestions include self-awareness, confidence-building, and societal contribution.
  4. Weaknesses and Challenges:

    • Acknowledging weaknesses and working to overcome them is essential.
    • Challenges in education and life can be turned into opportunities for growth.
  5. Life Story of Senaka Bibile:

    • Facing poverty, Bibile excelled academically and became a pioneer in pharmacology.
    • Advocated for affordable pharmaceuticals, contributing significantly to public health.
  6. Opportunities in Education:

    • Schools provide platforms for skill development and character building.
    • Acquiring knowledge and fostering positive attitudes are crucial for personal growth.

Questions and Answers:

  1. Who am I?

    • What steps can you take to recognize and appreciate your own identity?
  2. Have you identified your own talents?

    • How can you develop your talents further?
  3. What actions can be taken to minimize weaknesses?

    • How can one effectively address and improve upon identified weaknesses?
  4. What challenges do students face in education and life?

    • How can challenges be transformed into opportunities for success?
  5. What opportunities does education provide for personal development?

    • How can you make the most of the resources and opportunities available in your educational journey?