github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/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/deprecated/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. 8 labels: 9 custom.definition.oam.dev/deprecated: "true" 10 name: ingress 11 namespace: {{ include "systemDefinitionNamespace" . }} 12 spec: 13 podDisruptive: false 14 schematic: 15 cue: 16 template: | 17 // trait template can have multiple outputs in one trait 18 outputs: service: { 19 apiVersion: "v1" 20 kind: "Service" 21 metadata: name: context.name 22 spec: { 23 selector: "app.oam.dev/component": context.name 24 ports: [ 25 for k, v in parameter.http { 26 port: v 27 targetPort: v 28 }, 29 ] 30 } 31 } 32 33 outputs: ingress: { 34 apiVersion: "networking.k8s.io/v1beta1" 35 kind: "Ingress" 36 metadata: name: context.name 37 spec: rules: [{ 38 host: parameter.domain 39 http: paths: [ 40 for k, v in parameter.http { 41 path: k 42 backend: { 43 serviceName: context.name 44 servicePort: v 45 } 46 }, 47 ] 48 }] 49 } 50 51 parameter: { 52 // +usage=Specify the domain you want to expose 53 domain: string 54 55 // +usage=Specify the mapping relationship between the http path and the workload port 56 http: [string]: int 57 } 58 status: 59 customStatus: |- 60 let igs = context.outputs.ingress.status.loadBalancer.ingress 61 if igs == _|_ { 62 message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + "'\n" 63 } 64 if len(igs) > 0 { 65 if igs[0].ip != _|_ { 66 message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip 67 } 68 if igs[0].ip == _|_ { 69 message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host 70 } 71 } 72 healthPolicy: 'isHealth: len(context.outputs.service.spec.clusterIP) > 0' 73