From aa720f3c67d287eea6b5b882838df66772118937 Mon Sep 17 00:00:00 2001 From: chival <47812250+chivalryq@users.noreply.github.com> Date: Tue, 18 May 2021 18:45:25 +0800 Subject: [PATCH] Add expose (#1678) * add expose.cue * add expose.yaml * add usage comment * gen yaml * fix issue Co-authored-by: qiaozp --- .../templates/defwithtemplate/expose.yaml | 36 +++++++++++++++++++ hack/vela-templates/cue/expose.cue | 20 +++++++++++ hack/vela-templates/definitions/expose.yaml | 14 ++++++++ 3 files changed, 70 insertions(+) create mode 100644 charts/vela-core/templates/defwithtemplate/expose.yaml create mode 100644 hack/vela-templates/cue/expose.cue create mode 100644 hack/vela-templates/definitions/expose.yaml diff --git a/charts/vela-core/templates/defwithtemplate/expose.yaml b/charts/vela-core/templates/defwithtemplate/expose.yaml new file mode 100644 index 000000000..04b21980a --- /dev/null +++ b/charts/vela-core/templates/defwithtemplate/expose.yaml @@ -0,0 +1,36 @@ +# Code generated by KubeVela templates. DO NOT EDIT. +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "Expose port to enable web traffic for your component." + name: expose + namespace: {{.Values.systemDefinitionNamespace}} +spec: + appliesToWorkloads: + - deployments.apps + podDisruptive: false + schematic: + cue: + template: | + outputs: service: { + apiVersion: "v1" + kind: "Service" + metadata: + name: context.name + spec: { + selector: + "app.oam.dev/component": context.name + ports: [ + for p in parameter.port { + port: p + targetPort: p + }, + ] + } + } + parameter: { + // +usage=Specify the exposion ports + port: [...int] + } + diff --git a/hack/vela-templates/cue/expose.cue b/hack/vela-templates/cue/expose.cue new file mode 100644 index 000000000..37831602c --- /dev/null +++ b/hack/vela-templates/cue/expose.cue @@ -0,0 +1,20 @@ +outputs: service: { + apiVersion: "v1" + kind: "Service" + metadata: + name: context.name + spec: { + selector: + "app.oam.dev/component": context.name + ports: [ + for p in parameter.port { + port: p + targetPort: p + }, + ] + } +} +parameter: { + // +usage=Specify the exposion ports + port: [...int] +} diff --git a/hack/vela-templates/definitions/expose.yaml b/hack/vela-templates/definitions/expose.yaml new file mode 100644 index 000000000..852a3020f --- /dev/null +++ b/hack/vela-templates/definitions/expose.yaml @@ -0,0 +1,14 @@ +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "Expose port to enable web traffic for your component." + name: expose + namespace: {{.Values.systemDefinitionNamespace}} +spec: + appliesToWorkloads: + - deployments.apps + podDisruptive: false + schematic: + cue: + template: |