Skip to content

DevOps & Cloud Tools

Kubernetes YAML Generator

Generate Kubernetes manifests with matching selectors and labels.

kubernetes yaml generatorRuns in your browserUpdated 2026-09-22

Environment variables

tlks-web.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tlks-web
  namespace: default
  labels:
    app.kubernetes.io/name: tlks-web
    app.kubernetes.io/component: web
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: tlks-web
      app.kubernetes.io/component: web
  template:
    metadata:
      labels:
        app.kubernetes.io/name: tlks-web
        app.kubernetes.io/component: web
    spec:
      containers:
        - name: tlks-web
          image: ghcr.io/tlks/web:1.8.0
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
          env:
            - name: NODE_ENV
              value: production
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: database-url
                  key: DATABASE_URL
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 512Mi
          readinessProbe:
            httpGet:
              path: /healthz
              port: http
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /healthz
              port: http
            initialDelaySeconds: 15
            periodSeconds: 20
          securityContext:
            allowPrivilegeEscalation: false
            runAsNonRoot: true
            capabilities:
              drop:
                - ALL
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  name: tlks-web
  namespace: default
  labels:
    app.kubernetes.io/name: tlks-web
    app.kubernetes.io/component: web
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: tlks-web
    app.kubernetes.io/component: web
  ports:
    - name: http
      port: 80
      targetPort: http
      protocol: TCP

kubectl apply -f tlks-web.yaml -n default

Secrets are referenced by name only. Create the referenced Secret objects separately, for example with kubectl create secret generic, and never commit literal values.

About Kubernetes YAML Generator

Kubernetes manifests fail for boring reasons: a Service selector that does not match the pod labels, a probe that hits the wrong path, or a container without resource requests that is evicted under pressure. Generating the objects together keeps the selectors and labels consistent by construction.

Select a resource type and fill in the essentials; the generator emits a complete manifest with API version, labels, probes and resource settings, and keeps the Service selector synchronised with the Deployment template labels. Configuration values that should be secret are emitted as references to an existing Secret rather than as plain text.

How it works

  • Choose one or more objects: Deployment, Service, Ingress, ConfigMap or HorizontalPodAutoscaler.
  • Labels and selectors are generated from a single application name so they always match.
  • Probes, resource requests and limits are added when enabled, using conventional defaults.
  • Environment variables can be added as plain values or as references to a Secret or ConfigMap.
  • Service and Ingress objects reference the container port you declared rather than a guessed port.
  • Output is valid YAML with a document separator between objects, ready for kubectl apply -f.

Input and output

Accepts

Object type, application name, image, ports, replicas, environment variables and feature toggles.

Produces

One or more YAML documents with matching labels, selectors and port references.

Privacy

Manifests are rendered locally. Secrets are referenced by name and never typed into this tool.

Kubernetes YAML Generator FAQ

Why do my pods show as having no endpoints?

The Service selector does not match the pod labels. Compare the selector with the template metadata labels; generating them together avoids this class of error.

Should I set resource requests and limits?

Yes. Requests drive scheduling and limits prevent a noisy neighbour from consuming a node. Omitting requests makes pods the first candidates for eviction.

Why does the API version differ between clusters?

Kubernetes promotes APIs over time, for example Ingress from extensions/v1beta1 to networking.k8s.io/v1. Always confirm the version your cluster serves.

Where should secrets live?

In a Secret object or an external secret manager. Reference them with secretKeyRef from the manifest rather than committing literal values.