// Module included in the following assemblies:
//
// assembly-address-space-examples.adoc

[id='ref-address-space-example-exposing-endpoints-{context}']
= Address space example exposing endpoints externally 

This address space example shows how you can configure the external endpoints of an `AddressSpace`
to access messaging endpoints outside the {KubePlatform} cluster.

ifeval::["{cmdcli}" =="oc"]
== OpenShift route example

To expose `AddressSpace` endpoints through {KubePlatform} `LoadBalancer` services, the `loadbalancer` type is used:

[source,yaml,options="nowrap"]
----
apiVersion: enmasse.io/v1beta1
kind: AddressSpace
metadata:
  name: myspace
spec:
  type: standard
  plan: standard-unlimited
  authenticationService:
    name: standard-authservice
  endpoints:
  - name: messaging <1>
    service: messaging <2>
    expose:
     type: loadbalancer <3>
     loadBalancerPorts: <4>
     - amqp
     - amqps
    annotations: <5>
      mykey: myvalue
    loadBalancerSourceRanges: <6>
    - 10.0.0.0/8
----
<1> (Required) The name of the endpoint. The name specified affects the name of the {KubePlatform} service to be created as well as the name of the endpoint in the status section of the `AddressSpace`.
<2> (Required) The service names that must be configured for the `AddressSpace`.  The service can either be `messaging`, `console`, or `mqtt`. However, the `mqtt` service is supported for the `standard` address space type only.
<3> (Required) The type of endpoint being exposed. The `loadbalancer` type will create an {Kubernetes} `LoadBalancer` service. Valid values are `route` and `loadbalancer`.
<4> (Required) A list of the ports to be exposed on the `LoadBalancer` service. For `messaging`, `amqp` and `amqps` can be specified.
<5> (Optional) A set of key-value annotation pairs that are added to the `LoadBalancer` `Service` object.
<6> (Optional) The allowed source ranges that are accepted by the load balancer.
endif::[]

== {KubePlatform} `LoadBalancer` service example

To expose `AddressSpace` endpoints as OpenShift routes, the `route` type is used:

[source,yaml,options="nowrap"]
----
apiVersion: enmasse.io/v1beta1
kind: AddressSpace
metadata:
  name: myspace
spec:
  type: standard
  plan: standard-unlimited
  authenticationService:
    name: standard-authservice
  endpoints:
  - name: messaging <1>
    service: messaging <2>
    expose:
     type: route
     routeServicePort: amqps <3>
     routeTlsTermination: passthrough <4>
     routeHost: messaging.example.com <5>
----
<1> (Required) The name of the endpoint. The name specified affects the name of the {KubePlatform} service to be created as well as the name of the endpoint in the status section of the `AddressSpace`.
<2> (Required) The service names that must be configured for the `AddressSpace`.  The service can either be `messaging`, `console`, or `mqtt`. However, the `mqtt` service is supported for the `standard` address space type only.
<3> (Required) The name of the port to be exposed. With the `route` type, only a single TLS-enabled port can be specified. For the `messaging` service, either `amqps` and `https` can be specified. For the `console` service, only `https` can be specified.
<4> (Required) The TLS termination policy to be used for the OpenShift route. For the `messaging` service, the `amqps` port requires `passthrough` to be used, whereas `https` (websockets) also allows `reencrypt`. For the `console` service, `reencrypt` can be used.
<5> (Optional) The hostname to use for the created route.
