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

     1  "pure-ingress": {
     2  	attributes: {
     3  		appliesToWorkloads: ["*"]
     4  		conflictsWith: []
     5  		podDisruptive: false
     6  		status: {
     7  			customStatus: #"""
     8  				let igs = context.outputs.ingress.status.loadBalancer.ingress
     9  				if igs == _|_ {
    10  					message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
    11  				}
    12  				if len(igs) > 0 {
    13  					if igs[0].ip != _|_ {
    14  						message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
    15  					}
    16  					if igs[0].ip == _|_ {
    17  						message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
    18  					}
    19  				}
    20  				"""#
    21  		}
    22  		workloadRefPath: ""
    23  	}
    24  	description: "Enable public web traffic for the component without creating a Service."
    25  	labels: {
    26  		"ui-hidden":  "true"
    27  		"deprecated": "true"
    28  	}
    29  	type: "trait"
    30  }
    31  
    32  template: {
    33  	outputs: ingress: {
    34  		apiVersion: "networking.k8s.io/v1beta1"
    35  		kind:       "Ingress"
    36  		metadata:
    37  			name: context.name
    38  		spec: {
    39  			rules: [{
    40  				host: parameter.domain
    41  				http: {
    42  					paths: [
    43  						for k, v in parameter.http {
    44  							path: k
    45  							backend: {
    46  								serviceName: context.name
    47  								servicePort: v
    48  							}
    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  }