Skip to content

Kubernetes YAML Generator

Fill in a short form to get a Deployment, Service and Ingress for your app, with resource limits, health probes and environment variables. Apply it with kubectl apply -f.

Workload
Manifest

    

Last reviewed:

What is Kubernetes YAML?

Kubernetes is configured declaratively: you describe the state you want in manifests, YAML documents each containing an apiVersion, a kind, metadata such as name, namespace and labels, and a spec. You send them to the cluster with kubectl apply -f, and controllers work continuously to make reality match. Running a typical web service takes three resources. A Deployment keeps a set number of identical Pods running from a container image and replaces them gradually on updates. A Service gives those Pods a stable name and IP address and load-balances across them. An Ingress routes external HTTP and HTTPS traffic for a host name to the Service.

The pieces are connected by labels rather than by name. The Deployment's selector must match the labels in its Pod template, and the Service's selector must match the same labels, or traffic never reaches the Pods. A typo in a label, a wrong indent or a targetPort that does not match the container port produces manifests that apply without errors and then silently fail to serve anything.

Production manifests need more than the minimum. Resource requests tell the scheduler how much CPU and memory to reserve; limits cap usage. Readiness probes keep a Pod out of the Service until it can handle requests, and liveness probes restart a container that has hung. This generator produces all of that from a short form, with consistent labels and named ports so the pieces fit together.

How to use this tool

  1. Enter the App name and Namespace. The name is used for every resource, the container and the labels. It should be lowercase letters, numbers and dashes, and you will see a warning otherwise.
  2. Enter the Container image with a version tag. A warning appears for images without a tag or tagged latest.
  3. Set Replicas and the Container port your app listens on.
  4. Set CPU and Memory requests and limits, such as 100m (a tenth of a CPU core) and 128Mi. Leave a field empty to omit it.
  5. Enter the Readiness probe path and Liveness probe path, or clear them for no probe.
  6. Add Environment variables, one KEY=value per line. Lines starting with # are ignored.
  7. Choose a Service type (ClusterIP, NodePort, LoadBalancer or No Service) and its port.
  8. For external access, enter an Ingress host and Ingress class, and tick HTTPS with cert-manager to request a Let's Encrypt certificate.
  9. Copy or download the manifest (saved as <app name>.yaml) and run kubectl apply -f web-api.yaml.

Examples

The default web API

With the form's defaults, the tool produces a Deployment, a Service and an Ingress, separated by ---. The Deployment's container section looks like this:

      containers:
        - name: web-api
          image: ghcr.io/acme/web-api:1.4.2
          ports:
            - name: http
              containerPort: 8080
          env:
            - name: NODE_ENV
              value: production
            - name: LOG_LEVEL
              value: info
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 512Mi
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            initialDelaySeconds: 5
            periodSeconds: 10
            timeoutSeconds: 2
            failureThreshold: 3

The Service and Ingress refer to the port by its name, http, rather than by number:

apiVersion: v1
kind: Service
metadata:
  name: web-api
  namespace: default
  labels:
    app.kubernetes.io/name: web-api
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: web-api
  ports:
    - name: http
      port: 80
      targetPort: http

Changing the container port later only needs one edit. Inside the cluster, other apps reach the service at http://web-api (port 80).

A background worker without a Service

Name email-worker, namespace jobs, no readiness path, Service set to No Service, Ingress host empty, CPU limit empty, and these variables:

QUEUE=emails
CONCURRENCY=8
FEATURE_FLAG=on

The output is a single Deployment. Its environment section is:

          env:
            - name: QUEUE
              value: emails
            - name: CONCURRENCY
              value: "8"
            - name: FEATURE_FLAG
              value: "on"
          resources:
            requests:
              cpu: 250m
              memory: 256Mi
            limits:
              memory: 256Mi

8 and on are quoted because Kubernetes requires environment values to be strings; unquoted, YAML would read them as a number and a boolean. Without a CPU limit, the worker can use spare CPU on the node and is never throttled, while the memory limit still protects the node.

Common errors and how to fix them

  • cannot unmarshal number into Go struct field EnvVar…value of type string. An environment value such as 8 or true is unquoted in a hand-written manifest. Quote it, as the generator does.
  • Service has no endpoints. The Service selector does not match the Pod labels, or the Pods are not ready. Run kubectl describe service web-api to see its endpoints, and check the readiness probe.
  • Pods restart in a loop (CrashLoopBackOff). The liveness probe may fail before the app has started. Increase initialDelaySeconds, or add a startupProbe for slow starters like JVM apps. Check kubectl logs --previous for the crash itself.
  • OOMKilled. The container exceeded its memory limit. Raise the limit, or reduce memory use; for Java, cap the heap with -XX:MaxRAMPercentage.
  • ImagePullBackOff. The image name or tag is wrong, or the registry is private and needs an imagePullSecrets entry.
  • Ingress returns 404 or never gets an address. The ingressClassName must match an ingress controller installed in the cluster (kubectl get ingressclass). For HTTPS, cert-manager must be installed with a ClusterIssuer named letsencrypt-prod.
  • "spec.selector: field is immutable". You changed labels on an existing Deployment. Keep the selector stable, or delete and recreate the Deployment.

When developers use this

  • Deploying a new service to a cluster for the first time, starting from manifests that already follow good practice.
  • Writing a quick manifest for a local cluster such as kind, minikube or k3d to test an image.
  • Adding probes and resource settings to an app that was deployed without them.
  • Generating a base for Helm charts or Kustomize overlays.
  • Explaining to a teammate how Deployments, Services and Ingresses connect, with real, working YAML.

Privacy and how it works

The YAML is built in your browser with the js-yaml library from the values in the form. Nothing is sent to a server, and the tool never connects to a cluster, so image names, internal host names and environment values stay on your machine. Do not put real secrets in plain environment variables in manifests that are committed to Git. Use a Kubernetes Secret, and reference it with valueFrom.secretKeyRef or envFrom.

Limitations

  • Only Deployments, Services and Ingresses are generated. ConfigMaps, Secrets, HorizontalPodAutoscalers, StatefulSets and PersistentVolumeClaims are not.
  • The Ingress routes the whole host (/ with pathType: Prefix) to one Service. Multiple paths or hosts need manual edits.
  • The tool checks names and image tags but does not validate the manifest against your cluster's API. Run kubectl apply --dry-run=server -f file.yaml to check it with the cluster.

FAQ

What is the difference between requests and limits?

Requests are what the scheduler reserves for a container when it places the Pod on a node. Limits are the maximum it may use: going over the CPU limit slows the container down (throttling), and going over the memory limit kills it.

What is the difference between readiness and liveness probes?

A failing readiness probe removes the Pod from Service traffic but leaves it running, which is right for temporary problems such as a database blip. A failing liveness probe restarts the container. Keep liveness checks simple, so a slow dependency does not restart every Pod at once.

Which Service type should I choose?

ClusterIP is for traffic inside the cluster, usually behind an Ingress. NodePort opens a port on every node, and is mostly used for testing. LoadBalancer asks the cloud provider for an external load balancer, typically one per Service, which costs money.

Why does the manifest use named ports?

The Service's targetPort: http and the probes' port: http refer to the container port by name. If you change the number, everything stays in sync.

Do I need the cert-manager option?

Only if cert-manager is installed in your cluster. It reads the annotation, gets a certificate from Let's Encrypt for the host and stores it in the web-api-tls Secret, which the Ingress uses for HTTPS. Without cert-manager, untick it or supply your own TLS Secret.

Why should I avoid the latest tag?

latest points to whatever was pushed most recently, so different Pods can run different code. Rollbacks also become impossible to reason about. A version tag or digest makes every rollout repeatable.

How do I apply the manifest to a different namespace?

Change the Namespace field and the metadata of every resource updates. Create the namespace first with kubectl create namespace jobs if it does not exist.

Guides