https://github.com/skarlso/crd-to-sample-yaml
Generate a sample YAML file from a CRD and view it rendered on a nice website
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.2%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Generate a sample YAML file from a CRD and view it rendered on a nice website
Basic Info
- Host: GitHub
- Owner: Skarlso
- License: apache-2.0
- Language: HTML
- Default Branch: main
- Homepage: https://crdtoyaml.com/
- Size: 102 MB
Statistics
- Stars: 176
- Watchers: 3
- Forks: 18
- Open Issues: 9
- Releases: 50
Topics
Metadata Files
README.md
crd-to-sample-yaml or cty ( city )

Generate a sample YAML file from a CRD definition.
Dynamic CRD Parsing on the frontend

CRD Testing using CTY
For more information about how to use cty for helm-like unit testing your CRD schemas,
please follow the How to test CRDs with CTY Readme.

Example project using CTY for CRD validation: External Secrets Operator.
And the test locations are here.
Schema validation between versions
For information on this feature, please see Schema Validation README.
vscode extension
Under vscode-extension you can find an extension for CTY for vscode browser.
However, actions and intellisense is available to generate samples for a CRD in the current window.

The extension can be installed from it's official page: CRD To Sample YAML Extension.
Getting started
- Prerequisites: Go installed on your machine. (Check out this link for details: https://go.dev/doc/install)
- Clone the repository
- Execute
make buildto build the binary
Now you can simply run:
cty generate crd -c delivery.krok.app_krokcommands
Optionally, define a URL at which a CRD is located:
cty generate crd -u https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-aws/main/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml
cty does not support authentication modes, therefore the CRD needs to be publicly accessible.
This will result in a file similar to this:
yaml
apiVersion: delivery.krok.app/v1alpha1
kind: KrokCommand
metadata: {}
spec:
commandHasOutputToWrite: true
dependencies: ["string"]
enabled: true
image: string
platforms: ["string"]
readInputFromSecret:
name: string
namespace: string
schedule: string
status: {}
A single file will be created containing all versions in the CRD delimited by ---.
Optionally, you can provide the flag -s which will output the generated content to stdout.
You can also point at a git repository to discover CRDs inside the repository. Simply call crd with:
➜ cty generate crd -g https://github.com/Skarlso/crd-bootstrap
Discovered number of CRDs: 1
The following authentication methods are available:
- username and password
./cty generate crd -g https://github.com/Skarlso/crd-bootstrap --username skarlso --password password
- token
./cty generate crd -g https://github.com/Skarlso/crd-bootstrap --token token
- SSH with provided private key
./cty generate crd -g git@github.com:Skarlso/crd-bootstrap --private-ssh-key-file ~/.ssh/main-key
- SSH by using the local ssh-agent
./cty generate crd -g git@github.com:Skarlso/crd-bootstrap --ssh-agent
Notice the URL change in case SSH authentication is provided.
Further certificate bundles can be provided for privately hosted git servers with --ca-bundle-file.
HTML output
It's possible to generate a pre-rendered HTML based output for self-hosting what the website produces online.
To get an HTML output provide the format flag like this:
cty generate crd -c delivery.krok.app_krokcommands --comments --format html
In case of multiple CRD files being parsed using a folder target, the CRDs will be listed
in collapsed drop-down menus where their KIND is the title.

Custom CSS
The HTML output can be customized by providing a custom CSS file.
To do that, pass --css-file to the command like this:
console
cty generate crd -c ./sample-crd/delivery.krok.app_krokcommands.yaml --comments --format html --css-file pkg/test-custom.css --output krok.html
This way, you can customize the output however you want.
Minimal required CRD sample
It's possible to generate a sample YAML for a CRD that will make the CRD validation pass. Meaning, it will only contain samples for fields that are actually required. All other fields will be ignored.
For example, a CRD having a single required field with an example and the rest being optional would generate something like this:
yaml
apiVersion: delivery.krok.app/v1alpha1
kind: KrokCommand
spec:
image: "krok-hook/slack-notification:v0.0.1"
To run cty with minimal required fields, pass in --minimal to the command like this:
cty generate crd -c delivery.krok.app_krokcommands --comments --minimal --format html
Folder source
To parse multiple CRDs in a single folder, just pass in the whole folder like this:
cty generate crd -r folder
Any other flag will work as before.
Kubernetes Config
Use cty to search for a resource in an existing Kubernetes Cluster.
cty generate crd -k krokcommands.delivery.krok.app
This will look for this CRD in the cluster and generate a sample file for it. If you wish to use a different resource
that supports openAPIV3Schema you can configure the group/version/resource cty is looking for.
cty generate crd -k xxtstorageaccounts.crossplane.fnietoga.me --resource CompositeResourceDefinition --group apiextensions.crossplane.io --version v1
Config File
It's possible to define a config file that designates groups for various rendered CRDs.
To use a config file, set the switch --config. A sample config file could look something like this:
yaml
apiGroups:
- name: "com.aws.services"
description: "Resources related to AWS services"
files: # files and folders can be defined together or on their own
- sample-crd/infrastructure.cluster.x-k8s.io_awsclusters.yaml
- sample-crd/delivery.krok.app_krokcommands
- name: "com.azure.services"
description: "Resources related to Azure services"
folders:
- azure-crds
If no grouping information is provided, the rendered CRD's group version is used.

All ways of fetching CRDs are supported through the configuration file. When dealing with URLs I recommend templating this file and fetching sensitive data from elsewhere. For Git, I recommend using the local ssh-agent or a link to an SSH file.
Schema Generation
cty also provides a way to generate a JSON Schema out of a CRD. Simply use:
cty generate schema -c sample-crd/delivery.krok.app_krokcommands.yaml
to target a single file. Or
cty generate schema -r sample-crd
to target a folder.
CRD Types
ANY kind of type can be used, not just CustomResourceDefinitions as long as they provide the following structure:
```yaml
top level spec field
spec: names: kind: # this should be the kind of the generated object group: # the group of the generated object # optional version field versions: - name: v1alpha1 # OpenAPI schema (like the one used by Kubernetes CRDs). Determines what fields # the XR (and claim) will have. Will be automatically extended by crossplane. # See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/ # for full CRD documentation and guide on how to write OpenAPI schemas schema: openAPIV3Schema: # optional validation field describing all versions validation: openAPIV3Schema: ```
If these fields are respected, the apiVersion or the kind of the resource doesn't matter. It's all unstructured in the background.
WASM frontend
There is a WASM based frontend that can be started by navigating into the wasm folder and running the following make
target:
shell
make run
This will start a front-end that can be used to paste in and parse CRDs.
Diff View
If you paste in two CRDs ( or the provided content fetched from a link contains two CRDs of the same type by different versions ),
you can compare them by clicking on the diff button.

Shareable Link
It's possible to provide a link that can be shared using a url parameter like this:
https://crdtoyaml.com/share?url=https://raw.githubusercontent.com/Skarlso/crd-to-sample-yaml/main/sample-crd/infrastructure.cluster.x-k8s.io_awsclusters.yaml
Will load the content, or display an appropriate error message.
Comments
Comments can be added to each line of the generated YAML content where descriptions are available. This looks something like this:
```yaml
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
kind: AWSCluster metadata: {}
AWSClusterSpec defines the desired state of an EC2-based Kubernetes cluster.
spec: # AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the ones added by default. additionalTags: {} # Bastion contains options to configure the bastion host. bastion: ... ```
To add comments simply run cty with:
console
cty generate -c sample-crd/infrastructure.cluster.x-k8s.io_awsclusters.yaml --comments
The frontend also has a checkbox to add comments to the generated yaml output.
Templated CRDs
It's possible to provide a templated CRD like this one for flux: Helm Controller.
It contains template definition like:
yaml
{{- if and .Values.installCRDs .Values.helmController.create }}
These are trimmed so that the CRD parses correctly. Any values that might be in-lined are replaced with replaced.
This is done to avoid trying to parse a breaking yaml.
Things like this:
yaml
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
labels:
app.kubernetes.io/component: helm-controller
app.kubernetes.io/instance: {{ .Release.Namespace }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: '{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}'
name: helmreleases.helm.toolkit.fluxcd.io
Where some templated value isn't escaped with ' will create an invalid YAML that fails to parse.
Showcase

Owner
- Name: Gergely Brautigam
- Login: Skarlso
- Kind: user
- Location: Ether
- Company: Weaveworks
- Website: https://gergelybrautigam.com
- Twitter: Skarlso
- Repositories: 157
- Profile: https://github.com/Skarlso
https://exercism.io/profiles/Skarlso https://leetcode.com/gergely/
GitHub Events
Total
- Create event: 93
- Release event: 12
- Issues event: 25
- Watch event: 59
- Delete event: 77
- Issue comment event: 139
- Push event: 157
- Pull request review comment event: 5
- Pull request review event: 55
- Pull request event: 161
- Fork event: 1
Last Year
- Create event: 93
- Release event: 12
- Issues event: 25
- Watch event: 59
- Delete event: 77
- Issue comment event: 139
- Push event: 157
- Pull request review comment event: 5
- Pull request review event: 55
- Pull request event: 161
- Fork event: 1
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Gergely Brautigam | 1****o | 164 |
| dependabot[bot] | 4****] | 67 |
| Rajeev Krishna | l****2@g****m | 2 |
| Christopher Haar | c****r@u****o | 1 |
| Armin | 5****L | 1 |
| Ahsan-Ehtesham | a****0@g****m | 1 |
| Kolja Lucht | k****t@k****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 60
- Total pull requests: 250
- Average time to close issues: 30 days
- Average time to close pull requests: about 10 hours
- Total issue authors: 13
- Total pull request authors: 6
- Average comments per issue: 2.77
- Average comments per pull request: 0.99
- Merged pull requests: 198
- Bot issues: 1
- Bot pull requests: 164
Past Year
- Issues: 24
- Pull requests: 172
- Average time to close issues: 9 days
- Average time to close pull requests: about 9 hours
- Issue authors: 8
- Pull request authors: 3
- Average comments per issue: 4.08
- Average comments per pull request: 0.92
- Merged pull requests: 135
- Bot issues: 1
- Bot pull requests: 119
Top Authors
Issue Authors
- Skarlso (29)
- markussiebert (14)
- Callisto13 (5)
- Sijoma (2)
- haarchri (2)
- FJEANNOT (1)
- radzhiv25 (1)
- woodliu (1)
- Ahsan-Ehtesham (1)
- henrysachs (1)
- floric (1)
- dependabot[bot] (1)
- lzima (1)
Pull Request Authors
- dependabot[bot] (164)
- Skarlso (79)
- radzhiv25 (3)
- haarchri (2)
- kolja-lucht (1)
- Ahsan-Ehtesham (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
- Total downloads: unknown
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 0
(may contain duplicates) - Total versions: 102
proxy.golang.org: github.com/Skarlso/crd-to-sample-yaml
- Homepage: https://github.com/Skarlso/crd-to-sample-yaml
- Documentation: https://pkg.go.dev/github.com/Skarlso/crd-to-sample-yaml#section-documentation
- License: Apache-2.0
-
Latest release: v1.2.2
published 7 months ago
Rankings
proxy.golang.org: github.com/skarlso/crd-to-sample-yaml
- Documentation: https://pkg.go.dev/github.com/skarlso/crd-to-sample-yaml#section-documentation
- License: apache-2.0
-
Latest release: v1.2.2
published 7 months ago
Rankings
Dependencies
- github.com/go-logr/logr v1.2.3
- github.com/gogo/protobuf v1.3.2
- github.com/google/gofuzz v1.1.0
- github.com/gorilla/mux v1.8.0
- github.com/inconshreveable/mousetrap v1.0.0
- github.com/json-iterator/go v1.1.12
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
- github.com/modern-go/reflect2 v1.0.2
- github.com/spf13/cobra v1.4.0
- github.com/spf13/pflag v1.0.5
- golang.org/x/net v0.0.0-20220722155237-a158d28d115b
- golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
- golang.org/x/text v0.3.7
- gopkg.in/inf.v0 v0.9.1
- gopkg.in/yaml.v2 v2.4.0
- k8s.io/apiextensions-apiserver v0.25.3
- k8s.io/apimachinery v0.25.3
- k8s.io/klog/v2 v2.70.1
- k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
- sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2
- sigs.k8s.io/structured-merge-diff/v4 v4.2.3
- sigs.k8s.io/yaml v1.2.0
- github.com/cpuguy83/go-md2man/v2 v2.0.1
- github.com/davecgh/go-spew v1.1.0
- github.com/davecgh/go-spew v1.1.1
- github.com/go-logr/logr v0.1.0
- github.com/go-logr/logr v1.2.0
- github.com/go-logr/logr v1.2.3
- github.com/gogo/protobuf v1.3.2
- github.com/google/go-cmp v0.5.8
- github.com/google/gofuzz v1.0.0
- github.com/google/gofuzz v1.1.0
- github.com/gorilla/mux v1.8.0
- github.com/inconshreveable/mousetrap v1.0.0
- github.com/json-iterator/go v1.1.12
- github.com/kisielk/errcheck v1.5.0
- github.com/kisielk/gotool v1.0.0
- github.com/kr/text v0.2.0
- github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
- github.com/modern-go/reflect2 v1.0.2
- github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e
- github.com/pmezard/go-difflib v1.0.0
- github.com/russross/blackfriday/v2 v2.1.0
- github.com/spf13/afero v1.2.2
- github.com/spf13/cobra v1.4.0
- github.com/spf13/pflag v1.0.5
- github.com/stretchr/objx v0.1.0
- github.com/stretchr/testify v1.3.0
- github.com/stretchr/testify v1.8.0
- github.com/yuin/goldmark v1.1.27
- github.com/yuin/goldmark v1.2.1
- golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
- golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
- golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
- golang.org/x/mod v0.2.0
- golang.org/x/mod v0.3.0
- golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
- golang.org/x/net v0.0.0-20190620200207-3b0461eec859
- golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
- golang.org/x/net v0.0.0-20201021035429-f5854403a974
- golang.org/x/net v0.0.0-20220722155237-a158d28d115b
- golang.org/x/sync v0.0.0-20190423024810-112230192c58
- golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
- golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
- golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
- golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
- golang.org/x/sys v0.0.0-20190412213103-97732733099d
- golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f
- golang.org/x/text v0.3.0
- golang.org/x/text v0.3.3
- golang.org/x/text v0.3.7
- golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
- golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
- golang.org/x/tools v0.0.0-20200619180055-7c47624df98f
- golang.org/x/tools v0.0.0-20210106214847-113979e3529a
- golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
- golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
- golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
- golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
- gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f
- gopkg.in/inf.v0 v0.9.1
- gopkg.in/yaml.v2 v2.2.8
- gopkg.in/yaml.v2 v2.4.0
- gopkg.in/yaml.v3 v3.0.1
- k8s.io/apiextensions-apiserver v0.25.3
- k8s.io/apimachinery v0.25.3
- k8s.io/klog/v2 v2.0.0
- k8s.io/klog/v2 v2.70.1
- k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
- sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2
- sigs.k8s.io/structured-merge-diff/v4 v4.2.3
- sigs.k8s.io/yaml v1.2.0
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-go v3 composite
- goreleaser/goreleaser-action v3.2.0 composite
- alpine latest build
- golang 1.19-alpine build