Lab 1 - Container Insights (2024)

Here, in this lab, as part of Module 5: Operate and Monitor, we will look at Container Insights.

Before attempting this lab, please be sure to complete the items described in the Getting Started Section.

Container Insights

Container Insights is a feature designed to monitor the performance of container workloads deployed to the cloud. It gives you performance visibility by collecting memory and processor metrics from controllers, nodes, and containers that are available in Kubernetes through the Metrics API. After you enable monitoring from Kubernetes clusters, metrics and Container logs are automatically collected for you through a containerized version of the Log Analytics agent for Linux. Metrics are sent to the metrics database in Azure Monitor. Log data is sent to your Log Analytics workspace.

Enable Container Insights

Container Insights is designed to store its data in a Log Analytics workspace. You can let the enablement process create a Log Analytics workspace for this purpose, or if you already have a workspace, you can use that one. See Designing your Azure Monitor Logs deployment to learn more about best practices for Log Analytics.

Here, let’s begin by creating a Log Analytics workspace in order to support Container Insights. Right now, we will do this using the Azure CLI. Later, we will augment our Bicep templates in order to perform this same work.

az monitor log-analytics workspace create --resource-group $resourceGroupName --workspace-name $workspaceNameWORKSPACEID=$(az monitor log-analytics workspace show --resource-group $resourceGroupName --workspace-name $workspaceName --query id -o tsv)

Now, let’s augment our cluster and enable Container Insights.

az aks enable-addons -a monitoring --resource-group $resourceGroupName --name $clusterName --workspace-resource-id $WORKSPACEID

Let’s verify that the Container Insights agent and solution were successfully deployed. First, we’ll verify the daemonset was deployed:

kubectl get daemonset ama-logs --namespace=kube-system

The output should resemble the following:

NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGEama-logs 3 3 3 3 3 <none> 45m

Next, we’ll verify that the deployment was created:

The output should resemble the following:

NAME READY UP-TO-DATE AVAILABLE AGEama-logs-rs 1/1 1 1 47m

Using Container Insights

Now that Container Insights has been enabled, we can turn our attention to the Azure Portal and see the results of our labor. (It may take a few minutes for data to flow into the Log Analytics workspace.)

Within the Portal, navigate to the cluster. Once inside the cluster, check out the Monitoring section of the menu system and open the Insights tab. Here, you will be presented with a nice visualization of your cluster, showing node count, CPU, and memory utilization. You’ll also a graph showing the active pod count. These views are dynamic. You can change the time range, or even look at live data from the cluster.

Lab 1 - Container Insights (1)

Aside from the Cluster view within the Insights tab, you will find lists that desscribe your cluster’s nodes, controllers and containers. You will also find a tab dedicated to reports. These data driven reports provide additional insight into your cluster nodes, resource utilization, networking, and billing.

Now, let’s take a moment and test Container Insights by applying some load to our cluster.

First, let’s create a namespace to hold our work.

kubectl create namespace containerinsightstestkubectl config set-context --current --namespace containerinsightstest

Next, let’s run an interactive bash Pod on the cluster:

kubectl run test-shell --rm -i --tty --image ubuntu -- bash

Now, within the test-shell Pod, update, install and run stress:

apt updateapt install stressstress -c 10

The above commands will generate a sustained CPU spike in the cluster. Return to Container Insights and view the Cluster tab. Turn on Live updates and you should see the Node CPU Utilization graph jump as a result of the stress command.

Note: it may take several minutes in order for the visualization to update and show the increased utilization of your cluster.

Lab 1 - Container Insights (2)

Next, change the view by clicking on the Nodes tab. Here, you will see a summary of what’s happening inside the cluster. Notice that one of your nodes (The one running stress) should be much more busy than the others.

Lab 1 - Container Insights (3)

Find the node that appears to be the most busy in your cluster and expand its line item. Here, you will see a list of the processes running on that node. You should see our test-shell pod running stress at the top of this list.

Lab 1 - Container Insights (4)

Next, change the view by clicking on the Containers tab. Here, you will be presented with a list of containers running on the cluster. Notice that our test-shell pod is at the top of the list.

Lab 1 - Container Insights (5)

Select the test-shell container and you’ll get a description of the container.

Lab 1 - Container Insights (6)

Here, you can also see a live stream of the container console and events.

Lab 1 - Container Insights (7)

Return to test-shell and type ctrl-c to terminate stress. Then, exit the pod.

exit

Now, let’s clean our cluster:

kubectl delete namespace containerinsightstestkubectl config set-context --current --namespace default

Additional Diagnostics (Optional)

Container Insights provides excellent visibility within our Kubernetes Clusters. However, we can get even more visibility by streaming diagnostics data into the Azure Log Analytics workspace we just created. AKS offers you the ability to stream many types of diagnostic data, including log data from various sources as well as performance metrics.

Note: If you choose to implement Azure Sentinel as your centralized security monitoring solution, then this step will be done for you automatically when you add the Azure Kubernetes Service Data Connector to Sentinel. Sentinel will connect its associated Log Analytics Workspace to your cluster’s diagnostics.

Use the following CLI command to turn begin streaming select diagnostics data into Log Analytics

CLUSTERID=$(az aks show --resource-group $resourceGroupName --name $clusterName --query id -o tsv)echo '['>diag.configecho '{"category": "cluster-autoscaler", "enabled": true},'>>diag.configecho '{"category": "guard", "enabled" :true},'>>diag.configecho '{"category": "kube-apiserver", "enabled": true},'>>diag.configecho '{"category": "kube-audit", "enabled": true},'>>diag.configecho '{"category": "kube-audit-admin", "enabled": true},'>>diag.configecho '{"category": "kube-controller-manager", "enabled": true},'>>diag.configecho '{"category": "kube-scheduler", "enabled": true}'>>diag.configecho ']'>>diag.configaz monitor diagnostic-settings create \--name "diag01" \--resource "$CLUSTERID" \--workspace "$WORKSPACEID" \--logs @diag.configrm diag.config

Update Bicep Templates (Optional)

Now that we have enabled Container Insights, let’s go back and update our Bicep tempaltes in order to make sure our deployment process picks up the changes.

First, add the Log Analytics workspace to the template:

// Parameters...@description('Log Analytics Workspace name')param workspaceName string// Log Analytics Workspace Definition resource workspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = { name: workspaceName location: location}// Cluster Definition...

Next, adjust the AKS cluster and enable Container Insights:

// Inside Cluster Definition; add the following to propertiesaddonProfiles: { omsAgent: { enabled: true config: { logAnalyticsWorkspaceResourceID: workspace.id } } // ...}

Finally, add in Diagnostics at the end of the template:

resource diag01 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { name: 'diag01' scope: aks properties: { logs: [{ category: 'cluster-autoscaler' enabled: true retentionPolicy: { days: 0 enabled: false } }, { category: 'guard' enabled: true retentionPolicy: { days: 0 enabled: false } }, { category: 'kube-apiserver' enabled: true retentionPolicy: { days: 0 enabled: false } }, { category: 'kube-audit' enabled: true retentionPolicy: { days: 0 enabled: false } }, { category: 'kube-audit-admin' enabled: true retentionPolicy: { days: 0 enabled: false } }, { category: 'kube-controller-manager' enabled: true retentionPolicy: { days: 0 enabled: false } }, { category: 'kube-scheduler' enabled: true retentionPolicy: { days: 0 enabled: false } }] workspaceId: workspace.id }}

Conclusion

This completes Lab 1 - Container Insights. If you would like, you may continue by completing Lab 2 - Azure Policy for Kubernetes, Lab 3 - Defender for Containers, or return to the Introduction.

Lab 1 - Container Insights (2024)
Top Articles
Reducing Your Risk In Real Estate Investment - Disease called Debt
International Finance Assignment Help by Top-rated Tutors
Golden Abyss - Chapter 5 - Lunar_Angel
Cold Air Intake - High-flow, Roto-mold Tube - TOYOTA TACOMA V6-4.0
Chris Provost Daughter Addie
25X11X10 Atv Tires Tractor Supply
Professor Qwertyson
Unlocking the Enigmatic Tonicamille: A Journey from Small Town to Social Media Stardom
Ou Class Nav
270 West Michigan residents receive expert driver’s license restoration advice at last major Road to Restoration Clinic of the year
Rochester Ny Missed Connections
Space Engineers Projector Orientation
ATV Blue Book - Values & Used Prices
Caliber Collision Burnsville
Flower Mound Clavicle Trauma
Chile Crunch Original
H12 Weidian
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Never Give Up Quotes to Keep You Going
Titanic Soap2Day
Walmart Near South Lake Tahoe Ca
Pearson Correlation Coefficient
At&T Outage Today 2022 Map
Construction Management Jumpstart 3Rd Edition Pdf Free Download
Trivago Myrtle Beach Hotels
Bleacher Report Philadelphia Flyers
When His Eyes Opened Chapter 3123
Generator Supercenter Heartland
Funky Town Gore Cartel Video
Why Are The French So Google Feud Answers
Angela Muto Ronnie's Mom
Craigslist Ludington Michigan
Www Violationinfo Com Login New Orleans
Agematch Com Member Login
Gwu Apps
Craigslist Lakeside Az
The Syracuse Journal-Democrat from Syracuse, Nebraska
How to Draw a Sailboat: 7 Steps (with Pictures) - wikiHow
Sunrise Garden Beach Resort - Select Hurghada günstig buchen | billareisen.at
Busted Newspaper Campbell County KY Arrests
Appraisalport Com Dashboard Orders
SF bay area cars & trucks "chevrolet 50" - craigslist
Todd Gutner Salary
814-747-6702
War Room Pandemic Rumble
Hawkview Retreat Pa Cost
Ohio Road Construction Map
Mega Millions Lottery - Winning Numbers & Results
Bf273-11K-Cl
What Time Do Papa John's Pizza Close
Jasgotgass2
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6362

Rating: 4.1 / 5 (62 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.