crds-generator
This tool was created to generate a simple kubernetes crds from a pydantic-like object.
You can install it as shown below:
pip install crds-generator
You can create a CRDS with the code below:
from typing import Literal, Optional
import yaml
from crds_generator import CustomResourceDefinition, Schema, generate_crd, AdditionalPrinterColumns
class Server(Schema):
name: str
cpu_type: str
gpu_type: str
os: Literal["mac", "linux"]
class Spec(Schema):
servers: list[Server]
budget: int
class Status(Schema):
ping_result: bool
class ServerPool(Schema):
spec: Spec
status: Status = None
apc = AdditionalPrinterColumns(
name="Name",
type="string",
description="Server Name",
jsonPath= ".spec.servers[*].name"
)
print(
yaml.dump(
generate_crd(
CustomResourceDefinition(
spec={
"scope": "Namespaced",
"group": "example.com",
"names": {
"kind": "ServerPool",
"plural": "serverpools",
"singular": "serverpool",
"shortNames": ["sp"],
},
"versions": [
{
"name": "v1",
"served": True,
"storage": True,
"schema": ServerPool,
"additionalPrinterColumns": [
apc
],
}
],
},
)
)
)
)
then print
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: serverpools.example.com
spec:
group: example.com
names:
kind: ServerPool
plural: serverpools
shortNames:
- sp
singular: serverpool
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Server Name
jsonPath: .spec.servers[*].name
name: Name
type: string
name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
budget:
type: integer
servers:
items:
properties:
cpu_type:
type: string
gpu_type:
type: string
name:
type: string
os:
enum:
- mac
- linux
type: string
required:
- name
- cpu_type
- gpu_type
- os
type: object
type: array
required:
- servers
- budget
type: object
status:
properties:
ping_result:
type: boolean
required:
- ping_result
type: object
required:
- spec
type: object
served: true
storage: true
Metadata
Release files for crds-generator 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| crds_generator-0.0.6.tar.gz | 2.5 kB | Without provenance | Details for crds_generator-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crds_generator-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for crds_generator-0.0.6-py3-none-any.whl |
Total release size: 5.6 kB
Release files / crds_generator-0.0.6.tar.gz
| Download URL | crds_generator-0.0.6.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90aa3d22b5b4a602530142a028d62687c1366d05c7542348c000175214136f09
|
|
BLAKE2b-256 checksum How to use checksums |
093afa209b787e37474d864eefd54f5e4dcff641b763cfa2196f15789d954085
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / crds_generator-0.0.6-py3-none-any.whl
| Download URL | crds_generator-0.0.6-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17bb1d809f40e51d2d8d2cef5af817e33f25f1d8eee6237d8d413f499f48d09b
|
|
BLAKE2b-256 checksum How to use checksums |
e0f1577e74ce47b0f2e16684eeee70efe41cdd25d276b5b01c6a4bd47f88ee1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for crds-generator 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.