restructure documentation
This commit is contained in:
parent
98a314803c
commit
b7924280b8
|
@ -0,0 +1,316 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway Gateway
|
||||
description: >-
|
||||
Consul API Gateway Gateway
|
||||
---
|
||||
|
||||
# Gateway
|
||||
|
||||
This topic provides full details about the `Gateway` resource.
|
||||
|
||||
## Introduction
|
||||
|
||||
A `Gateway` is an instance of network infrastructure that determines how service traffic should be handled. A `Gateway` contains one or more `listeners` that bind to a set of IP addresses. An `HTTPRoute` or `TCPRoute` can then attach to a gateway listener to direct traffic from the gateway to a service.
|
||||
|
||||
Gateway instances derive their configurations from the `GatewayClass` resource, which acts as a template for individual `Gateway` deployments. Refer to [GatewayClass](/docs/api-gateway/configuration/gatewayclass) for additional information.
|
||||
|
||||
Specify the following parameters to declare a Gateway:
|
||||
|
||||
| Parameter | Description | Required |
|
||||
|:-----------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------:|
|
||||
| kind | Specifies the type of configuration object. The value should always be Gateway | Required |
|
||||
| description | Human-readable string for describing the purpose of the Gateway. | Optional |
|
||||
| version | Specifies the Kubernetes API version. The value should always be gateway.networking.k8s.io/v1alpha2 | Required |
|
||||
| scope | Specifies the effective scope of the Gateway. The value should always be namespaced. | Required |
|
||||
| fields | Specifies the configurations for the Gateway. The fields are listed in the Configuration model. Details for each field are described in the Specification. | Required |
|
||||
|
||||
|
||||
|
||||
## Configuration model
|
||||
|
||||
* gatewayClassName: string | required
|
||||
* listeners: array of objects | required
|
||||
* allowedRoutes: object | required
|
||||
* namespaces: object | required
|
||||
* from: string | required
|
||||
* selector: object | required if from is configured to selector
|
||||
* matchExpressions: array of objects | required if matchLabels is not configured
|
||||
* key: string | required if matchExpressions is declared
|
||||
* operator: string | required if matchExpressions is declared
|
||||
* values: array of strings | required if matchExpressions is declared
|
||||
* matchLabels: map of strings | required if matchExpressions is not configured
|
||||
* hostname: string | required
|
||||
* name: string | required
|
||||
* port: integer | required
|
||||
* protocol: string | required
|
||||
* tls: object | required if protocol is set to HTTPS
|
||||
* certificateRefs: array or objects | required if tls is declared
|
||||
* name: string | required if certificateRefs is declared
|
||||
* namespace: string | required if certificateRefs is declared
|
||||
* mode: string | required if certificateRefs is declared
|
||||
* options: map of strings | optional
|
||||
|
||||
## Specification
|
||||
|
||||
This topic provides details about the configuration parameters
|
||||
|
||||
### gatewayClassName
|
||||
Specifies the name of the `GatewayClass` resource used for the `Gateway` instance.
|
||||
* Type: string
|
||||
* Required: required
|
||||
|
||||
### listeners
|
||||
Specifies the `listeners` associated with the `Gateway`. At least one `listener` must be specified. Each `listener` within a `Gateway` must have a unique combination of `hostname`, `port`, and `protocol`.
|
||||
|
||||
* Type: array of objects
|
||||
* Required: required
|
||||
|
||||
### listeners.allowedRoutes
|
||||
Specifies a `namespace` object that defines the types of routes that may be attached to a listener.
|
||||
* Type: object
|
||||
* Required: required
|
||||
|
||||
### listeners.allowedRoutes.namespaces
|
||||
Determines which routes are allowed to attach to the `listener`. Only routes in the same namespace as the `Gateway` may be attached by default.
|
||||
|
||||
### listeners.allowedRoutes.namespaces.from
|
||||
Specifies the policy for which namespaces a route may attach to a `Gateway` from. Defaults to `Same`.
|
||||
|
||||
This parameter has the following properties:
|
||||
* Type: string
|
||||
* Required: required
|
||||
|
||||
You can specify one of the following strings:
|
||||
* All: Routes in all namespaces may be attached to the Gateway.
|
||||
* Same: Only routes in the same namespace as the Gateway may be attached.
|
||||
* Selector: Only routes in namespaces that match the selector configuration may be attached.
|
||||
|
||||
### listeners.allowedRoutes.namespaces.selector
|
||||
The `selector` configuration matches zero or more namespaces that determine which routes are allowed to attach to the listener.
|
||||
* Type: Object
|
||||
* Required: Required when from is configured to selector.
|
||||
|
||||
The selector configuration contains one of the following objects:
|
||||
* matchExpressions
|
||||
* matchLabels
|
||||
|
||||
### listeners.allowedRoutes.namespaces.selector.matchExpressions
|
||||
Specifies an array of requirements for matching namespaces. If a match is found, then routes from the matching namespace(s) are allowed to attach to the `Gateway`. The following table describes members of the `matchExpressions` array:
|
||||
|
||||
| Requirement | Description | Type |
|
||||
|:-----------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------:|
|
||||
| key | Specifies that label that the key applies to. | string |
|
||||
| operator | Specifies the key's relation to a set of values. The following values are valid:In: description of what this means NotIn: description of what this means Exists: description of what this means DoesNotExist: description of what this means | string |
|
||||
| values | Specifies an array of string values. If the operator is configured to In or NotIn,the values array must be non-empty. If theoperator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. | array of strings |
|
||||
| scope | Specifies the effective scope of the Gateway. The value should always be namespaced. | Required |
|
||||
| fields | Specifies the configurations for the Gateway. The fields are listed in the Configuration model. Details for each field are described in the Specification. | Required |
|
||||
|
||||
```yaml
|
||||
namespaceSelector:
|
||||
matchExpressions:
|
||||
- key: kubernetes.io/metadata.name
|
||||
operator: In
|
||||
values:
|
||||
- foo
|
||||
- bar
|
||||
```
|
||||
|
||||
### listeners.allowedRoutes.namespaces.selector.matchLabels
|
||||
Specifies an array of labels and label values. If a match is found, then routes with the matching label(s) are allowed to attach to the `Gateway`. This selector can contain any arbitrary key/value pair.
|
||||
|
||||
```yaml
|
||||
namespaceSelector:
|
||||
matchLabels:
|
||||
foo: bar
|
||||
```
|
||||
|
||||
For more on labels, see [Labels and Selectors](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/)
|
||||
|
||||
### listeners.hostname
|
||||
Specifies the `listeners` hostname
|
||||
* Type: string
|
||||
* Required: required
|
||||
|
||||
### listeners.name
|
||||
Specifies the `listeners` name
|
||||
* Type: string
|
||||
* Required: required
|
||||
|
||||
### listeners.port
|
||||
Specifies the port number that the `listener` will attach to
|
||||
* Type: integer
|
||||
* Required: required
|
||||
|
||||
### listeners.protocol
|
||||
Specifies the protocol the `listener` will use
|
||||
* Type: string
|
||||
* Required: required
|
||||
|
||||
Allowed values `TCP`, `HTTP`, `HTTPS`
|
||||
|
||||
### listeners.tls
|
||||
* Type: Object
|
||||
* Required: required if protocol is set to HTTPS
|
||||
|
||||
### listeners.tls.certificateRefs
|
||||
`CertificateRefs` contains a series of references to Kubernetes objects that contains TLS certificates and private keys. These certificates are used to establish a TLS handshake for requests that match the hostname of the associated `listener`. Each reference must be a Kubernetes Secret, and, if using a Secret in a namespace other than the`Gateway`'s, must have a corresponding `ReferencePolicy` created.
|
||||
* Type: Object or Array
|
||||
* Required: required if tls is set
|
||||
|
||||
### listeners.tls.mode
|
||||
* Type: String
|
||||
* Required: required if certificateRefs is set
|
||||
|
||||
### listeners.tls.options
|
||||
* Type: Map of Strings
|
||||
* Required: optional
|
||||
|
||||
## Complete configuration
|
||||
The following example shows a fully configured Gateway.
|
||||
|
||||
```yaml
|
||||
kind: Gateway
|
||||
Description: This gateway enables traffic from A to B.
|
||||
version: gateway.networking.k8s.io/v1alpha2
|
||||
scope: Namespaced
|
||||
fields:
|
||||
- name: addresses
|
||||
supported: false
|
||||
- name: gatewayClassName
|
||||
type: string
|
||||
description: Name of a GatewayClass resource used for this Gateway.
|
||||
- name: listeners
|
||||
type: array<object>
|
||||
description: |
|
||||
Description of the listeners associated with this Gateway.
|
||||
items:
|
||||
fields:
|
||||
- name: allowedRoutes
|
||||
type: object
|
||||
description: |
|
||||
AllowedRoutes defines the types of routes that
|
||||
MAY be attached to a Listener and the trusted namespaces where
|
||||
those Route resources MAY be present.
|
||||
fields:
|
||||
- name: kinds
|
||||
supported: false
|
||||
- name: namespaces
|
||||
type: object
|
||||
description: |
|
||||
Description of namespaces from which routes may be attached to this Listener. This is restricted
|
||||
to the namespace of this Gateway by default.
|
||||
fields:
|
||||
- name: from
|
||||
type: string
|
||||
default: Same
|
||||
description: |
|
||||
From indicates where Routes will be selected
|
||||
for this Gateway."
|
||||
enum: ["All", "Selector", "Same"]
|
||||
- name: selector
|
||||
type: object
|
||||
description: "Selector must be specified when From is
|
||||
set to \"Selector\". In that case, only Routes in
|
||||
Namespaces matching this Selector will be selected
|
||||
by this Gateway."
|
||||
fields:
|
||||
- name: matchExpressions
|
||||
type: array<object>
|
||||
description: |
|
||||
matchExpressions is a list of label
|
||||
selector requirements. The requirements are ANDed.
|
||||
items:
|
||||
fields:
|
||||
- name: key
|
||||
type: string
|
||||
description: |
|
||||
key is the label key that the
|
||||
selector applies to.
|
||||
- name: operator
|
||||
type: string
|
||||
description: |
|
||||
operator represents a key's relationship
|
||||
to a set of values. Valid operators are
|
||||
In, NotIn, Exists and DoesNotExist.
|
||||
- name: values
|
||||
type: array<string>
|
||||
description: |
|
||||
values is an array of string
|
||||
values. If the operator is In or NotIn,
|
||||
the values array must be non-empty. If the
|
||||
operator is Exists or DoesNotExist, the
|
||||
values array must be empty. This array is
|
||||
replaced during a strategic merge patch.
|
||||
- name: matchLabels
|
||||
type: map<string, string>
|
||||
description: |
|
||||
matchLabels is a map of {key,value}
|
||||
pairs. A single {key,value} in the matchLabels
|
||||
map is equivalent to an element of matchExpressions,
|
||||
whose key field is "key", the operator is "In",
|
||||
and the values array contains only "value". The
|
||||
requirements are ANDed.
|
||||
- name: hostname
|
||||
type: string
|
||||
description: |
|
||||
Hostname specifies the virtual hostname to match for HTTP or HTTPS-based listeners. When unspecified,
|
||||
all hostnames are matched. This is implemented by checking the HTTP Host header sent on a client request.
|
||||
- name: name
|
||||
type: string
|
||||
description: "Name is the name of the Listener. This name MUST be unique within a Gateway."
|
||||
- name: port
|
||||
type: integer
|
||||
description: "Port is the network port of a listener."
|
||||
- name: protocol
|
||||
type: string
|
||||
description: "Protocol specifies the network protocol this listener expects to receive."
|
||||
enum: ["HTTP", "HTTPS", "TCP"]
|
||||
- name: tls
|
||||
type: object
|
||||
description: |
|
||||
TLS is the TLS configuration for the Listener.
|
||||
This field is required if the Protocol field is "HTTPS".
|
||||
It is invalid to set this field if the Protocol
|
||||
field is "HTTP" or "TCP".
|
||||
fields:
|
||||
- name: certificateRefs
|
||||
type: array<object>
|
||||
description: |
|
||||
CertificateRefs contains a series of references
|
||||
to Kubernetes objects that contains TLS certificates and
|
||||
private keys. These certificates are used to establish
|
||||
a TLS handshake for requests that match the hostname of
|
||||
the associated listener. Each reference must be a Kubernetes
|
||||
Secret, and, if using a Secret in a namespace other than the
|
||||
Gateway's, must have a corresponding ReferencePolicy created.
|
||||
items:
|
||||
fields:
|
||||
- name: group
|
||||
supported: false
|
||||
- name: kind
|
||||
supported: false
|
||||
- name: name
|
||||
type: string
|
||||
description: Name is the name of the Kubernetes Secret.
|
||||
- name: namespace
|
||||
type: string
|
||||
description: |
|
||||
Namespace is the namespace of the Secret. When unspecified, the local namespace is inferred.
|
||||
|
||||
Note that when a namespace is specified, a ReferencePolicy
|
||||
object is required in the specified namespace to
|
||||
allow that namespace's owner to accept the reference.
|
||||
- name: mode
|
||||
type: string
|
||||
default: Terminate
|
||||
description: "Mode defines the TLS behavior for the TLS session initiated by the client. The only supported mode at this time is `Terminate`"
|
||||
enum: ["Terminate"]
|
||||
- name: options
|
||||
type: map<string, string>
|
||||
description: |
|
||||
Options are a list of key/value pairs to enable
|
||||
extended TLS configuration for each implementation.
|
||||
enum: ["api-gateway.consul.hashicorp.com/tls_min_version","api-gateway.consul.hashicorp.com/tls_max_version","api-gateway.consul.hashicorp.com/tls_cipher_suites",]
|
||||
```
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway GatewayClass
|
||||
description: >-
|
||||
Consul API Gateway GatewayClass
|
||||
---
|
||||
|
||||
# GatewayClass
|
||||
|
||||
The `GatewayClass` resource is used as a template for creating `Gateway` resources.
|
||||
The specification includes the name of the controller (`controllerName`) and an API object containing controller-specific configuration resources within the cluster (`parametersRef`).
|
||||
The value of the `controllerName` field must be set to `hashicorp.com/consul-api-gateway-controller`.
|
||||
|
||||
When gateways are created from a `GatewayClass`, they use the parameters specified in the `GatewayClass` at the time of instantiation.
|
||||
|
||||
Add the `kind: GatewayClass` option to the the gateway values file to declare a gateway class.
|
||||
The following example creates a gateway class called `test-gateway-class`:
|
||||
|
||||
<CodeBlockConfig filename="gateway.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: GatewayClass
|
||||
metadata:
|
||||
name: test-gateway-class
|
||||
spec:
|
||||
controllerName: 'hashicorp.com/consul-api-gateway-controller'
|
||||
parametersRef:
|
||||
group: api-gateway.consul.hashicorp.com
|
||||
kind: GatewayClassConfig
|
||||
name: test-gateway-class-config
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
Refer to the [Kubernetes Gateway API documentation](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.GatewayClass) for details about configuring gateway classes.
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway GatewayClassConfig
|
||||
description: >-
|
||||
Consul API Gateway GatewayClassConfig
|
||||
---
|
||||
|
||||
# GatewayClassConfig
|
||||
|
||||
The `GatewayClassConfig` object describes Consul API Gateway-related configuration parameters for the [`GatewayClass`](#gatewayclass).
|
||||
|
||||
Add the `kind: GatewayClassConfig` option to the gateway values file to declare a gateway class.
|
||||
The following example creates a gateway class configuration called `test-gateway-class-config`:
|
||||
|
||||
<CodeBlockConfig filename="gateway.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: api-gateway.consul.hashicorp.com/v1alpha1
|
||||
kind: GatewayClassConfig
|
||||
metadata:
|
||||
name: test-gateway-class-config
|
||||
spec:
|
||||
useHostPorts: true
|
||||
logLevel: 'trace'
|
||||
consul:
|
||||
scheme: 'https'
|
||||
ports:
|
||||
http: 8501
|
||||
grpc: 8502
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
The following table describes the allowed parameters for the `spec` array:
|
||||
|
||||
| Parameter | Description | Type | Default |
|
||||
| --- | --- | ---- | ------- |
|
||||
| `consul.address` | Specifies the address of the Consul server to communicate with in the gateway pod. If unspecified, the pod will attempt to use a local agent on the host on which the pod is running. | String | N/A |
|
||||
| `consul.authentication.account` | Specifies the Kubernetes service account to use for authentication. | String | N/A |
|
||||
| `consul.authentication.managed` | Set to `true` to enable deployments to run with managed service accounts created by the gateway controller. The `consul.authentication.account` field is ignored when this option is enabled. | Boolean | `false` |
|
||||
| `consul.authentication.method` | Specifies the Consul auth method used for initial authentication by Consul API Gateway. | String | N/A |
|
||||
| `consul.authentication.namespace` | Specifies the Consul namespace to use for authentication. | String | N/A |
|
||||
| `consul.ports.grpc` | Specifies the gRPC port for Consul's xDS server. | Integer | `8502` |
|
||||
| `consul.ports.http` | Specifies the port for Consul's HTTP server. | Integer | `8500` |
|
||||
| `consul.scheme` | Specifies the scheme to use for connecting to Consul. The supported values are `"http"` and `"https"`. | String | `"http"` |
|
||||
| `copyAnnotations.service` | List of annotations to copy to the gateway service. | Array | `["external-dns.alpha.kubernetes.io/hostname"]` |
|
||||
| `deployment.defaultInstances` | Specifies the number of instances to deploy by default for each gateway. | Integer | 1 |
|
||||
| `deployment.maxInstances` | Specifies the maximum allowed number of instances per gateway. | Integer | 8 |
|
||||
| `deployment.minInstances` | Specifies the minimum allowed number of instances per gateway. | Integer | 1 |
|
||||
| `image.consulAPIGateway` | The image to use for consul-api-gateway. View available image tags on [DockerHub](https://hub.docker.com/r/hashicorp/consul-api-gateway/tags). | String | `"hashicorp/consul-api-gateway:RELEASE_VERSION"` |
|
||||
| `image.envoy` | Specifies the container image to use for Envoy. View available image tags on [DockerHub](https://hub.docker.com/r/envoyproxy/envoy/tags). | String | `"envoyproxy/envoy:RELEASE_VERSION"` |
|
||||
| `logLevel` | Specifies the error reporting level for logs. You can specify the following values: `error`, `warning`, `info`, `debug`, `trace`. | String | `"info"` |
|
||||
| `nodeSelector` | Specifies a set of parameters that constrain the nodes on which the pod can run. Defining nodes with the `nodeSelector` enables the pod to fit on a node. The selector must match a node's labels for the pod to be scheduled on that node. Refer to the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/) for additional information. | Object | N/A |
|
||||
| `serviceType` | Specifies the ingress methods for a service. The following values are supported: <br/>`ClusterIP` <br/>`NodePort` <br/>`LoadBalancer`. | String | N/A |
|
||||
| `useHostPorts` | If set to `true`, then the Envoy container ports are mapped to host ports. | Boolean | `false` |
|
||||
|
||||
Refer to the [Consul API Gateway repository](https://github.com/hashicorp/consul-api-gateway/blob/main/config/crd/bases/api-gateway.consul.hashicorp.com_gatewayclassconfigs.yaml) for the complete specification.
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway Configuration
|
||||
description: >-
|
||||
Consul API Gateway Configuration
|
||||
---
|
||||
|
||||
# Configuration
|
||||
|
||||
This topic provides an overview of the configuration items that enable Consul API Gateway to facilitate ingress into your Consul service mesh.
|
||||
|
||||
- [Gateway](/docs/api-gateway/configuration/gateway): Defines the main infrastructure resource that links API gateway components. It specifies the name of the `GatewayClass` and one or more listeners (see [Listeners](/docs/api-gateway/configuration/gateway#listeners)), which specify the logical endpoints bound to the gateway's addresses. Refer to Configuration > Gateway for details on configuration.
|
||||
- [GatewayClassConfig](/docs/api-gateway/configuration/gatewayclassconfig): Describes additional Consul API Gateway-related configuration parameters for the GatewayClass resource.
|
||||
- [GatewayClass](/docs/api-gateway/configuration/gatewayclass): Defines a class of gateway resources that you can use as a template for creating gateways.
|
||||
- [Routes](/docs/api-gateway/configuration/routes): Specifies the path from the gateway to the backend service(s)client to the listener.
|
||||
|
||||
<!--TODO add diagram -->
|
|
@ -0,0 +1,89 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway Routes
|
||||
description: >-
|
||||
Consul API Gateway Routes
|
||||
---
|
||||
|
||||
# Route
|
||||
|
||||
Routes are independent configuration objects that are associated with specific listeners.
|
||||
|
||||
Declare a route with either `kind: HTTPRoute` or `kind: TCPRoute` and configure the route parameters in the `spec` block.
|
||||
Refer to the Kubernetes Gateway API documentation for each object type for details:
|
||||
|
||||
- [HTTPRoute](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute)
|
||||
- [TCPRoute](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.TCPRoute)
|
||||
|
||||
The following example creates a route named `example-route` associated with a listener defined in `example-gateway`.
|
||||
|
||||
<CodeBlockConfig filename="routes.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: example-route
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: example-gateway
|
||||
rules:
|
||||
- backendRefs:
|
||||
- kind: Service
|
||||
name: echo
|
||||
port: 8080
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
To create a route for a `backendRef` in a different namespace, you must also
|
||||
create a [ReferencePolicy](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.ReferencePolicy).
|
||||
|
||||
The following example creates a route named `example-route` in namespace `gateway-namespace`. This route has a `backendRef` in namespace `service-namespace`. Traffic is allowed because the `ReferencePolicy`, named `reference-policy` in namespace `service-namespace`, allows traffic from `HTTPRoutes` in `gateway-namespace` to `Services` in `service-namespace`.
|
||||
|
||||
<CodeBlockConfig filename="route_with_referencepolicy.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: example-route
|
||||
namespace: gateway-namespace
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: example-gateway
|
||||
rules:
|
||||
- backendRefs:
|
||||
- kind: Service
|
||||
name: echo
|
||||
namespace: service-namespace
|
||||
port: 8080
|
||||
---
|
||||
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: ReferencePolicy
|
||||
metadata:
|
||||
name: reference-policy
|
||||
namespace: service-namespace
|
||||
spec:
|
||||
from:
|
||||
- group: gateway.networking.k8s.io
|
||||
kind: HTTPRoute
|
||||
namespace: gateway-namespace
|
||||
to:
|
||||
- group: ""
|
||||
kind: Service
|
||||
name: echo
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
## MeshService
|
||||
|
||||
The `MeshService` configuration holds a reference to an externally-managed Consul service mesh service and can be used as a `backendRef` for a [`Route`](#route).
|
||||
|
||||
| Parameter | Description | Type | Default |
|
||||
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------- |
|
||||
| `name` | Specifies the service name for a Consul service. It is assumed this service will exist in either the `consulDestinationNamespace` or mirrored Consul namespace from where this custom resource is defined, depending on the Helm configuration.
|
||||
|
||||
Refer to the [Consul API Gateway repository](https://github.com/hashicorp/consul-api-gateway/blob/main/config/crd/bases/api-gateway.consul.hashicorp.com_meshservices.yaml) for the complete specification.
|
|
@ -11,7 +11,64 @@ This topic describes how to use the Consul API Gateway add-on module. It include
|
|||
|
||||
## Requirements
|
||||
|
||||
Ensure that the environment you are deploying Consul API Gateway in meets the requirements listed in the [Technical Specifications][tech-specs]. This includes validating that the requirements for minimum versions of software are met. See the [Release Notes][rel-notes] for the version of API Gateway you are deploying.
|
||||
Verify that your environment meets the following requirements prior to using Consul API Gateway.
|
||||
|
||||
### Datacenter Requirements
|
||||
|
||||
Your datacenter must meet the following requirements prior to configuring the Consul API Gateway:
|
||||
|
||||
- Kubernetes 1.21+
|
||||
- Kubernetes 1.24 is not supported at this time.
|
||||
- `kubectl` 1.21+
|
||||
- Consul 1.11.2+
|
||||
- HashiCorp Consul Helm chart 0.45.0+
|
||||
- Consul Service Mesh must be deployed on the Kubernetes cluster that API Gateway is deployed on.
|
||||
- Envoy: Envoy proxy support is determined by the Consul version deployed. Refer to [Envoy Integration](/docs/connect/proxies/envoy) for details.
|
||||
|
||||
### TCP Port Requirements
|
||||
|
||||
The following table describes the TCP port requirements for each component of the API Gateway.
|
||||
|
||||
| Port | Description | Component |
|
||||
| ---- | ----------- | --------- |
|
||||
| 9090 | Secret discovery service (SDS) | Gateway controller pod <br/> Gateway instance pod |
|
||||
| 20000 | Kubernetes readiness probe | Gateway instance pod |
|
||||
| Configurable | Port for scraping Prometheus metrics. Disabled by default. | Gateway controller pod |
|
||||
|
||||
## Consul Server Deployments
|
||||
|
||||
- Consul Editions supported: OSS and Enterprise
|
||||
- Supported Consul Server deployment types:
|
||||
- Self-Managed
|
||||
- HCP Consul
|
||||
|
||||
## Deployment Environments
|
||||
|
||||
Consul API Gateway can be deployed in the following Kubernetes-based environments:
|
||||
|
||||
- Generic Kubernetes
|
||||
- AWS Elastic Kubernetes Service (EKS)
|
||||
- Google Kubernetes Engine (GKE)
|
||||
- Azure Kubernetes Service (AKS)
|
||||
|
||||
## Kubernetes Gateway API Specification - Supported Versions
|
||||
|
||||
See the Release Notes for the version of Consul API Gateway being used.
|
||||
|
||||
## Resource Allocations
|
||||
|
||||
The following resources are allocated for each component of the API Gateway.
|
||||
|
||||
### Gateway Controller Pod
|
||||
|
||||
- **CPU**: None. Either the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
- **Memory**: None. Either the the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
|
||||
### Gateway Instance Pod
|
||||
|
||||
- **CPU**: None. Either the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
- **Memory**: None. Either the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -47,379 +104,9 @@ Ensure that the environment you are deploying Consul API Gateway in meets the re
|
|||
$ helm install consul hashicorp/consul --version 0.45.0 --values values.yaml --create-namespace --namespace consul
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1. Verify that the [requirements](#requirements) have been met.
|
||||
1. Verify that the Consul API Gateway CRDs and controller have been installed and applied (see [Installation](#installation)).
|
||||
1. Configure the artifacts described below in [Configuration](#configuration).
|
||||
|
||||
<CodeBlockConfig hideClipboard filename="values.yaml">
|
||||
|
||||
```yaml
|
||||
apiGateway:
|
||||
managedGatewayClass:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
1. Issue the `kubectl apply` command to implement the configurations, e.g.:
|
||||
|
||||
```shell-session
|
||||
$ kubectl apply -f gateway.yaml routes.yaml
|
||||
```
|
||||
|
||||
<!--- Commented out per https://github.com/hashicorp/consul/pull/11951/files#r791204596
|
||||
|
||||
### Using the Consul API Gateway Binary
|
||||
|
||||
You can download the Consul API Gateway binary and use it to manually start the control plane server.
|
||||
|
||||
1. Download the binary from the [Consul API Gateway repository](https://github.com/hashicorp/consul-api-gateway).
|
||||
1. Navigate to the `consul-api-gateway-main` directory and build the binary:
|
||||
|
||||
```shell-session
|
||||
$ go build
|
||||
```
|
||||
|
||||
1. (Optional) Copy the binary to the execution path, e.g.:
|
||||
|
||||
```shell-session
|
||||
$ cp consul-api-gateway /usr/bin
|
||||
```
|
||||
|
||||
1. Use the `server` command to interact with the Consul API Gateway binary:
|
||||
|
||||
```shell-session
|
||||
$ ./consul-api-gateway server <options>
|
||||
```
|
||||
|
||||
The following options are supported:
|
||||
|
||||
| Option | Description | Required | Default |
|
||||
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------- |
|
||||
| `-ca-file` | String value that specifies the path to the CA for the Consul server. | Required | none |
|
||||
| `-ca-secret` | String value that specifies the CA secret for the Consul server. | Required | none |
|
||||
| `-ca-secret-namespace` | String value that specifies the CA secret namespace for the Consul server. | Required | none |
|
||||
| `-k8-context` | String value that specifies the Kubernetes context to use when starting the Consul server. | Optional | current context |
|
||||
| `-k8-namespace` | String value that specifies the Kubernetes namespace to use when starting the Consul server. | Optional | `default` |
|
||||
| `-log-json` | Boolean value that enables or disables JSON format for the log output. | Required | `false` |
|
||||
| `-log-level` | String value that specifies the logging level. The following values are supported: <br/>- `trace` (highest level of detail) <br/>- `debug` <br/>- `info` <br/>- `warn` <br/>- `error` | Optional | `info` |
|
||||
| `-metrics-port` | Integer value that specifies the port number for collecting metrics. | Optional | none |
|
||||
| `-pprof` | Integer value that specifies the Go pprof port number for collecting metrics. | Optional | none |
|
||||
| `-sds-server-host` | String value that specifies the host server for the secret discovery service (SDS). | Optional | `consul-api-gateway-controller.default.`<br/>`svc.cluster.`<br/>`local` |
|
||||
| `-sds-server-host` | Integer value that specifies the port number for the secret discovery service (SDS). | Optional | `9090` |
|
||||
|
||||
You can also issue the `version` command to print the Consul API Gateway version to the console:
|
||||
|
||||
```shell-session
|
||||
$ ./consul-api-gateway version
|
||||
consul-api-gateway 0.1.0
|
||||
```
|
||||
--->
|
||||
|
||||
## Configuration
|
||||
|
||||
Configure the following artifacts to facilitate ingress into your Consul service mesh:
|
||||
|
||||
- [GatewayClassConfig](#gatewayclassconfig): Describes additional Consul API Gateway-related configuration parameters for the `GatewayClass` resource.
|
||||
- [GatewayClass](#gatewayclass): Defines a class of gateway resources that you can use as a template for creating gateways.
|
||||
- [Gateway](#gateway): Defines the main infrastructure resource that links API gateway components. It specifies the name of the `GatewayClass` and one or more `listeners` (see [Listeners](#listeners)), which specify the logical endpoints bound to the gateway's addresses.
|
||||
- [Routes](#routes): Specifies the path from the client to the listener.
|
||||
|
||||
-> **Note:** Add the following `managedGatewayClass` configuration to the `values.yaml` Helm configuration to enable the `GatewayClassConfig` and `GatewayClass` to be created automatically. The gateway, listeners, and routes will need to be configured manually. When `managedGatewayClass` is enabled, the [`serviceType`](/docs/k8s/helm#v-apigateway-managedgatewayclass-servicetype) for a managed `GatewayClass` will also default to `LoadBalancer`, which is appropriate for most deployments to managed Kubernetes cloud offerings (i.e., EKS, GKE, AKS). Other deployments, such as to a [kind](https://kind.sigs.k8s.io/) cluster, may require specifying `NodePort` or `ClusterIP`, instead.
|
||||
|
||||
### GatewayClassConfig
|
||||
|
||||
The `GatewayClassConfig` object describes Consul API Gateway-related configuration parameters for the [`GatewayClass`](#gatewayclass).
|
||||
|
||||
Add the `kind: GatewayClassConfig` option to the gateway values file to declare a gateway class.
|
||||
The following example creates a gateway class configuration called `test-gateway-class-config`:
|
||||
|
||||
<CodeBlockConfig filename="gateway.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: api-gateway.consul.hashicorp.com/v1alpha1
|
||||
kind: GatewayClassConfig
|
||||
metadata:
|
||||
name: test-gateway-class-config
|
||||
spec:
|
||||
useHostPorts: true
|
||||
logLevel: 'trace'
|
||||
consul:
|
||||
scheme: 'https'
|
||||
ports:
|
||||
http: 8501
|
||||
grpc: 8502
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
The following table describes the allowed parameters for the `spec` array:
|
||||
|
||||
| Parameter | Description | Type | Default |
|
||||
| --- | --- | ---- | ------- |
|
||||
| `consul.address` | Specifies the address of the Consul server to communicate with in the gateway pod. If unspecified, the pod will attempt to use a local agent on the host on which the pod is running. | String | N/A |
|
||||
| `consul.authentication.account` | Specifies the Kubernetes service account to use for authentication. | String | N/A |
|
||||
| `consul.authentication.managed` | Set to `true` to enable deployments to run with managed service accounts created by the gateway controller. The `consul.authentication.account` field is ignored when this option is enabled. | Boolean | `false` |
|
||||
| `consul.authentication.method` | Specifies the Consul auth method used for initial authentication by Consul API Gateway. | String | N/A |
|
||||
| `consul.authentication.namespace` | Specifies the Consul namespace to use for authentication. | String | N/A |
|
||||
| `consul.ports.grpc` | Specifies the gRPC port for Consul's xDS server. | Integer | `8502` |
|
||||
| `consul.ports.http` | Specifies the port for Consul's HTTP server. | Integer | `8500` |
|
||||
| `consul.scheme` | Specifies the scheme to use for connecting to Consul. The supported values are `"http"` and `"https"`. | String | `"http"` |
|
||||
| `copyAnnotations.service` | List of annotations to copy to the gateway service. | Array | `["external-dns.alpha.kubernetes.io/hostname"]` |
|
||||
| `deployment.defaultInstances` | Specifies the number of instances to deploy by default for each gateway. | Integer | 1 |
|
||||
| `deployment.maxInstances` | Specifies the maximum allowed number of instances per gateway. | Integer | 8 |
|
||||
| `deployment.minInstances` | Specifies the minimum allowed number of instances per gateway. | Integer | 1 |
|
||||
| `image.consulAPIGateway` | The image to use for consul-api-gateway. View available image tags on [DockerHub](https://hub.docker.com/r/hashicorp/consul-api-gateway/tags). | String | `"hashicorp/consul-api-gateway:RELEASE_VERSION"` |
|
||||
| `image.envoy` | Specifies the container image to use for Envoy. View available image tags on [DockerHub](https://hub.docker.com/r/envoyproxy/envoy/tags). | String | `"envoyproxy/envoy:RELEASE_VERSION"` |
|
||||
| `logLevel` | Specifies the error reporting level for logs. You can specify the following values: `error`, `warning`, `info`, `debug`, `trace`. | String | `"info"` |
|
||||
| `nodeSelector` | Specifies a set of parameters that constrain the nodes on which the pod can run. Defining nodes with the `nodeSelector` enables the pod to fit on a node. The selector must match a node's labels for the pod to be scheduled on that node. Refer to the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/) for additional information. | Object | N/A |
|
||||
| `serviceType` | Specifies the ingress methods for a service. The following values are supported: <br/>`ClusterIP` <br/>`NodePort` <br/>`LoadBalancer`. | String | N/A |
|
||||
| `useHostPorts` | If set to `true`, then the Envoy container ports are mapped to host ports. | Boolean | `false` |
|
||||
|
||||
Refer to the [Consul API Gateway repository](https://github.com/hashicorp/consul-api-gateway/blob/main/config/crd/bases/api-gateway.consul.hashicorp.com_gatewayclassconfigs.yaml) for the complete specification.
|
||||
|
||||
### GatewayClass
|
||||
|
||||
The `GatewayClass` resource is used as a template for creating `Gateway` resources.
|
||||
The specification includes the name of the controller (`controllerName`) and an API object containing controller-specific configuration resources within the cluster (`parametersRef`).
|
||||
The value of the `controllerName` field must be set to `hashicorp.com/consul-api-gateway-controller`.
|
||||
|
||||
When gateways are created from a `GatewayClass`, they use the parameters specified in the `GatewayClass` at the time of instantiation.
|
||||
|
||||
Add the `kind: GatewayClass` option to the the gateway values file to declare a gateway class.
|
||||
The following example creates a gateway class called `test-gateway-class`:
|
||||
|
||||
<CodeBlockConfig filename="gateway.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: GatewayClass
|
||||
metadata:
|
||||
name: test-gateway-class
|
||||
spec:
|
||||
controllerName: 'hashicorp.com/consul-api-gateway-controller'
|
||||
parametersRef:
|
||||
group: api-gateway.consul.hashicorp.com
|
||||
kind: GatewayClassConfig
|
||||
name: test-gateway-class-config
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
Refer to the [Kubernetes Gateway API documentation](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.GatewayClass) for details about configuring gateway classes.
|
||||
|
||||
### Gateway
|
||||
|
||||
The gateway configuration is the main infrastructure resource that links API gateway components. It specifies the name of the `GatewayClass` and one or more `listeners`.
|
||||
|
||||
Add the `kind: Gateway` option to the configuration file to declare a gateway.
|
||||
The following example creates a gateway called `example-gateway`.
|
||||
The gateway is based on the `test-gateway-class` and includes a listener called `https` (see [Listeners](#listeners) for details about the `listener` configuration).
|
||||
|
||||
<CodeBlockConfig filename="gateway.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: example-gateway
|
||||
annotations:
|
||||
'external-dns.alpha.kubernetes.io/hostname': DNS_HOSTNAME
|
||||
spec:
|
||||
gatewayClassName: test-gateway-class
|
||||
listeners:
|
||||
- protocol: HTTPS
|
||||
hostname: DNS_HOSTNAME
|
||||
port: 443
|
||||
name: https
|
||||
allowedRoutes:
|
||||
namespaces:
|
||||
from: Same
|
||||
tls:
|
||||
certificateRefs:
|
||||
- name: gateway-production-certificate
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
For a listener's `certificateRef` to reference a secret in a different namespace, you must also create a [ReferencePolicy](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.ReferencePolicy).
|
||||
|
||||
The following example creates a `Gateway` named `example-gateway` in `gateway-namespace`. This `Gateway` has a `certificateRef` in `secret-namespace`.
|
||||
The reference is allowed because `reference-policy` in `secret-namespace` lets `Gateways` in `gateway-namespace` reference `Secrets` in `secret-namespace`.
|
||||
|
||||
<CodeBlockConfig filename="gateway_with_referencepolicy.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: example-gateway
|
||||
namespace: gateway-namespace
|
||||
annotations:
|
||||
'external-dns.alpha.kubernetes.io/hostname': DNS_HOSTNAME
|
||||
spec:
|
||||
gatewayClassName: test-gateway-class
|
||||
listeners:
|
||||
- protocol: HTTPS
|
||||
hostname: DNS_HOSTNAME
|
||||
port: 443
|
||||
name: https
|
||||
allowedRoutes:
|
||||
namespaces:
|
||||
from: Same
|
||||
tls:
|
||||
certificateRefs:
|
||||
- name: gateway-production-certificate
|
||||
namespace: secret-namespace
|
||||
---
|
||||
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: ReferencePolicy
|
||||
metadata:
|
||||
name: reference-policy
|
||||
namespace: secret-namespace
|
||||
spec:
|
||||
from:
|
||||
- group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
namespace: gateway-namespace
|
||||
to:
|
||||
- group: ""
|
||||
kind: Secret
|
||||
name: gateway-production-certificate
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
Refer to the [Kubernetes Gateway API documentation](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.Gateway) for further details about configuring gateways.
|
||||
|
||||
#### Listeners
|
||||
|
||||
Listeners are the logical endpoints bound to the gateway's addresses.
|
||||
Add the `listener` object to the `gateway` configuration and specify the following properties to define a listener:
|
||||
|
||||
| Parameter | Description | Type | Default |
|
||||
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------- |
|
||||
| `hostname` | Specifies the virtual hostname to match for protocol types. | String | none |
|
||||
| `port` | Specifies the network port number. | Integer | none |
|
||||
| `protocol` | Specifies the network protocol expected by the listener. | String | `http` |
|
||||
| `tls` | Collection of parameters that specify TLS options for the listener. Refer to the [`GatewayTLSConfig`](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.GatewayTLSConfig) documentation for additional information about configuring TLS. | Object | N/A |
|
||||
| `tls.mode` | Specifies a mode for operating Consul API Gateway listeners over TLS. <br/>You can only specify the `Terminate` mode, which configures the TLS session between the downstream client and the gateway to terminate at the gateway. <br/>Refer to the [`TLSModeType` documentation](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.TLSModeType) for additional information. | String | `Terminate` |
|
||||
| `tls.certificateRefs` | Specifies the name of secret object used for Envoy SDS (Secret Discovery Service) to support terminating TLS. Refer to the [`[]*SecretObjectReference` documentation](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.SecretObjectReference) for additional information. | String | N/A |
|
||||
| `tls.options` | Specifies key/value pairs to enable extended TLS configuration specific to an implementation. | Object | N/A |
|
||||
| `tls.options.tls_min_version` | Specifies the minimum TLS version supported for the listener. The following values are supported: `TLS_AUTO`, `TLSv1_0`, `TLSv1_1`, `TLSv1_2`, `TLSv1_3`. | String | `TLS 1.2` |
|
||||
| `tls.options.tls_max_version` | Specifies the maximum TLS version supported for the listener. The specified version must be greater than or equal to `TLSMinVersion`. The following values are supported: `TLS_AUTO`, `TLSv1_0`, `TLSv1_1`, `TLSv1_2`, `TLSv1_3`. | String | `TLS 1.3` |
|
||||
| `tls.options.tls_cipher_suites` | Specifies the list of TLS cipher suites to support when negotiating connections using TLS 1.2 or earlier. <br/>If unspecified, a [more secure set of cipher suites](https://github.com/hashicorp/consul-api-gateway/blob/main/internal/common/tls.go#L3-L10) than Envoy's current [default server cipher list](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/common.proto#envoy-v3-api-field-extensions-transport-sockets-tls-v3-tlsparameters-cipher-suites) will be used. <br/>The full list of supported cipher suites can seen in [`internal/common/tls.go`](https://github.com/hashicorp/consul-api-gateway/blob/main/internal/common/tls.go) and is dependent on underlying support in Envoy. | String | See description |
|
||||
|
||||
Refer to the [Kubernetes Gateway API documentation](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.Listener) for details about configuring listeners.
|
||||
|
||||
#### Scaling
|
||||
|
||||
You can scale a logical gateway object to multiple instances with the [`kubectl scale`](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#scaling-a-deployment) command. The object scales according to the bounds set in `GatewayClassConfig`.
|
||||
|
||||
```shell-session
|
||||
$ kubectl get deployment --selector api-gateway.consul.hashicorp.com/name=example-gateway
|
||||
NAME READY UP-TO-DATE AVAILABLE
|
||||
example-gateway 1/1 1 1
|
||||
```
|
||||
```shell-session
|
||||
$ kubectl scale deployment/example-gateway --replicas=3
|
||||
deployment.apps/example-gateway scaled
|
||||
```
|
||||
```shell-session
|
||||
$ kubectl get deployment --selector api-gateway.consul.hashicorp.com/name=example-gateway
|
||||
NAME READY UP-TO-DATE AVAILABLE
|
||||
example-gateway 3/3 3 3
|
||||
```
|
||||
|
||||
### Route
|
||||
|
||||
Routes are independent configuration objects that are associated with specific listeners.
|
||||
|
||||
Declare a route with either `kind: HTTPRoute` or `kind: TCPRoute` and configure the route parameters in the `spec` block.
|
||||
Refer to the Kubernetes Gateway API documentation for each object type for details:
|
||||
|
||||
- [HTTPRoute](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute)
|
||||
- [TCPRoute](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.TCPRoute)
|
||||
|
||||
The following example creates a route named `example-route` associated with a listener defined in `example-gateway`.
|
||||
|
||||
<CodeBlockConfig filename="routes.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: example-route
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: example-gateway
|
||||
rules:
|
||||
- backendRefs:
|
||||
- kind: Service
|
||||
name: echo
|
||||
port: 8080
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
To create a route for a `backendRef` in a different namespace, you must also
|
||||
create a [ReferencePolicy](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.ReferencePolicy).
|
||||
|
||||
The following example creates a route named `example-route` in namespace `gateway-namespace`. This route has a `backendRef` in namespace `service-namespace`. Traffic is allowed because the `ReferencePolicy`, named `reference-policy` in namespace `service-namespace`, allows traffic from `HTTPRoutes` in `gateway-namespace` to `Services` in `service-namespace`.
|
||||
|
||||
<CodeBlockConfig filename="route_with_referencepolicy.yaml">
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: example-route
|
||||
namespace: gateway-namespace
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: example-gateway
|
||||
rules:
|
||||
- backendRefs:
|
||||
- kind: Service
|
||||
name: echo
|
||||
namespace: service-namespace
|
||||
port: 8080
|
||||
---
|
||||
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: ReferencePolicy
|
||||
metadata:
|
||||
name: reference-policy
|
||||
namespace: service-namespace
|
||||
spec:
|
||||
from:
|
||||
- group: gateway.networking.k8s.io
|
||||
kind: HTTPRoute
|
||||
namespace: gateway-namespace
|
||||
to:
|
||||
- group: ""
|
||||
kind: Service
|
||||
name: echo
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
### MeshService
|
||||
|
||||
The `MeshService` configuration holds a reference to an externally-managed Consul service mesh service and can be used as a `backendRef` for a [`Route`](#route).
|
||||
|
||||
| Parameter | Description | Type | Default |
|
||||
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------- |
|
||||
| `name` | Specifies the service name for a Consul service. It is assumed this service will exist in either the `consulDestinationNamespace` or mirrored Consul namespace from where this custom resource is defined, depending on the Helm configuration.
|
||||
|
||||
Refer to the [Consul API Gateway repository](https://github.com/hashicorp/consul-api-gateway/blob/main/config/crd/bases/api-gateway.consul.hashicorp.com_meshservices.yaml) for the complete specification.
|
||||
|
||||
<!--
|
||||
****** KEEP ALL PAGE CONTENT ABOVE THIS LINE *******
|
||||
Only Reference style links should be added below this comment
|
||||
--->
|
||||
[tech-specs]: /docs/api-gateway/tech-specs
|
||||
[rel-notes]: /docs/release-notes
|
||||
|
|
|
@ -18,7 +18,7 @@ Consul API Gateway solves the following primary use cases:
|
|||
- **Controlling access at the point of entry**: Consul API Gateway allows users to set the protocols of external connection requests and provide clients with TLS certificates from trusted providers (e.g., Verisign, Let’s Encrypt).
|
||||
- **Simplifying traffic management**: The Consul API Gateway can load balance requests across services and route traffic to the appropriate service by matching one or more criteria, such as hostname, path, header presence or value, and HTTP Method type (e.g., GET, POST, PATCH).
|
||||
|
||||
## Implementation
|
||||
## How Does Consul API Gateway Work?
|
||||
|
||||
Consul API Gateway can be deployed on Kubernetes-based runtime environments and requires that Consul service mesh be deployed on the Kubernetes cluster.
|
||||
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway Technical Specifications
|
||||
description: >-
|
||||
This topic describes technical specifications for Consul API Gateway.
|
||||
---
|
||||
|
||||
# Technical Specifications
|
||||
|
||||
This topic describes the technical specifications associated with using Consul API Gateway.
|
||||
|
||||
## Requirements
|
||||
|
||||
Verify that your environment meets the following requirements prior to using Consul API Gateway.
|
||||
|
||||
### Datacenter Requirements
|
||||
|
||||
Your datacenter must meet the following requirements prior to configuring the Consul API Gateway:
|
||||
|
||||
- Kubernetes 1.21+
|
||||
- Kubernetes 1.24 is not supported at this time.
|
||||
- `kubectl` 1.21+
|
||||
- Consul 1.11.2+
|
||||
- HashiCorp Consul Helm chart 0.45.0+
|
||||
- Consul Service Mesh must be deployed on the Kubernetes cluster that API Gateway is deployed on.
|
||||
- Envoy: Envoy proxy support is determined by the Consul version deployed. Refer to [Envoy Integration](/docs/connect/proxies/envoy) for details.
|
||||
|
||||
### TCP Port Requirements
|
||||
|
||||
The following table describes the TCP port requirements for each component of the API Gateway.
|
||||
|
||||
| Port | Description | Component |
|
||||
| ---- | ----------- | --------- |
|
||||
| 9090 | Secret discovery service (SDS) | Gateway controller pod <br/> Gateway instance pod |
|
||||
| 20000 | Kubernetes readiness probe | Gateway instance pod |
|
||||
| Configurable | Port for scraping Prometheus metrics. Disabled by default. | Gateway controller pod |
|
||||
|
||||
## Consul Server Deployments
|
||||
|
||||
- Consul Editions supported: OSS and Enterprise
|
||||
- Supported Consul Server deployment types:
|
||||
- Self-Managed
|
||||
- HCP Consul
|
||||
|
||||
## Deployment Environments
|
||||
|
||||
Consul API Gateway can be deployed in the following Kubernetes-based environments:
|
||||
|
||||
- Generic Kubernetes
|
||||
- AWS Elastic Kubernetes Service (EKS)
|
||||
- Google Kubernetes Engine (GKE)
|
||||
- Azure Kubernetes Service (AKS)
|
||||
|
||||
## Kubernetes Gateway API Specification - Supported Versions
|
||||
|
||||
See the Release Notes for the version of Consul API Gateway being used.
|
||||
|
||||
## Resource Allocations
|
||||
|
||||
The following resources are allocated for each component of the API Gateway.
|
||||
|
||||
### Gateway Controller Pod
|
||||
|
||||
- **CPU**: None. Either the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
- **Memory**: None. Either the the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
|
||||
### Gateway Instance Pod
|
||||
|
||||
- **CPU**: None. Either the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
||||
- **Memory**: None. Either the namespace or cluster default is allocated, depending on the Kubernetes cluster configuration.
|
|
@ -0,0 +1,131 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Consul API Gateway Basic Usage
|
||||
description: >-
|
||||
Consul API Gateway Basic Usage
|
||||
---
|
||||
|
||||
|
||||
# Basic Usage
|
||||
|
||||
1. Verify that the [requirements](/docs/api-gateway/consul-api-gateway-install#requirments) have been met.
|
||||
1. Verify that the Consul API Gateway CRDs and controller have been installed and applied (see [Installation](/docs/api-gateway/consul-api-gateway-install)).
|
||||
1. Configure the artifacts described below in [Configuration](/docs/api-gateway/configuration).
|
||||
|
||||
<CodeBlockConfig hideClipboard filename="values.yaml">
|
||||
|
||||
```yaml
|
||||
apiGateway:
|
||||
managedGatewayClass:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
</CodeBlockConfig>
|
||||
|
||||
1. Issue the `kubectl apply` command to implement the configurations, e.g.:
|
||||
|
||||
```shell-session
|
||||
$ kubectl apply -f gateway.yaml routes.yaml
|
||||
```
|
||||
|
||||
<!--- Commented out per https://github.com/hashicorp/consul/pull/11951/files#r791204596
|
||||
|
||||
### Using the Consul API Gateway Binary
|
||||
|
||||
You can download the Consul API Gateway binary and use it to manually start the control plane server.
|
||||
|
||||
1. Download the binary from the [Consul API Gateway repository](https://github.com/hashicorp/consul-api-gateway).
|
||||
1. Navigate to the `consul-api-gateway-main` directory and build the binary:
|
||||
|
||||
```shell-session
|
||||
$ go build
|
||||
```
|
||||
|
||||
1. (Optional) Copy the binary to the execution path, e.g.:
|
||||
|
||||
```shell-session
|
||||
$ cp consul-api-gateway /usr/bin
|
||||
```
|
||||
|
||||
1. Use the `server` command to interact with the Consul API Gateway binary:
|
||||
|
||||
```shell-session
|
||||
$ ./consul-api-gateway server <options>
|
||||
```
|
||||
|
||||
The following options are supported:
|
||||
|
||||
| Option | Description | Required | Default |
|
||||
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------- |
|
||||
| `-ca-file` | String value that specifies the path to the CA for the Consul server. | Required | none |
|
||||
| `-ca-secret` | String value that specifies the CA secret for the Consul server. | Required | none |
|
||||
| `-ca-secret-namespace` | String value that specifies the CA secret namespace for the Consul server. | Required | none |
|
||||
| `-k8-context` | String value that specifies the Kubernetes context to use when starting the Consul server. | Optional | current context |
|
||||
| `-k8-namespace` | String value that specifies the Kubernetes namespace to use when starting the Consul server. | Optional | `default` |
|
||||
| `-log-json` | Boolean value that enables or disables JSON format for the log output. | Required | `false` |
|
||||
| `-log-level` | String value that specifies the logging level. The following values are supported: <br/>- `trace` (highest level of detail) <br/>- `debug` <br/>- `info` <br/>- `warn` <br/>- `error` | Optional | `info` |
|
||||
| `-metrics-port` | Integer value that specifies the port number for collecting metrics. | Optional | none |
|
||||
| `-pprof` | Integer value that specifies the Go pprof port number for collecting metrics. | Optional | none |
|
||||
| `-sds-server-host` | String value that specifies the host server for the secret discovery service (SDS). | Optional | `consul-api-gateway-controller.default.`<br/>`svc.cluster.`<br/>`local` |
|
||||
| `-sds-server-host` | Integer value that specifies the port number for the secret discovery service (SDS). | Optional | `9090` |
|
||||
|
||||
You can also issue the `version` command to print the Consul API Gateway version to the console:
|
||||
|
||||
```shell-session
|
||||
$ ./consul-api-gateway version
|
||||
consul-api-gateway 0.1.0
|
||||
```
|
||||
--->
|
||||
|
||||
## Common Error Messages
|
||||
|
||||
Some of the errors messages commonly encountered during installation and operations of Consul API Gateway are listed below, along with suggested methods for resolving them.
|
||||
|
||||
If the error message is not listed on this page, it may be listed on the main [Consul Common errors][consul-common-errors] page. If the error message is not listed on that page either, please consider following our general [Troubleshooting Guide][troubleshooting] or reach out to us in [Discuss](https://discuss.hashicorp.com/).
|
||||
|
||||
<!---
|
||||
***************************************************************************
|
||||
Use markdown's Reference-Style links when including hyperlinks. This makes it easier to read the content im markdown.
|
||||
|
||||
Each common error should have its own section on this page. Each section
|
||||
should start with a heading line that is a short description of the error or
|
||||
the text of the error.
|
||||
|
||||
Two examples:
|
||||
### Failed opening file during installation
|
||||
### Message: "Can't connect to repository" when running Helm chart
|
||||
|
||||
******** Template for new Error Messages ********
|
||||
Copy and paste the following 13 lines when adding a new error message to this page.
|
||||
|
||||
### Title for this error
|
||||
|
||||
```
|
||||
Replace with text of example error message
|
||||
```
|
||||
**Conditions:**
|
||||
REPLACE THIS with description of when and why the error is typically seen
|
||||
|
||||
**Impact:**
|
||||
REPLACE THIS with description of most likely impact of the event that caused this error to occur
|
||||
|
||||
**Recommended Action:**
|
||||
REPLACE THIS with the actions the user should take to try to correct the situation
|
||||
|
||||
***************************************************************************
|
||||
--->
|
||||
|
||||
### Helm installation failed: "no matches for kind"
|
||||
|
||||
```
|
||||
Error: INSTALLATION FAILED: unable to build kubernetes objects from release manifest: [unable to recognize "": no matches for kind "GatewayClass" in version "gateway.networking.k8s.io/v1alpha2", unable to recognize "": no matches for kind "GatewayClassConfig" in version "api-gateway.consul.hashicorp.com/v1alpha1"]
|
||||
```
|
||||
**Conditions:**
|
||||
When this error occurs during the process of installing Consul API Gateway, it is usually caused by not having the required CRD files installed in Kubernetes prior to installing Consul API Gateway.
|
||||
|
||||
**Impact:**
|
||||
The installation process will typically fail after this error message is generated
|
||||
|
||||
**Recommended Action:**
|
||||
Install the required CRDs by using the command in Step 1 of the [Consul API Gateway installation instructions](/docs/api-gateway/consul-api-gateway-install) and then retry installing Consul API Gateway.
|
||||
|
|
@ -385,17 +385,43 @@
|
|||
"title": "Installation",
|
||||
"path": "api-gateway/consul-api-gateway-install"
|
||||
},
|
||||
{
|
||||
"title": "Technical Specifications",
|
||||
"path": "api-gateway/tech-specs"
|
||||
},
|
||||
{
|
||||
"title": "Common Errors",
|
||||
"path": "api-gateway/common-errors"
|
||||
},
|
||||
{
|
||||
"title": "Upgrades",
|
||||
"path": "api-gateway/upgrade-specific-versions"
|
||||
"path": "api-gateway/upgrades"
|
||||
},
|
||||
{
|
||||
"title": "Usage",
|
||||
"routes": [
|
||||
{
|
||||
"title": "Basic Usage",
|
||||
"path": "api-gateway/usage/basic-usage"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Configuration",
|
||||
"routes": [
|
||||
{
|
||||
"title": "Overview",
|
||||
"path": "api-gateway/configuration"
|
||||
},
|
||||
{
|
||||
"title": "Gateway",
|
||||
"path": "api-gateway/configuration/gateway"
|
||||
},
|
||||
{
|
||||
"title": "Gateway Class",
|
||||
"path": "api-gateway/configuration/gatewayclass"
|
||||
},
|
||||
{
|
||||
"title": "Gateway Class",
|
||||
"path": "api-gateway/configuration/gatewayclassconfig"
|
||||
},
|
||||
{
|
||||
"title": "Gateway Class",
|
||||
"path": "api-gateway/configuration/routes"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue