github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/workflowstep/export-service.cue (about)

     1  import (
     2  	"vela/op"
     3  )
     4  
     5  "export-service": {
     6  	type: "workflow-step"
     7  	annotations: {
     8  		"category": "Application Delivery"
     9  	}
    10  	labels: {
    11  		"scope": "Application"
    12  	}
    13  	description: "Export service to clusters specified by topology."
    14  }
    15  template: {
    16  	meta: {
    17  		name:      *context.name | string
    18  		namespace: *context.namespace | string
    19  		if parameter.name != _|_ {
    20  			name: parameter.name
    21  		}
    22  		if parameter.namespace != _|_ {
    23  			namespace: parameter.namespace
    24  		}
    25  	}
    26  	objects: [{
    27  		apiVersion: "v1"
    28  		kind:       "Service"
    29  		metadata:   meta
    30  		spec: {
    31  			type: "ClusterIP"
    32  			ports: [{
    33  				protocol:   "TCP"
    34  				port:       parameter.port
    35  				targetPort: parameter.targetPort
    36  			}]
    37  		}
    38  	}, {
    39  		apiVersion: "v1"
    40  		kind:       "Endpoints"
    41  		metadata:   meta
    42  		subsets: [{
    43  			addresses: [{ip: parameter.ip}]
    44  			ports: [{port: parameter.targetPort}]
    45  		}]
    46  	}] @step(1)
    47  
    48  	getPlacements: op.#GetPlacementsFromTopologyPolicies & {
    49  		policies: *[] | [...string]
    50  		if parameter.topology != _|_ {
    51  			policies: [parameter.topology]
    52  		}
    53  	} @step(2)
    54  
    55  	apply: op.#Steps & {
    56  		for p in getPlacements.placements {
    57  			for o in objects {
    58  				"\(p.cluster)-\(o.kind)": op.#Apply & {
    59  					value:   o
    60  					cluster: p.cluster
    61  				}
    62  			}
    63  		}
    64  	} @step(3)
    65  
    66  	parameter: {
    67  		// +usage=Specify the name of the export destination
    68  		name?: string
    69  		// +usage=Specify the namespace of the export destination
    70  		namespace?: string
    71  		// +usage=Specify the ip to be export
    72  		ip: string
    73  		// +usage=Specify the port to be used in service
    74  		port: int
    75  		// +usage=Specify the port to be export
    76  		targetPort: int
    77  		// +usage=Specify the topology to export
    78  		topology?: string
    79  	}
    80  }