| 27 | |
| 28 | |
| 29 | def main(): |
| 30 | # Creating a dynamic client |
| 31 | client = dynamic.DynamicClient( |
| 32 | api_client.ApiClient(configuration=config.load_kube_config()) |
| 33 | ) |
| 34 | |
| 35 | # fetching the custom resource definition (CRD) api |
| 36 | crd_api = client.resources.get( |
| 37 | api_version="apiextensions.k8s.io/v1", kind="CustomResourceDefinition" |
| 38 | ) |
| 39 | |
| 40 | # Creating a Namespaced CRD named "ingressroutes.apps.example.com" |
| 41 | name = "ingressroutes.apps.example.com" |
| 42 | |
| 43 | crd_manifest = { |
| 44 | "apiVersion": "apiextensions.k8s.io/v1", |
| 45 | "kind": "CustomResourceDefinition", |
| 46 | "metadata": { |
| 47 | "name": name, |
| 48 | }, |
| 49 | "spec": { |
| 50 | "group": "apps.example.com", |
| 51 | "versions": [ |
| 52 | { |
| 53 | "name": "v1", |
| 54 | "schema": { |
| 55 | "openAPIV3Schema": { |
| 56 | "properties": { |
| 57 | "spec": { |
| 58 | "properties": { |
| 59 | "strategy": {"type": "string"}, |
| 60 | "virtualhost": { |
| 61 | "properties": { |
| 62 | "fqdn": {"type": "string"}, |
| 63 | "tls": { |
| 64 | "properties": { |
| 65 | "secretName": {"type": "string"} |
| 66 | }, |
| 67 | "type": "object", |
| 68 | }, |
| 69 | }, |
| 70 | "type": "object", |
| 71 | }, |
| 72 | }, |
| 73 | "type": "object", |
| 74 | } |
| 75 | }, |
| 76 | "type": "object", |
| 77 | } |
| 78 | }, |
| 79 | "served": True, |
| 80 | "storage": True, |
| 81 | } |
| 82 | ], |
| 83 | "scope": "Cluster", |
| 84 | "names": { |
| 85 | "plural": "ingressroutes", |
| 86 | "listKind": "IngressRouteList", |