Kubernetes: Workflow from Kubectl to Cri

When kubectl receives a create command, it performs the following steps:

  1. Parses the command line arguments and identifies the type of resource to create.
  2. Validates the command line arguments, including the resource type, name, and any other required fields.
  3. Serializes the resource definition into a JSON or YAML document.
  4. Sends the resource definition to the Kubernetes API server.
  5. Waits for the API server to create the resource.
  6. Displays a success message to the user.
  1. Parsing the Configuration: kubectl reads the YAML or JSON file provided as an argument to the create command. This file should contain a resource definition, which includes details about the desired state of the resource to be created, such as the resource type, name, labels, and any other configuration parameters.
  2. API Server Communication: kubectl communicates with the Kubernetes API server, which is responsible for managing the cluster’s state. It sends a POST request to the API server with the resource definition from the file.
  3. Resource Validation: The API server performs validation checks on the resource definition to ensure that it is well-formed and complies with any applicable constraints or policies. If there are any issues with the resource definition, the API server will reject the request and provide an error message.
  4. Resource Creation: If the resource definition is valid and there are no conflicts (e.g., a resource with the same name already exists), the API server creates the requested resource in the cluster based on the provided configuration. This involves allocating resources, setting up networking, and any other necessary actions to fulfill the desired state.
  5. Response: The API server responds to the kubectl client with the status of the operation. If the resource creation is successful, it returns a success message and the resource’s details, including its unique identifier (UID). If there are errors or conflicts, it provides error messages for debugging.
  6. Client Feedback: kubectl displays the API server’s response to the user, allowing them to confirm whether the resource creation was successful or if there were any issues.
  7. Resource Controller Actions: After a resource is created, the appropriate Kubernetes controller (e.g., Deployment controller, StatefulSet controller) may take further actions to ensure that the desired state is maintained. For example, if you created a Deployment resource, the Deployment controller will start the specified number of pods.
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x