github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/deprecated/ingress.cue (about)

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