github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/pure-ingress.yaml (about)

     1  # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
     2  # Definition source cue file: vela-templates/definitions/internal/pure-ingress.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: TraitDefinition
     5  metadata:
     6    annotations:
     7      definition.oam.dev/description: Enable public web traffic for the component without creating a Service.
     8    labels:
     9      custom.definition.oam.dev/deprecated: "true"
    10      custom.definition.oam.dev/ui-hidden: "true"
    11    name: pure-ingress
    12    namespace: {{ include "systemDefinitionNamespace" . }}
    13  spec:
    14    appliesToWorkloads:
    15      - '*'
    16    conflictsWith: []
    17    podDisruptive: false
    18    schematic:
    19      cue:
    20        template: |
    21          outputs: ingress: {
    22          	apiVersion: "networking.k8s.io/v1beta1"
    23          	kind:       "Ingress"
    24          	metadata: name: context.name
    25          	spec: rules: [{
    26          		host: parameter.domain
    27          		http: paths: [
    28          			for k, v in parameter.http {
    29          				path: k
    30          				backend: {
    31          					serviceName: context.name
    32          					servicePort: v
    33          				}
    34          			},
    35          		]
    36          	}]
    37          }
    38          parameter: {
    39          	// +usage=Specify the domain you want to expose
    40          	domain: string
    41  
    42          	// +usage=Specify the mapping relationship between the http path and the workload port
    43          	http: [string]: int
    44          }
    45    status:
    46      customStatus: |-
    47        let igs = context.outputs.ingress.status.loadBalancer.ingress
    48        if igs == _|_ {
    49        	message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
    50        }
    51        if len(igs) > 0 {
    52        	if igs[0].ip != _|_ {
    53        		message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
    54        	}
    55        	if igs[0].ip == _|_ {
    56        		message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
    57        	}
    58        }
    59    workloadRefPath: ""
    60