GCP - Yaml file definitions

9/12/2018

I'm trying to make google cloud my default cloud tool. So far it's going quite fine and following the documentation. In order to be able to automate some things (e.g. creating deployments - services - ingress - ...) with kubernetes environments, I'm digging into the YAML manifests.

The issue now is: I find examples and documentation on how to create e.g. a deployment based upon a YAML manifest, but I don't find the description/documentation of the manifests (i.e. which properties are available and which purpose do they have).

Does anyone know where to find these?

-- Vandeperre Maarten
kubernetes

2 Answers

9/13/2018

You can get a brief explanation of manifest options right from the kubectl tool:

$ kubectl explain --help

List the fields for supported resources

This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:

 <type>.<fieldName>[.<fieldName>]

Add the --recursive flag to display all of the fields at once without descriptions. Information about each field is retrieved from the server in OpenAPI format.

Use "kubectl api-resources" for a complete list of supported resources.

Examples:

Get the documentation of the resource and its fields

kubectl explain pods    

Get the documentation of a specific field of a resource

kubectl explain pods.spec.containers

Options:

 --api-version='': Get different explanations for particular API version
 --recursive=false: Print the fields of fields (Currently only 1 level deep)

Usage: kubectl explain RESOURCE [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).

Here is an example output for the pods.spec.containers.image explanation:

$ kubectl explain pods.spec.containers.image
KIND:     Pod
VERSION:  v1
FIELD:    image <string>
DESCRIPTION:
     Docker image name. More info:
     https://kubernetes.io/docs/concepts/containers/images This field is
     optional to allow higher level config management to default or override
     container images in workload controllers like Deployments and StatefulSets.
-- VAS
Source: StackOverflow

9/12/2018

I find examples and documentation on how to create e.g. a deployment based upon a yaml manifest, but I don't find the description/documentation of the manifests (i.e. which properties are available and which purpose do they have).

The Kubernetes API specification should be your first place to check (link). There are outward links from that page to a general page describing the k8s API and to a listing of each API kind which you express in your YAML manifests. There is a version of this document for each version of the API, as defined at the point of a k8s release. (The current docs, for v1.11, are here.)


For clarity, the component you are using, Google Kubernetes Engine, is a managed instance of the container orchestration platform Kubernetes (commonly abbreviated as k8s). The k8s specification is defined and maintained by the k8s project maintainers, who are independent from Google (although a significant number of Google employees contribute to the project, in recognition of the importance of k8s in Google's infrastructure!).

The k8s team publishes an automatically-generated documentation website for the API entities, which you can find at the links posted above. The project does a great job at documentation, although it's worth noting that while the API specs are a good reference manual, they are very low level. I recommend reading them in conjunction with the other k8s documentation if you seek a more conceptual understanding.

-- Cosmic Ossifrage
Source: StackOverflow