fixes for unsupported partitions field in CRD metadata block (#16604)

* fixes for unsupported partitions field in CRD metadata block

* Apply suggestions from code review

Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com>

---------

Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com>
This commit is contained in:
trujillo-adam 2023-03-10 11:33:42 -08:00 committed by GitHub
parent e298f506a5
commit 51902695de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 11 deletions

View File

@ -88,6 +88,9 @@ spec:
</Tab>
<Tab heading="Consul Enterprise">
For Kubernetes environments, the configuration entry is always created in the same partition as the Kubernetes cluster.
<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
```hcl
@ -117,7 +120,6 @@ kind: IngressGateway
metadata:
name: <name for the gateway>
namespace: <namespace containing the gateway>
partition: <partition containing the gateway namespace>
spec:
listeners:

View File

@ -82,7 +82,6 @@ The following outline shows how to format the service splitter configuration ent
- [`metadata`](#metadata): map | no default
- [`name`](#name): string | no default
- [`namespace`](#namespace): string | no default | <EnterpriseAlert inline />
- [`partition`](#partition): string | no default | <EnterpriseAlert inline />
- [`spec`](#spec): map | no default
- [`protocol`](#protocol): string | default: `tcp`
- [`balanceInboundConnections`](#balanceinboundconnections): string | no default
@ -239,7 +238,6 @@ kind: ServiceDefaults
metadata:
name: <name of the service you are configuring>
namespace: <Consul Enterprise namespace>
partition: <Consul Enterprise admin partition>
spec:
protocol: tcp
balanceInboundConnnections: exact_balance
@ -802,13 +800,6 @@ Specifies the Consul namespace that the configuration entry applies to. Refer to
- Default: `default`
- Data type: string
### `metadata.partition` <Enterprise/>
Specifies the name of the name of the Consul admin partition that the configuration entry applies to. Refer to [Consul Enterprise](/consul/docs/k8s/crds#consul-enterprise) for information about how Consul Enterprise on Kubernetes. Consul OSS distributions ignore the `metadata.partition` configuration.
- Default: `default`
- Data type: string
### `spec`
Map that contains the details about the `ServiceDefaults` configuration entry. The `apiVersion`, `kind`, and `metadata` fields are siblings of the `spec` field. All other configurations are children.

View File

@ -15,7 +15,7 @@ You must tell Consul about the services deployed to your network if you want the
You can define multiple services individually using `service` blocks or group multiple services into the same `services` configuration block. Refer to [Define multiple services in a single file](#define-multiple-services-in-a-single-file) for additional information.
If Consul service mesh is enabled in your network, you can use the `service-defaults` configuration entry to specify default global values for services. The configuraiton entry lets you define common service parameter, such as upstreams, namespaces, and partitions. Refer to [Define service defaults](#define-service-defaults) for additional information.
If Consul service mesh is enabled in your network, you can use the [service defaults configuration entry](/consul/docs/connect/config-entries/service-defaults) to specify default global values for services. The configuration entry lets you define common service parameter, such as upstreams, namespaces, and partitions. Refer to [Define service defaults](#define-service-defaults) for additional information.
## Requirements
@ -145,6 +145,9 @@ If Consul service mesh is enabled in your network, you can define default values
Create a file for the configuration entry and specify the required fields. If you are authoring `service-defaults` in HCL or JSON, the `Kind` and `Name` fields are required. On Kubernetes, the `apiVersion`, `kind`, and `metadata.name` fields are required. Refer to [Service Defaults Reference](/consul/docs/connect/config-entries/service-defaults) for details about the configuration options.
If you use Consul Enterprise, you can also specify the `Namespace` and `Partition` fields to apply the configuration to services in a specific namespace or partition. For Kubernetes environments, the configuration entry is always created in the same partition as the Kubernetes cluster.
### Consul OSS example
The following example instructs services named `counting` to send up to `512` concurrent requests to a mesh gateway:
<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
@ -222,6 +225,87 @@ spec:
```
</CodeTabs>
### Consul Enterprise example
The following example instructs services named `counting` in the `prod` namespace to send up to `512` concurrent requests to a mesh gateway:
<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
```hcl
Kind = "service-defaults"
Name = "counting"
Namespace = "prod"
UpstreamConfig = {
Defaults = {
MeshGateway = {
Mode = "local"
}
Limits = {
MaxConnections = 512
MaxPendingRequests = 512
MaxConcurrentRequests = 512
}
}
Overrides = [
{
Name = "dashboard"
MeshGateway = {
Mode = "remote"
}
}
]
}
```
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceDefaults
metadata:
name: counting
namespace: prod
spec:
upstreamConfig:
defaults:
meshGateway:
mode: local
limits:
maxConnections: 512
maxPendingRequests: 512
maxConcurrentRequests: 512
overrides:
- name: dashboard
meshGateway:
mode: remote
```
```json
{
"Kind": "service-defaults",
"Name": "counting",
"Namespace" : "prod",
"UpstreamConfig": {
"Defaults": {
"MeshGateway": {
"Mode": "local"
},
"Limits": {
"MaxConnections": 512,
"MaxPendingRequests": 512,
"MaxConcurrentRequests": 512
}
},
"Overrides": [
{
"Name": "dashboard",
"MeshGateway": {
"Mode": "remote"
}
}
]
}
}
```
</CodeTabs>
### Apply service defaults
You can apply your `service-defaults` configuration entry using the [`consul config` command](/consul/commands/config) or by calling the [`/config` API endpoint](/consul/api-docs/config). In Kubernetes environments, apply the `service-defaults` custom resource definitions (CRD) to implement and manage Consul configuration entries.