Tweak Objects In Kubernetes concept

Co-authored-by: Ader Fu <ader.ydfu@gmail.com>
pull/42117/head
Tim Bannister 2023-07-20 22:15:08 +01:00
parent 6f0c807e69
commit 819d4c32d4
1 changed files with 15 additions and 7 deletions

View File

@ -33,7 +33,7 @@ will constantly work to ensure that object exists. By creating an object, you're
telling the Kubernetes system what you want your cluster's workload to look like; this is your
cluster's *desired state*.
To work with Kubernetes objects--whether to create, modify, or delete them--you'll need to use the
To work with Kubernetes objects—whether to create, modify, or delete them—you'll need to use the
[Kubernetes API](/docs/concepts/overview/kubernetes-api/). When you use the `kubectl` command-line
interface, for example, the CLI makes the necessary Kubernetes API calls for you. You can also use
the Kubernetes API directly in your own programs using one of the
@ -71,15 +71,18 @@ For more information on the object spec, status, and metadata, see the
When you create an object in Kubernetes, you must provide the object spec that describes its
desired state, as well as some basic information about the object (such as a name). When you use
the Kubernetes API to create the object (either directly or via `kubectl`), that API request must
include that information as JSON in the request body. **Most often, you provide the information to
`kubectl` in a .yaml file.** `kubectl` converts the information to JSON when making the API
request.
include that information as JSON in the request body.
Most often, you provide the information to `kubectl` in file known as a _manifest_.
By convention, manifests are YAML (you could also use JSON format).
Tools such as `kubectl` convert the information from a manifest into JSON or another supported
serialization format when making the API request over HTTP.
Here's an example `.yaml` file that shows the required fields and object spec for a Kubernetes Deployment:
Here's an example manifest that shows the required fields and object spec for a Kubernetes
Deployment:
{{% code_sample file="application/deployment.yaml" %}}
One way to create a Deployment using a `.yaml` file like the one above is to use the
One way to create a Deployment using a manifest file like the one above is to use the
[`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply) command
in the `kubectl` command-line interface, passing the `.yaml` file as an argument. Here's an example:
@ -95,7 +98,8 @@ deployment.apps/nginx-deployment created
### Required fields
In the `.yaml` file for the Kubernetes object you want to create, you'll need to set values for the following fields:
In the manifest (YAML or JSON file) for the Kubernetes object you want to create, you'll need to set values for
the following fields:
* `apiVersion` - Which version of the Kubernetes API you're using to create this object
* `kind` - What kind of object you want to create
@ -159,6 +163,10 @@ If you're new to Kubernetes, read more about the following:
* [Controllers](/docs/concepts/architecture/controller/) in Kubernetes.
* [kubectl](/docs/reference/kubectl/) and [kubectl commands](/docs/reference/generated/kubectl/kubectl-commands).
[Kubernetes Object Management](/docs/concepts/overview/working-with-objects/object-management/)
explains how to use `kubectl` to manage objects.
You might need to [install kubectl](/docs/tasks/tools/#kubectl) if you don't already have it available.
To learn about the Kubernetes API in general, visit:
* [Kubernetes API overview](/docs/reference/using-api/)