|
| 1 | +import besom.* |
| 2 | +import besom.api.kubernetes as k8s |
| 3 | + |
| 4 | +@main def main = Pulumi.run { |
| 5 | + |
| 6 | + val crd = |
| 7 | + k8s.yaml.v2.ConfigGroup( |
| 8 | + name = "config-group", |
| 9 | + k8s.yaml.v2.ConfigGroupArgs( |
| 10 | + yaml = """apiVersion: apiextensions.k8s.io/v1 |
| 11 | + |kind: CustomResourceDefinition |
| 12 | + |metadata: |
| 13 | + | # name must match the spec fields below, and be in the form: <plural>.<group> |
| 14 | + | name: crontabs.stable.example.com |
| 15 | + |spec: |
| 16 | + | # group name to use for REST API: /apis/<group>/<version> |
| 17 | + | group: stable.example.com |
| 18 | + | # list of versions supported by this CustomResourceDefinition |
| 19 | + | versions: |
| 20 | + | - name: v1 |
| 21 | + | # Each version can be enabled/disabled by Served flag. |
| 22 | + | served: true |
| 23 | + | # One and only one version must be marked as the storage version. |
| 24 | + | storage: true |
| 25 | + | schema: |
| 26 | + | openAPIV3Schema: |
| 27 | + | type: object |
| 28 | + | properties: |
| 29 | + | spec: |
| 30 | + | type: object |
| 31 | + | properties: |
| 32 | + | cronSpec: |
| 33 | + | type: string |
| 34 | + | image: |
| 35 | + | type: string |
| 36 | + | replicas: |
| 37 | + | type: integer |
| 38 | + | # either Namespaced or Cluster |
| 39 | + | scope: Namespaced |
| 40 | + | names: |
| 41 | + | # plural name to be used in the URL: /apis/<group>/<version>/<plural> |
| 42 | + | plural: crontabs |
| 43 | + | # singular name to be used as an alias on the CLI and for display |
| 44 | + | singular: crontab |
| 45 | + | # kind is normally the CamelCased singular type. Your resource manifests use this. |
| 46 | + | kind: CronTab |
| 47 | + | # shortNames allow shorter string to match your resource on the CLI |
| 48 | + | shortNames: |
| 49 | + | - ct |
| 50 | + | """.stripMargin |
| 51 | + ) |
| 52 | + ) |
| 53 | + |
| 54 | + val cronTab = |
| 55 | + k8s.yaml.v2.ConfigGroup( |
| 56 | + name = "cron-tab", |
| 57 | + k8s.yaml.v2.ConfigGroupArgs( |
| 58 | + yaml = """apiVersion: "stable.example.com/v1" |
| 59 | + |kind: CronTab |
| 60 | + |metadata: |
| 61 | + | name: my-new-cron-object |
| 62 | + |spec: |
| 63 | + | cronSpec: "* * * * */5" |
| 64 | + | image: my-awesome-cron-image |
| 65 | + | """.stripMargin |
| 66 | + ), |
| 67 | + opts = opts(dependsOn = crd) |
| 68 | + ) |
| 69 | + |
| 70 | + Stack.exports( |
| 71 | + crdResource = crd.resources, |
| 72 | + cronTabResource = cronTab.resources |
| 73 | + ) |
| 74 | +} |
0 commit comments