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

Why is Kubernetes so popular?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "Why Kubernetes is so popular". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "Why Kubernetes is so popular".

Architecture based on data (YAML)

From the world of Puppet [9] and Chef [10], one of the major shifts in Kubernetes is the transition from a code-based infrastructure to a data-based infrastructure (especially YAML). All resources in Kubernetes, including Pod, configuration, deployment, volumes, etc., can be simply represented in the YAML file.

ApiVersion: v1 kind: Pod metadata: name: site labels: app: web spec: containers:-name: front-end image: nginx ports:-containerPort: 80

This representation makes it easier for DevOps or site reliability engineers to fully express their workloads without having to code in programming languages such as Python,Ruby or Javascript.

Other benefits of a data-based architecture include:

GitOps or Git Operations version control. Using this approach, you can keep all Kubernetes YAML files under the git repository, which allows you to know exactly when changes were made, by whom, and what changes were made. This avoids the need for members of the entire organization to find content that may be ambiguous, thereby improving the transparency and efficiency of the entire organization. At the same time, by merging requests, it is easier to change Kubernetes resources automatically.

Scalability. Defining a resource as YAML makes it very easy for a cluster operator to change one or two numbers in a Kubernetes resource to change the scaling behavior. Kubernetes has a horizontal Pod auto-scaler that helps you determine the minimum and maximum number of Pod that a particular deployment must be able to handle to handle low-traffic and high-traffic times. For example, if you are running a deployment that may require more capacity due to a sudden increase in traffic, you can change the maxReplicas from 10 to 20:

ApiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: myapp namespace: default spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: 1 maxReplicas: 20 metrics:-type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50

Security and control. YAML is a good way to verify what is deployed in the middle of Kubernetes and how to deploy it. For example, one of the main security issues is whether your workload is running as a non-root user. We can use tools such as conftest [11] (a YAML / JSON validator) and Open Policy Agent [12] (a policy validator) to check whether the SecurityContext [13] of your workload allows the container to run as root. To do this, users can re-register the policy using a simple open policy agent, as follows:

Package main deny [msg] {input.kind = "Deployment" not input.spec.template.spec.securityContext.runAsNonRoot = true msg = "Containers must not run as root"}

Cloud provider integration. One of the main trends in the technology industry is to run workloads in public cloud providers. With cloud provider components, Kubernetes allows each cluster to integrate with the cloud provider it is running. For example, if a user is running an application in the Kubernetes of AWS and wants to access the application through a service, the cloud provider will help automatically create a LoadBalancer service that will automatically set up the Amazon Elastic LoadBalancer to forward traffic to the application pods.

Expandability

Kubernetes has good extensibility, and developers are very satisfied with it. Built-in resources, such as Pod,Deployment,StatefulSet,Secrets,ConfigMap, etc. At the same time, users and developers can add more resources through the Custom Resource definition [14]. For example, if we want to define a CronTab resource, we can do this in the following ways:

ApiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: crontabs.my.org spec: group: my.org versions:-name: v1 served: true storage: true Schema: openAPIV3Schema: type: object properties: spec: type: object properties: cronSpec: Type: string pattern:'^ (\ d+ |\ *) (/\ d+)? (\ s + (\ *) (/\ d+)?) {4} $'replicas: type: integer minimum: 1 maximum: 10 scope: Namespaced names: plural: crontabs singular: crontab kind: CronTab shortNames:-ct

We can create the CronTab resource later with the following:

ApiVersion: "my.org/v1" kind: CronTab metadata: name: my-cron-object spec: cronSpec: "* * / 5" image: my-cron-image replicas: 5

Another form of Kubernetes extensibility is the ability of developers to write their own Operators [15]. Operator runs in a Kubernetes cluster and follows the specific process of control loop pattern [16]. The operator allows users to automatically manage CRD (custom resource definitions) by talking to Kubernetes API.

The community has several tools that allow developers to create their own Operators. One of these tools is Operator Framework [17] and its Operator SDK [18]. SDK provides a framework for developers to quickly start creating operator. For example, you can start from the command line [19] by entering the following command:

$operator-sdk new my-operator-repo github.com/myuser/my-operator

It will create the entire template for your operator, including the YAML file and Go code:

. | | _ cmd | | _ manager | _ main.go | _ go.mod | _ deploy | | _ role.yaml | | _ role_binding.yaml | | _ service_account.yaml | | _ operator.yaml | _ tools.go | _ go.sum | _ .gitignore | _ version | | _ version.go | _ Build | | _ bin | _ user_setup | _ entrypoint | | _ Dockerfile | _ pkg | | _ apis | _ apis.go | | _ controller | _ controller.go

You can then add API and similar controllers:

Operator-sdk add api--api-version=myapp.com/v1alpha1-- kind=MyAppService $operator-sdk add controller-- api-version=myapp.com/v1alpha1-- kind=MyAppService

Finally, build and push the operator to your container registry:

$operator-sdk build your.container.registry/youruser/myapp-operator

If the developer needs more control, you can modify the boilerplate code in the Go file. For example, to modify the details of the controller, they can make changes to the controller.go file.

Another project, KUDO [20], allows you to create operators using only declarative YAML files. For example, the operator for Apache Kafka will be defined as the following [21], which allows users to install a Kafka cluster on Kubernetes using the following command:

$kubectl kudo install zookeeper $kubectl kudo install kafka

Then use another command to adjust it:

$kubectl kudo install kafka--instance=my-kafka-name\-p ZOOKEEPER_URI=zk-zookeeper-0.zk-hs:2181\-p ZOOKEEPER_PATH=/my-path-p BROKER_CPUS=3000m\-p BROKER_COUNT=5-p BROKER_MEM=4096m\-p DISK_SIZE=40Gi-p MIN_INSYNC_REPLICAS=3\-p NUM_NETWORK_THREADS=10-p NUM_IO_THREADS=20

Innovation

In the past few years, Kubernetes has released a major version every three or four months, which means that there are three or four major versions every year. The number of new features introduced has not slowed down, as evidenced by more than 30 new features and changes in the latest version [22]. In addition, Kubernetes project GitHub activities show that even in these difficult times, the contribution shows no sign of slowing down.

These new features give cluster operators more flexibility when running a variety of workloads. Software engineers also like to have more controls to deploy their applications directly to a production environment.

Community

Another important aspect of Kubernetes's popularity is its strong community. First, when Kubernetes released version 1.0 in 2015, it donated to a family that had nothing to do with suppliers: Cloud Native Computing Foundation [24].

As the project progresses, there are a variety of community SIG [25] (special interest groups) for different areas of Kubernetes. They keep adding new features and making them more user-friendly.

CloudNative Foundation also organizes CloudNativeCon/KubeCon, which at the time of this writing is the largest open source activity in the world. The event, which is usually held three times a year, attracts thousands of technicians and professionals who want to improve Kubernetes and its ecosystem and take advantage of new features released every three months.

In addition, Cloud Native Foundation has a technical oversight committee [26], together with SIGs [27], to study new and existing projects of the Foundation in cloud native ecosystems [28]. Most projects help enhance the value proposition of Kubernetes.

Finally, I believe that without the conscious efforts of the community to tolerate each other and welcome any newcomers, Kubernetes will not be successful.

Thank you for your reading, the above is the content of "Why Kubernetes is so popular", after the study of this article, I believe you have a deeper understanding of why Kubernetes is so popular, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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