Nothing Special   »   [go: up one dir, main page]

How To Connect Azure Kubernetes Cluster Using Kubectl

Connecting to an Azure Kubernetes Service (AKS) cluster is a crucial step in managing and interacting with the resources on the cluster. In this article, we will go through the process of connecting to an AKS cluster using kubectl commands with examples and the command in the console. 

Install Azure CLI

The first step is to install the Azure CLI. This tool is required to authenticate to the AKS cluster. You can install the Azure CLI by following the instructions provided by Microsoft at the following link: 

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
Install kubectlNext, we need to install kubectl, which is the command-line tool for interacting with Kubernetes clusters. You can install kubectl by following the instructions provided by Kubernetes at the following link:

Authenticate to the AKS cluster

To authenticate to the AKS cluster, you will need to run the following command, replacing "myResourceGroup" and "myAKSCluster" with the appropriate values for your cluster:

az aks get-credentials --resource-group myResourceGroup --name myAKSCluster

This command will configure kubectl to use the credentials of the AKS cluster, allowing you to interact with the cluster using kubectl commands.Verify the connection: Once you have authenticated to the AKS cluster, you can verify the connection by running the following command:

kubectl get nodes

This command will display a list of the nodes in the AKS cluster, indicating that you have successfully connected to the cluster. The output should look something like this:


Summary

I hope from the preceding step-by-step explanation you have learned how to connect to an existing Azure Kubernetes Service (AKS) cluster using kubectl commands.

How To Deploy ASP.NET Core Application On Docker Linux Container

In this article we will learn how deploy an ASP.NET core web application in a docker Linux container. Docker is the platform for deploying and building the applications which delivers the application in the packages over the operating system level virtualization. Now lets start step by step to make it understandable to everyone by explaining it in a simple language.

Step 1: Install Prerequisites
You need to install the docker desktop client based on your machine (PC) as per your operating system type. Use the following link to download the docker desktop client.
The docker desktop client features are different based on the operating system and the docker subscription plan. The installed docker desktop client looks like as follows.


I hope you installed the prerequisites.Step 2 : Create the ASP.NET Core Application
  1. Open Visual Studio (I am using 2019)
  2. Once Visual studio open then click on Continue Without Code(If you are using VS 2019)
  3. Then from Visual Studio Menu, click on File => New Project , as shown in the following image

After clicking on the New Project, the following window will appear, choose the project template ASP.NET Core Web App as shown in the following image.


After choosing the project template, click on the next button, provide the project name and storage location of the project on your PC.


After providing the required details, click on the next button, the following screen will get appeared. Provide additional information for your project such as target framework and other details. Just choose the latest .NET 5.0 and skip other details.

 
Now providing the required details, click the create button. It will create the ASP.NET Core web application and the created ASP.NET Core web application looks like as follows in your visual studio.

Step 3: Add Docker Support
Docker support can be enabled in two ways from visual studio, at the time of creating the application and after creating the application. To make it easier to make understand for beginners, in this tutorial we will enable the docker support after creating the ASP.NET core application.

Right click on the solution explorer of your existing project and follow the steps which are shown in the following image.


Once you click on the Docker Support option, it will prompt the screen which is shown in the step 4.
Step 4: Choose the Container (Docker File)
Choose the target operating system on which type of container you want to run the application, and it will create the docker image. Let's choose the Linux option which creates the image size smaller than compared to the windows container image.


In the preceding image click on the OK button, it will create the Docker file in your project solution as shown in the following image.


Step 5: Open the Docker File
Double click on docker file in which you will see auto generated code from visual studio which has pre-configured steps to create and run the docker image in multiple stages.

The visual studio creates docker file in your project which has multi-stages build features which make sure the final image remain smaller in the size which helps to become container more efficient and faster. The container images created in the following stages
  • Base 
  • Build 
  • Publish
  • Final Image

We will learn more about the base image and docker file stages in a separate article.
Step 6:  Run the image in Docker Container
Choose the docker option to run the application as shown in the following image.


After clicking on the docker option, it will build the code and creates a docker image as well as a docker container and run the application inside the docker container. The application opens in the browser as follows.


In the preceding, our application is running inside the Linux Docker container instead of IIS express. We can view the created images by using the docker command or navigating to the docker desktop dashboard. Let's view images using the docker command. Open your windows command prompt and use the following command on the command prompt and press enter.

           Docker Images

The preceding docker command will display the list of available docker images as follows.


I hope from all the above-mentioned examples you have learned how to deploy an  ASP.NET Core web application in the docker Linux container.

Note

This tutorial is for the beginner, so there is no command line tool used to build, run the docker container images. This process internally after clicking on Visual Studio Run Option by choosing the Docker option does the same thing.
Summary
I hope the preceding article is useful to understand how to deploy an ASP.NET core web application on a docker Linux container.
Related articles

Deploy ASP.NET Core Application in Docker Container

In this article we will learn how deploy an ASP.NET core web application in a docker container. The intend to write this article is to make understandable to everyone by explaining in the simple language.

What is Docker?

Docker is the platform for deploying and building the applications which delivers the application in the packages over the operating system level virtualization. Docker requires the following components to run the application

  • Image 
  • Container
What is docker image?
Docker image is the set of configuration and instructions to create the docker container, an image is created during building the application based on steps defined in the docker file of your application. The docker image is the read-only file which cannot be modified once it's created, but we can delete the image from docker.
What is Container?
The Container is an independent isolated process of an operating system which has its own networking and file system to run the image or application. The container is created on the docker engine based on the image configuration.
Difference between Virtual Machine and Docker Container?
The virtual machine (Linux, ubuntu) is installed on some other operating system (windows) which shares the same lifecycle such as running and shutting at the same time. Virtual machine acts as a real PC on an actual operating system which has full features such as RAM, Hard Disk, networking etc. In this case, often virtual machines are called guest PC and the actual PC which runs the VM is called host system machine.
The container is the minimal and smaller part of a virtual machine which does not use the entire operating system as a virtual machine. The container cuts the unnecessary components of the VM and creates the isolated virtualized environment called a container, which is faster than virtual machine. The container does not require the host system as a virtual machine instead, it works on the docker engine.


The preceding diagram gives more understanding about the virtual machine and docker container.
Step 1: Install Prerequisites
You need to install the docker desktop client based on your machine (PC) as per your operating system type. Use the following link to download the docker desktop client.
The installed docker desktop client looks like as follows.


I hope you installed the prerequisites.Step 2 : Create the ASP.NET Core Application
  1. Open Visual Studio (I am using 2019)
  2. Once Visual studio open then click on Continue Without Code(If you are using VS 2019)
  3. Then from Visual Studio Menu, click on File => New Project , as shown in the following image

After clicking on the New Project, following window will get appears, Choose the project template ASP.NET Core Web App as shown in the following image


After Choosing the project template click on next button, provide the project name and storage location of the project on your PC


After providing the required details, click on next button the following screen will get appears. Provide the additional information for your project such as target framework and other details, Just choose the latest .NET 5.0 and skip other details

 
Now providing the required details, click on create button it will create the ASP.NET Core web application and created ASP.NET Core web application looks like as follows in your visual studio.

Step 3: Add Docker Support
Docker support can be enabled in two ways from visual studio, at the time of creating the application and after creating the application. To make it easier to make understand for beginners, in this tutorial we will enable the docker support after creating the ASP.NET core application.

Right click on the solution explorer of your existing project and follow the steps which are shown in the following image.


Once you click on the Docker Support option, it will prompt the screen which is shown in the step 4.
Step 4: Choose the Container (Docker File)
Choose the target operating system on which type of container you want to run the application, and it will create the docker image. Let's choose the Linux option which creates the image size smaller than compared to the windows container image.


In the preceding image click on the OK button, it will create the Docker file in your project solution as shown in the following image.


Step 5: Open the Docker File
Double click on docker file in which you will see auto generated code from visual studio which has pre-configured steps to create and run the docker image in multiple stages.

The visual studio creates docker file in your project which has multi-stages build features which make sure the final image remain smaller in the size which helps to become container more efficient and faster. The container images created in the following stages
  • Base 
  • Build 
  • Publish
  • Final Image

We will learn more about the base image and docker file stages in a separate article.
Step 6:  Run the image in Docker Container
Choose the docker option to run the application as shown in the following image.


After clicking on the docker option, it will build the code and creates a docker image as well as a docker container and run the application inside the docker container. The application opens in the browser as follows.


In the preceding, our application is running inside the Linux Docker container instead of IIS express. We can view the created images by using the docker command or navigating to the docker desktop dashboard. Let's view images using the docker command. Open your windows command prompt and use the following command on the command prompt and press enter.

           Docker Images

The preceding docker command will display the list of available docker images as follows.


I hope from all the above-mentioned examples you have learned how to deploy an  ASP.NET Core web application in the docker container.

Note

  • This tutorial is for the beginner, so there is no command line tool used to build, run the docker container images but internally after clicking on Visual Studio Run Option by choosing Docker option does the same thing
  • The intend of this tutorial is to make familiar to beginners about docker.
  • Next article we will learn how to build, run and create images using docker commands.
Summary
I hope the preceding article is useful to understand how to deploy an ASP.NET core web application in a docker container.
Related articles

Running ASP.NET Core Web Application in Docker Container

In this article we will learn how to run an ASP.NET core web application in a docker container. The intend to write this article is to clear the hype around docker and make understandable to everyone by explaining in the simple and plain language.

What is Docker?

Docker is the platform for deploying and building the applications which delivers the application in the packages over the operating system level virtualization. Docker requires the following components to run the application

  • Image 
  • Container
What is docker image?
Docker image is the set of configuration and instructions to create the docker container, an image is created during building the application based on steps defined in the docker file of your application. The docker image is the read-only file which cannot be modified once it's created, but we can delete the image from docker.
What is Container?
The Container is an independent isolated process of an operating system which has its own networking and file system to run the image or application. The container is created on the docker engine based on the image configuration.
Difference between Virtual Machine and Docker Container?
The virtual machine (Linux, ubuntu) is installed on some other operating system (windows) which shares the same lifecycle such as running and shutting at the same time. Virtual machine acts as a real PC on an actual operating system which has full features such as RAM, Hard Disk, networking etc. In this case, often virtual machines are called guest PC and the actual PC which runs the VM is called host system machine.
The container is the minimal and smaller part of a virtual machine which does not use the entire operating system as a virtual machine. The container cuts the unnecessary components of the VM and creates the isolated virtualized environment called a container, which is faster than virtual machine. The container does not require the host system as a virtual machine instead, it works on the docker engine.


The preceding diagram gives more understanding about the virtual machine and docker container.
Step 1: Install Prerequisites
You need to install the docker desktop client based on your machine (PC) as per your operating system type. Use the following link to download the docker desktop client.
The installed docker desktop client looks like as follows.


I hope you installed the prerequisites.Step 2 : Create the ASP.NET Core Application
  1. Open Visual Studio (I am using 2019)
  2. Once Visual studio open then click on Continue Without Code(If you are using VS 2019)
  3. Then from Visual Studio Menu, click on File => New Project , as shown in the following image

After clicking on the New Project, following window will get appears, Choose the project template ASP.NET Core Web App as shown in the following image


After Choosing the project template click on next button, provide the project name and storage location of the project on your PC


After providing the required details, click on next button the following screen will get appears. Provide the additional information for your project such as target framework and other details, Just choose the latest .NET 5.0 and skip other details

 
Now providing the required details, click on create button it will create the ASP.NET Core web application and created ASP.NET Core web application looks like as follows in your visual studio.

Step 3: Add Docker Support
Docker support can be enabled in two ways from visual studio, at the time of creating the application and after creating the application. To make it easier to make understand for beginners, in this tutorial we will enable the docker support after creating the ASP.NET core application.

Right click on the solution explorer of your existing project and follow the steps which are shown in the following image.


Once you click on the Docker Support option, it will prompt the screen which is shown in the step 4.
Step 4: Choose the Container (Docker File)
Choose the target operating system on which type of container you want to run the application, and it will create the docker image. Let's choose the Linux option which creates the image size smaller than compared to the windows container image.


In the preceding image click on the OK button, it will create the Docker file in your project solution as shown in the following image.


Step 5: Open the Docker File
Double click on docker file in which you will see auto generated code from visual studio which has pre-configured steps to create and run the docker image in multiple stages.

The visual studio creates docker file in your project which has multi-stages build features which make sure the final image remain smaller in the size which helps to become container more efficient and faster. The container images created in the following stages
  • Base 
  • Build 
  • Publish
  • Final Image

We will learn more about the base image and docker file stages in a separate article.
Step 6:  Run the image in Docker Container
Choose the docker option to run the application as shown in the following image.


After clicking on the docker option, it will build the code and creates a docker image as well as a docker container and run the application inside the docker container. The application opens in the browser as follows.


In the preceding, our application is running inside the Linux Docker container instead of IIS express. We can view the created images by using the docker command or navigating to the docker desktop dashboard. Let's view images using the docker command. Open your windows command prompt and use the following command on the command prompt and press enter.

           Docker Images

The preceding docker command will display the list of available docker images as follows.


I hope from all the above-mentioned examples you have learned how to run the ASp.NET Core web application inside the docker container.

Note

  • This tutorial is for the beginner, so there is no command line tool used to build, run the docker container images but internally after clicking on Visual Studio Run Option by choosing Docker option does the same thing
  • The intend of this tutorial is to make familiar to beginners about docker.
  • Next article we will learn how to build, run and create images using docker commands.
Summary
I hope the preceding article is useful to understand how to run an ASP.NET core web application in a docker container.
Related articles

Build and Run ASP.NET Core Application in Docker Container

In this article we will learn how to build and run ASP.NET core application in a docker container. The docker and containerization term is booming in the market and developer and IT professional curious to know and learn about the docker and containerization but due to lack of plain simple documentation people finds hard to understand about these terms and concepts, my intend to write this article is to clear the hype around these concepts and make understandable to everyone by explaining in the plain simple language.

Hype around the Docker Learning

Many documentation, articles and YouTube videos show lots of command line tools during building the docker application and often readers think that I need to learn these commands and due to this, they find it very difficult and complex to create the docker application but believe me you don't need all to remind and know the commands. Visual studio built in features for azure containers makes it very simple for you. You can first learn the docker concepts using the way which I am showing in this article, then once you are familiar with these terms and concepts, you can use advanced tools such as docker commands etc.

What is Docker?

Docker is the platform for deploying and building the applications which delivers the application in the packages over the operating system level virtualization. Docker requires the following components to run the application

  • Image 
  • Container
What is docker image?
Docker image is the set of configuration and instructions to create the docker container, an image is created during building the application based on steps defined in the docker file of your application. The docker image is the read-only file which cannot be modified once it's created, but we can delete the image from docker.
What is Container?
The Container is an independent isolated process of an operating system which has its own networking and file system to run the image or application. The container is created on the docker engine based on the image configuration.
What is difference between Virtual Machine and Docker Container?
The virtual machine (Linux, ubuntu) is installed on some other operating system (windows) which shares the same lifecycle such as running and shutting at the same time. Virtual machine acts as a real PC on an actual operating system which has full features such as RAM, Hard Disk, networking etc. In this case, often virtual machines are called guest PC and the actual PC which runs the VM is called host system machine.

The container is the minimal and smaller part of a virtual machine which does not use the entire operating system as a virtual machine. The container cuts the unnecessary components of the VM and creates the isolated virtualized environment called a container, which is faster than virtual machine. The container does not require the host system as a virtual machine instead, it works on the docker engine.

The preceding diagram gives more understanding about the virtual machine and docker container, now let's start building and running the ASP.NET Core application in docker step by step.
Step 1: Install Prerequisites
You need to install the docker desktop client based on your machine (PC) as per your operating system type. Use the following link to download the docker desktop client.
The installed docker desktop client looks like as follows.


I hope you installed the prerequisites.
Step 2 : Create the ASP.NET Core Application
  1. Open Visual Studio (I am using 2019)
  2. Once Visual studio open then click on continue without code(If you are using VS 2019)
  3. Then from Visual Studio Menu, click on File => New Project , as shown in the following image

After clicking on the New Project, following window will get appears, Choose the project template ASP.NET Core Web App as shown in the following image


After Choosing the project template click on next button, provide the project name and storage location of the project on your PC


After providing the required details, click on next button the following screen will get appears. Provide the additional information for your project such as target framework and other details, Just choose the latest .NET 5.0 and skip other details

 
Now providing the required details, click on create button it will create the ASP.NET Core web application and created ASP.NET Core web application looks like as follows in your visual studio.

Step 3: Add Docker Support
Docker support can be enabled in two ways from visual studio, at the time of creating the application and after creating the application. To make it easier to make understand for beginners, in this tutorial we will enable the docker support after creating the ASP.NET core application.
Right click on the solution explorer of your existing project and follow the steps which are shown in the following image.


Once you click on the Docker Support option, it will prompt the screen which is shown in the step 4.
Step 4: Choose the Container (Docker File)
Choose the target operating system on which type of container you want to run the application, and it will create the docker image. Let's choose the Linux option which creates the image size smaller than compared to the windows container image.


In the preceding image click on the OK button, it will create the Docker file in your project solution as shown in the following image.


Step 5: Open the Docker File
Double click on docker file in which you will see auto generated code from visual studio which has pre-configured steps to create and run the docker image in multiple stages.

The visual studio creates docker file in your project which has multi-stages build features which make sure the final image remain smaller in the size which helps to become container more efficient and faster. The container images created in the following stages
  • Base 
  • Build 
  • Publish
  • Final Image

We will learn more about the base image and docker file stages in a separate article.
Step 6:  Run the image in Docker Container
Choose the docker option to run the application as shown in the following image.


After clicking on the docker option, it will build code, create a docker image as well as a docker container and run the application inside the docker container without using the docker commands on the windows command prompt. The application opens the browser as follows.


In the preceding, our application is running inside the Linux Docker container instead of IIS express. We can view the created images by using the docker command or navigating to the docker desktop dashboard. Let's view images using the docker command. Open your windows command prompt and use the following command on the command prompt and press enter.

           Docker Images

The preceding docker command will display the list of available docker images as follows.


I hope from all the above-mentioned examples you have learned how to build and run the asp.net core application inside the docker container.

Note

  • This tutorial is for the beginner, so there is no command line tool used to build, run the docker container images. 
  • The intend of this tutorial is to make familiar to beginners about docker.
  • Next article we will learn how to build, run and create images using docker commands.
Summary
I hope the preceding article is useful to understand how to build and run ASP.NET core application in a docker container. You can support me by subscribing to my YouTube Channel and blog by using the following links.
Related articles

www.CodeNirvana.in

Protected by Copyscape
Copyright © Compilemode