liveBook · Manning

Kubernetes manifest

As explained in Developer Experience on Kubernetes

A Kubernetes manifest is a declarative configuration document that specifies the desired state of one or more Kubernetes resources.

A Kubernetes manifest is a YAML configuration file that defines resources to create in a cluster. It gives an application a deployable shape: the workload that runs its container, the networking that reaches it, and optional configuration or credentials. Developers apply manifests through the Kubernetes API, commonly with kubectl. section 3.3.3

Manifests matter in a Kubernetes inner loop because running a changed application is no longer a single local-runtime action. After packaging an image and making it available to the cluster, developers define or update resource manifests and apply them. That extra configuration work can slow feedback and pull attention from application logic. section 3.3.2 section 3.3

A typical application deployment uses manifests for several resource roles:

  • Deployment — manages the lifecycle of a stateless replicated application; each replica contains a Pod representing the application container. section 3.3.3
  • Service — makes a Deployment reachable for network calls, usually from inside the cluster. section 3.3.3
  • Ingress — makes a Service reachable for network calls from outside the cluster. section 3.3.3
  • ConfigMap and Secret — supply application properties or credentials. Base64 encoding alone does not make Secret data encrypted or secret. section 3.3.3

Manifest-driven appointments service

An appointments application can use a Deployment manifest with identifying metadata and labels, a selector and Pod template, a container image, and environment variables read from a database Secret. Applying the configuration creates or updates the declared resources; querying resources by the application label then verifies the deployment. A PostgreSQL Cluster can be provisioned separately before the application is deployed. section 3.3.3

Listing 3.1 Deployment configuration for a cloud native application.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: appointments #A
  labels:
    app: appointments
spec:
  selector:
    matchLabels:
      app: appointments
  template:
    metadata:
      labels:
        app: appointments
    spec:
      containers:
        - name: appointments #B
          image: ko.local/appointments:0.0.1-SNAPSHOT #C
          env: #D
            - name: POSTGRES_HOST
              valueFrom:
                secretKeyRef:
                  name: db-appointments-app
                  key: host
            - name: POSTGRES_PORT
              valueFrom:
                secretKeyRef:
                  name: db-appointments-app
                  key: port
            - name: POSTGRES_DB
              valueFrom:
                secretKeyRef:
                  name: db-appointments-app
                  key: dbname
            - name: POSTGRES_USERNAME
              valueFrom:
                secretKeyRef:
                  name: db-appointments-app
                  key: username
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-appointments-app
                  key: password
          ...

Inspect the Deployment configuration to connect manifest fields to an application container, image reference, labels, and database environment variables. section 3.3.3

Writing manifests directly provides explicit control but requires familiarity with the Kubernetes API. For early adoption, generated manifests can reduce that burden: the JKube plugin can generate them from Java application source. Tools such as ko can automate image building, local cluster loading, and deployment when a manifest is applied; Skaffold further automates that workflow through application live-sync. section 3.5 section 3.5

How Developer Experience on Kubernetes covers it

How deep it goes
Explains YAML manifests through Deployment, Service, Ingress, ConfigMap, and Secret roles, while deferring detailed Secret use.
Examples
Uses an appointments service Deployment with a container image and database Secret variables, plus a PostgreSQL Cluster.
What it assumes
Assumes a Kubernetes cluster and a packaged container image, then teaches manifest definition and application.
What you can do after
Operate/configure it by defining resource YAML and applying it to create or update an application deployment.
How it connects
Connects manifests to Kubernetes API, kubectl, Deployments, Pods, Services, Ingresses, ConfigMaps, Secrets, ko, JKube, and Skaffold.

Also explained in

Compare how 11 books explain Kubernetes manifest →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Developer Experience on Kubernetes. The section links point to the parts of the book it draws on.