Skip to content

Creating Kubernetes YAML

Using --dry-run is a quick way to create well formed k8s yaml:

$ kubectl create ingress blog --class=nginx --rule="blog.mehcoleman.com/*=blog:80" --dry-run=client -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  creationTimestamp: null
  name: blog
spec:
  ingressClassName: nginx
  rules:
  - host: blog.mehcoleman.com
    http:
      paths:
      - backend:
          service:
            name: blog
            port:
              number: 80
        path: /
        pathType: Prefix

See How To Create Kubernetes YAML Manifests Quickly for many other examples, and my post on K8s configuration management methods for an overview of how they might be used.