In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I've always wanted to learn Kubernetes because it sounds interesting (if you're Greek, you'll think the name is problematic), but I never had a chance because I didn't have anything to run in the cluster. Recently, my work began to involve things related to Kubernetes, so this time I seized the opportunity to look up the information, but then I found that all the current materials (including official tutorials) were too lengthy and irrationally structured, which made me a little frustrated at first.
After a few days of research, I began to understand the core philosophy of Kubernetes and deployed it to a production environment. Because my resume now says I'm an "Kubernetes expert," an idea immediately arises: why not show more people my broad understanding of the system and the knowledge I've spent hours of research gathering? Although I couldn't convince myself that I shouldn't write another aimless article, I soon understood:
This is the article.
The main problem I have encountered in the existing article is that before delving into the details, I can't find anything that summarizes a high-level overview of what these components are and how they fit together. And this strategically advantageous presentation is the best way for me to learn. I wrote it in this way, and I hope it suits you, too. If you know any expert-level articles / tutorials that describe how Kubernetes works and are easy to understand, please don't tell me, because you were there when I needed you, and now I've written my article and you didn't take it out early.
Also remember, I've only been studying Kubernetes for a week or so, so I won't go very deep, some of it may be inaccurate, I hope there's nothing wrong, the information here should be enough for you to run a simple cluster.
Having said that, I finally found that the concept in Kubernetes is very simple, although I'm sure there's a lot I don't know yet. But what I know is enough to build a cluster and let our applications run on it, and I'm pretty sure they're enough to let most people know how to get started.
Basic concept
The first thing we need to do is to detail the various parts of Kubernetes:
Control plane (Control plane): as the name implies, this is the part that controls everything else, and this is the part I know nothing about, because we just pay Amazon to handle this part for us. My understanding is that this is the best decision, unless you are Google, you should pay some companies to manage for you. Node (Nodes): a node is essentially a server, just like your paid physical machine worker. This is where all the code is deployed, and the way to turn a naked server into a node is to install Docker,kubelet,kube-proxy and other things on it. This article assumes that you already have some worker in your cluster. Container set (Pod): Pod is a container collection. This is where your code is located, and there is usually one Pod per container, although you may want to put some closely related services in the same Pod. Pod runs on a single node (but a node can run many Pod), which means that all containers in the Pod will have the same IP address and they can communicate with each other by connecting to each other's ports on the localhost. Pod cannot be updated after deployment and can only be deleted or replaced. Deployments: Deployment is how you actually deploy Pod to the cluster. You can run Pod without Deployment, but without Deployment, you cannot easily specify the number of copies required, automatically redeploy Pod in case of failure, roll back to an earlier state, and so on. Deployment makes code life cycle management easier, and you can use it to make Docker images run on Kubernetes. Service (Service): the service allows you to open a port from one Pod to another Pod and specify the DNS name of a Pod so that you can find and connect to other Pod in the cluster. Ingress: Ingresses is how you tell your Ingress controller (usually a web server like Traefik) what to expose to the outside world and on which path or hostname. The entry will be mapped to the Pod that will actually reply to the request. This tutorial also assumes that you have configured portals, although setting up Traefik to do this should not be very difficult (use the Deployment method when using their tutorials).
All of this can be created using the command-line kubectl, or more securely from the YAML file, which will contain the definition and details of what you want to deploy (and then execute kubectl apply-f).
In a nutshell, you put containers into pods, these pods will be created and deployed by deployment, its network will be handled by service, and ingress will be added so that the outside world can access your server.
Let's take a look at each of these sections and see what their YAML configuration looks like.
The Pod
Let's take a look at the YAML configuration of the pod that will run the Redis image in the container. Keep in mind that Pod is not persistent, so you can hardly use it directly. Instead, you will use deployment to deploy Pod indirectly, which we will describe below.
The following configuration example is for you to modify only. You just need to look at it, and then keep reading, don't stop to marvel at its beauty.
As you can see, it's very simple, you add a bunch of Kubernetes-specific things, each of which is just copy and paste, and then you declare that the configuration is Pod, give it a name, specify the container running in it and the port they listen on, please delete the whole file, you're ready!
More information about Kubernetes is available in the official Pod documentation.
The Deployment
Here is how you actually run the above Pod, even with deployment. Keep in mind that you don't need to pay attention to the above Pod configuration at all, we'll redefine it in deployment.
You will notice that this is mainly the Pod configuration above, but there are some additional configurations, such as replica, and so on. These define the name of the deployment and the number of copies we want to deploy. Changing the number of copies will deploy more of the Pod specified in the template section.
More information about Kubernetes is available in the official Deployments documentation.
The Service
Now that we have deployed a Pod, we need to expose its port to the rest of the cluster. The containerPort directive in the deployment exposes the Docker port, but does not actually forward the port on the host, so multiple Pod (not containers in the same Pod) can use the same port without collision.
To actually expose the above port to other Pod running on the cluster, we need to create a Service for it. This will create the rules required to forward the port and provide us with a DNS entry that we can use to parse the IP of that Pod.
This exposes the Redis port to other Pod in the cluster, which can be connected through my-service:6379.
To deploy more of your application, simply add another deployment and associated Service to the cluster. You can deploy the main application service in exactly the same way as the Redis above.
The Ingress
Finally, we can use Ingress to expose our services to the Internet. Here is an example of using Traefik, and although you may not actually want to expose Redis to the outside world, the same approach applies to your own applications.
The configuration in this section tells Traefik that you want all traffic on the host named redis.yourdomain.com to be forwarded to my service port 6379. As far as I know, this is just a configuration for Traefik. After applying the configuration, Pod will be exposed to the Internet through Traefik on redis.yourdomain.com.
I hope this article is useful for beginners. This article is short because the foundation of Kubernetes is short, but we managed to cover how to run the service with minimal hassle.
Now you should know what Kubernetes is!
Summary
The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.