Creating Kubernetes manifests

Managing Kubernetes workloads is one of the most heavily used applications of GitOps, so it's important to understand the basics of declaring some of the most commonly used Kubernetes resources such as deployments and services. Declarative configurations for Kubernetes resources are commonly referred to as manifests.

A manifest is a plain text configuration file that uses the JSON or YAML formats to describe resources that should run on the cluster. The configuration in these files must adhere to the specifications for different resources found in the Kubernetes API reference. In most cases, YAML is the preferred format for manifests, so we’ll use it throughout our lessons.

Required fields

There are four required fields in every manifest that must be provided when describing a resource we want to deploy on a Kubernetes cluster.

  1. The first field is the apiVersion, which defines the version of the Kubernetes API being used to create the resource. Some resources are available for multiple and different API versions, so it's important to correctly identify the API version being used for the object.

  2. The second field is the kind field, which indicates the type of resource to be created. Its value will be the name of a Kubernetes resource, which can be something like deployment, service, or some other valid resource name.

  3. The third required field is metadata, which allows us to provide a name for the object in the Kubernetes cluster and optionally a namespace in which it should reside. A namespace is used to partition or isolate groups of resources within the cluster.

  4. The final and most complicated field is spec. This is where the configuration of the resource that will be deployed on the cluster is defined. The spec field will be different for each type of resource because each resource has a unique specification defined by the API.

Here's a shortened example of the required fields for a Kubernetes resource, which demonstrates the structure and example values for the fields:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy