Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Kubernetes in Azure

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to deploy Kubernetes in Azure. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The Azure Command Line Interface (CLI) is a Microsoft cross-platform command line experience for managing Azure resources. Azure CLI is easy to learn and is the perfect tool for building custom automation capabilities for Azure resources.

Required infrastructure

In this article, I will use the new Azure CLI. Installation is very simple, and in most cases, all you need is "pip install azure-cli". So now let's preview our cluster. First, you may need resource groups to isolate your infrastructure.

Az group create-n my-very-own-k8s-cluster-l "West Europe" next is the regulatory cluster az acs create-n my-very-own-k8s-cluster\-g my-very-own-k8s-cluster\-- dns-prefix my-very-own-k8s-cluster\-- orchestrator-type kubernetes.

While waiting for the order to be completed, let's take a look at some comments.

1. If there are some problems with your commands, such as some meaningless errors in these commands, adding the-debug parameter is a bit verbose, but there will be some errors.

2.-dnsprefix is optional, and it is recommended to add it. Otherwise, it will be used according to "cluster name + group name". If the length exceeds 90 characters, a strange error will occur during the operation.

By default, ACS sets up the cluster with a single master and three agents. These steps are set to use D2 by default, so this cluster is expensive, so remember to clean up resources when you don't need it.

And, welcome to the content under Kubernetes's ACS engine, link: https://github.com/Azure/acs-engine/blob/master/docs/kubernetes.md. The above gives some great ideas in the implementation process. Note that the ACS document does not use the new Azure tool, so it can be a bit complicated.

First payload

All the infrastructure is ready to be completed, and now begin to deploy Kubernetes. To manage the cluster, you need kubectl. You can run it automatically with the following code (you may need to add it to PATH yourself):

Az acs kubernetes install-cli

Next, you need to use the cluster to authenticate kubectl.

Az acs kubernetes get-credentials-n my-very-own-k8s-cluster\-g my-very-k8s-cluster

Check if everything is OK. This command line provides both client-side and server-side versions.

Kubectl version

From here on, you already have what you need to run your first payload. So let's create the first definition file and try to run it. The definition file within Kubernetes can use many file formats, and I use YAML, so we create the hello.yml file with the following:

ApiVersion: extension/v1beta1kind: Deploymentmetadata:name: hello # Name of the deployment, just for reference purposesspec:replica: 1 # Number of instances for the given applicationtemplate:metadata:labels:app: hellospec:containers:- name: ner-uk-ms # Name of container, could be anything you likeimage: chaliy/ner-ms:uk # Docker image to runports:-containerPort:8080

Currently, it is important to understand some Kubernetes terms.

Pod-- container instance-- http://kubernetes.io/docs/user-guide/pods/Deployment Mel-- ensures that pods is running and plays a supervisory role-- http://kubernetes.io/docs/user-guide/deployments/Service Mel-- combines pod into a system-- http://kubernetes.io/docs/user-guide/services/.

So, for a single pod defined in the template, the definition file we just created is a deployment. The following command line pulls the Docker image chaliy/ner-ms:uk, opens its instance, and sets up a supervisor:

Kubectl create-f. / hello.yml

There are very few command lines available now:

# Retrieve logs associated with deploymentkubectl logs hello# List Podskubectl get pods# List deploymentskubectl get deployments# Details about concrete pod, for example in case of errorskubectl describe pods/podid

If you want to reconfigure the application, you can modify it in the definition file, such as setting replicas:10, and then run:

Kubectl apply-f. / hello.yml

Technically, this is already running the payload. Let's take a look at how it works. The UI interface of Kubernetes presents the cluster health to users. It runs in the same way as an application. Of course, if you don't want such UI to appear outside the cluster, then by default you can only run within the cluster. But what happens if you visit?

The method is simple: Kubernetes implements the Basteon mode and proxies to your local computer in a simple way. So first you need to run the agent:

Kubectl proxy-port=8000

Then you need to see the words of Kubernetes Dashboard immediately. You can browse: http://localhost:8000/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard and you may need to publish services outside the cluster. For this, you need to create a service (for Kubernetes), and then use the expose command with the new Loadbalancer.

Kubectl expose deployment hello-type= "LoadBalancer"-port=80-target-port=8080

This command line will start setting up the new load balance, which will take some time. To check if it is running, query for information about service:

Kubectl get services/hello

After that, you will see the external IP address, which means that the service is already in the OK state, which you can use to send requests. Similar to:

Curl http://EXTERNAL-IP /

All scripts can be found on this website: https://github.com/chaliy/play-azure-kubernetes. Here you can find some real examples of using the Nginx agent as a router.

Conclusion

For me, the user experience is great, but I'm not sure I'll continue to use it, because there are several questions that still haunt me:

1. The Kubernetes ACS version is still in the pre-release stage, and some features have not yet been implemented (for example, you cannot scale down and expand your cluster).

2. The use cost is high, requiring at least 4D2 nodes, which may cost up to US $1000 per month. It's OK to use a relatively small instance, but my load type doesn't know how to take advantage of it.

3. At present, there is no device to create the system. Similar to docker-compose, it can provide related services.

This is the end of the article on "how to deploy Kubernetes in Azure". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report