Azure Kubernetes Service/Kubernetes Tip: View POD/Container logs using kubectl

When developing and troubleshooting components deployed in Kubernetes cluster, POD logs can be viewed by running command kubectl logs {POD_NAME}

Adding -f argument will let you view stream and command is kubectl logs {POD_NAME} -f

Lastly, --previous argument will let you view logs for a previous instantiation and command is  kubectl logs {POD_NAME} --previous

The command arguments listed above are valid for viewing logs for a specific container within a POD however you will need to specify container name by adding -c argument and command is kubectl logs {POD_NAME} -c {CONTAINER_NAME}

Hope this tip helps you in troubleshooting components deployed in Kubernetes cluster.

Azure Dev Spaces – Debug Containers directly in Azure Kubernetes Service (AKS) from Visual Studio 2017

This is second part of the series on Azure Dev Spaces. The first part of this services describes steps needed to deploy Angular App and ASP.net Core Web API to AKS using Azure Dev Spaces. This article will show ease of debugging containers deployed in AKS from Visual Studio 2017.

In the first part of this series, I had created a sample ASP.net Core Web API app and deployed that to AKS using Azure Dev Spaces. The steps needed to debug ASP.net Core Web API application running in AKS are

  • Install Visual Studio Tools for Kubernetes. Once installation completes, open ‘Tools -> Extensions and Updates’ in Visual Studio and update this extension for any updates.
  • Open SampleWebApp solution in Visual Studio. The source code can be downloaded from GitHub.
  • Select Debug target as Azure Dev Spaces

  • Add a breakpoint in Get method of UsersController which we are going to debug
  • Start Debugging and select AKS cluster and Space in Azure Dev Spaces prompt
  • You can get public URL from Output window by selecting Azure Dev Spaces as displayed below
  • Open http://{URL}/api/users in browser and request will hit the breakpoint added previously

You can check the status of URL by running command azds list-uris. If URL isn’t available for more than 5 minutes you will need to delete PODS as explained in previous article. This completes this article which showed how easy it is to debug containers deployed in AKS from Visual Studio 2017 using Azure Dev Spaces.