In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the specification and state of Kubernetes object". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the specification and state of Kubernetes object".
Object specification (Spec) and state (Status)
Each Kubernetes object contains two nested object fields that control the configuration of the object: object specification (spec) and object state (status). Spec is a required field that describes the desired state of the object and the properties you want the object to have. Status describes the actual state of the object, which is provided and updated by the Kubernetes system. At any given time, the Kubernetes control panel continuously manages the actual state of the object to match the desired state you provide.
For example, Kubernetes Deployment is an object that represents an application running on a cluster. When you create a deployment, you can set the deployment specification to specify three copies of the application you want to run. The Kubernetes system reads the deployment specification and starts three instances of the desired application, updating the status to match the specification. If any of these instances fail (state change), the Kubernetes system responds to the difference between the spec and the state by correcting it in this example (starting the replacement instance).
For more information about objects spec, status, and metadata, check out the Kubernetes API convention.
Describe a Kubernetes object
When you create an object in Kubernetes, you must provide an object specification that describes its desired state, as well as some basic information about the object (such as its name). When creating an object using Kubernetes API (either directly or through kubectl), the request body of the API request must contain information in JSON format. Typically, information is provided to kubectl in a .yaml file. Kubectl converts the information to JSON when issuing an API request.
The following is an example of a .yaml file that shows the fields and object specifications required for Kubernetes deployment:
Application/deployment.yaml
ApiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2kind: Deploymentmetadata: name: nginx-deploymentspec: selector: matchLabels: nginx replicas: 2 # tells deployment to run 2 pods matching the template template: metadata: labels: app: nginx spec: containers:-name: nginx image: nginx:1.7.9 ports:-containerPort: 80
One way to create a deployment using a .yaml file similar to the above is to use the kubectl apply command in the kubectl command line interface, passing the .yaml file as an argument. The following is an example:
Kubectl apply-f https://k8s.io/examples/application/deployment.yaml-- record
The output is similar to the following:
Deployment.apps/nginx-deployment created
In the .yaml file of the Kubernetes object you want to create, you need to set values for the following fields:
ApiVersion-the Kubernetes API version used to create this object
Kind-the type that created this object
Metadata-data that helps uniquely identify objects, including name strings, UID, and optional namespace
You also need to provide the spec field of the object. The precise format of the object spec is different for each Kubernetes object and contains nested fields specific to that object. Kubernetes API references can help you find the spec format of all objects created with Kubernetes. For example, the spec format of the Pod object can be found here, and the spec format of the Deployment object can be found here.
Thank you for your reading, the above is the content of "the specification and status of Kubernetes objects". After the study of this article, I believe you have a deeper understanding of the specification and status of Kubernetes objects, 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.
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.