github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/ingress-1-20.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-1-20.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, the ingress API matches K8s v1.20+. 8 labels: 9 custom.definition.oam.dev/deprecated: "true" 10 name: ingress-1-20 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/v1" 35 kind: "Ingress" 36 metadata: { 37 name: context.name 38 annotations: "kubernetes.io/ingress.class": parameter.class 39 } 40 spec: rules: [{ 41 host: parameter.domain 42 http: paths: [ 43 for k, v in parameter.http { 44 path: k 45 pathType: "ImplementationSpecific" 46 backend: service: { 47 name: context.name 48 port: number: v 49 } 50 }, 51 ] 52 }] 53 } 54 55 parameter: { 56 // +usage=Specify the domain you want to expose 57 domain: string 58 59 // +usage=Specify the mapping relationship between the http path and the workload port 60 http: [string]: int 61 62 // +usage=Specify the class of ingress to use 63 class: *"nginx" | string 64 } 65 status: 66 customStatus: |- 67 let igs = context.outputs.ingress.status.loadBalancer.ingress 68 if igs == _|_ { 69 message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + "'\n" 70 } 71 if len(igs) > 0 { 72 if igs[0].ip != _|_ { 73 message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip 74 } 75 if igs[0].ip == _|_ { 76 message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host 77 } 78 } 79 healthPolicy: 'isHealth: len(context.outputs.service.spec.clusterIP) > 0' 80