Rename partition-exports to exported-services

Using a name less tied to partitions gives us more flexibility to use
this config entry in OSS for exports between datacenters/meshes.
This commit is contained in:
freddygv 2021-12-02 23:50:38 -07:00
parent ff1e71efec
commit ed6076db26
17 changed files with 97 additions and 97 deletions

View File

@ -16,10 +16,10 @@ type Config struct {
type ExportFetcher interface { type ExportFetcher interface {
// ExportsForPartition returns the config entry defining exports for a partition // ExportsForPartition returns the config entry defining exports for a partition
ExportsForPartition(partition string) PartitionExports ExportsForPartition(partition string) ExportedServices
} }
type PartitionExports struct { type ExportedServices struct {
Data map[string]map[string][]string Data map[string]map[string][]string
} }

View File

@ -1980,6 +1980,6 @@ func filterACL(r *ACLResolver, token string, subj interface{}) error {
type partitionInfoNoop struct{} type partitionInfoNoop struct{}
func (p *partitionInfoNoop) ExportsForPartition(partition string) acl.PartitionExports { func (p *partitionInfoNoop) ExportsForPartition(partition string) acl.ExportedServices {
return acl.PartitionExports{} return acl.ExportedServices{}
} }

View File

@ -597,7 +597,7 @@ func gateWriteToSecondary(targetDC, localDC, primaryDC, kind string) error {
// Partition exports are gated from interactions from secondary DCs // Partition exports are gated from interactions from secondary DCs
// because non-default partitions cannot be created in secondaries // because non-default partitions cannot be created in secondaries
// and services cannot be exported to another datacenter. // and services cannot be exported to another datacenter.
if kind != structs.PartitionExports { if kind != structs.ExportedServices {
return nil return nil
} }
if localDC == "" { if localDC == "" {
@ -611,10 +611,10 @@ func gateWriteToSecondary(targetDC, localDC, primaryDC, kind string) error {
switch { switch {
case targetDC == "" && localDC != primaryDC: case targetDC == "" && localDC != primaryDC:
return fmt.Errorf("partition-exports writes in secondary datacenters must target the primary datacenter explicitly.") return fmt.Errorf("exported-services writes in secondary datacenters must target the primary datacenter explicitly.")
case targetDC != "" && targetDC != primaryDC: case targetDC != "" && targetDC != primaryDC:
return fmt.Errorf("partition-exports writes must not target secondary datacenters.") return fmt.Errorf("exported-services writes must not target secondary datacenters.")
} }
return nil return nil

View File

@ -2093,7 +2093,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "", targetDC: "",
localDC: "dc1", localDC: "dc1",
primaryDC: "", primaryDC: "",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
}, },
{ {
@ -2102,7 +2102,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "", targetDC: "",
localDC: "dc1", localDC: "dc1",
primaryDC: "dc1", primaryDC: "dc1",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
}, },
{ {
@ -2111,7 +2111,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "dc1", targetDC: "dc1",
localDC: "dc1", localDC: "dc1",
primaryDC: "dc1", primaryDC: "dc1",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
}, },
{ {
@ -2120,7 +2120,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "dc2", targetDC: "dc2",
localDC: "dc1", localDC: "dc1",
primaryDC: "", primaryDC: "",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
wantErr: "writes must not target secondary datacenters", wantErr: "writes must not target secondary datacenters",
}, },
@ -2130,7 +2130,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "dc2", targetDC: "dc2",
localDC: "dc1", localDC: "dc1",
primaryDC: "dc1", primaryDC: "dc1",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
wantErr: "writes must not target secondary datacenters", wantErr: "writes must not target secondary datacenters",
}, },
@ -2140,7 +2140,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "dc2", targetDC: "dc2",
localDC: "dc2", localDC: "dc2",
primaryDC: "dc1", primaryDC: "dc1",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
wantErr: "writes must not target secondary datacenters", wantErr: "writes must not target secondary datacenters",
}, },
@ -2150,7 +2150,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
targetDC: "", targetDC: "",
localDC: "dc2", localDC: "dc2",
primaryDC: "dc1", primaryDC: "dc1",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
wantErr: "must target the primary datacenter explicitly", wantErr: "must target the primary datacenter explicitly",
}, },
@ -2158,7 +2158,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
name: "empty local DC", name: "empty local DC",
args: args{ args: args{
localDC: "", localDC: "",
kind: structs.PartitionExports, kind: structs.ExportedServices,
}, },
wantErr: "unknown local datacenter", wantErr: "unknown local datacenter",
}, },
@ -2179,7 +2179,7 @@ func Test_gateWriteToSecondary_AllowedKinds(t *testing.T) {
} }
for _, kind := range structs.AllConfigEntryKinds { for _, kind := range structs.AllConfigEntryKinds {
if kind == structs.PartitionExports { if kind == structs.ExportedServices {
continue continue
} }

View File

@ -93,7 +93,7 @@ func (s *Server) reconcileLocalConfig(ctx context.Context, configs []structs.Con
for i, entry := range configs { for i, entry := range configs {
// Partition exports only apply to the primary datacenter. // Partition exports only apply to the primary datacenter.
if entry.GetKind() == structs.PartitionExports { if entry.GetKind() == structs.ExportedServices {
continue continue
} }
req := structs.ConfigEntryRequest{ req := structs.ConfigEntryRequest{

View File

@ -395,7 +395,7 @@ func validateProposedConfigEntryInGraph(
} }
case structs.ServiceIntentions: case structs.ServiceIntentions:
case structs.MeshConfig: case structs.MeshConfig:
case structs.PartitionExports: case structs.ExportedServices:
default: default:
return fmt.Errorf("unhandled kind %q during validation of %q", kindName.Kind, kindName.Name) return fmt.Errorf("unhandled kind %q during validation of %q", kindName.Kind, kindName.Name)
} }

View File

@ -178,12 +178,12 @@ func TestUsageReporter_emitNodeUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"}, {Name: "kind", Value: "terminating-gateway"},
}, },
}, },
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=partition-exports": { "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
Name: "consul.usage.test.consul.state.config_entries", Name: "consul.usage.test.consul.state.config_entries",
Value: 0, Value: 0,
Labels: []metrics.Label{ Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"}, {Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "partition-exports"}, {Name: "kind", Value: "exported-services"},
}, },
}, },
}, },
@ -363,12 +363,12 @@ func TestUsageReporter_emitNodeUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"}, {Name: "kind", Value: "terminating-gateway"},
}, },
}, },
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=partition-exports": { "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
Name: "consul.usage.test.consul.state.config_entries", Name: "consul.usage.test.consul.state.config_entries",
Value: 0, Value: 0,
Labels: []metrics.Label{ Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"}, {Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "partition-exports"}, {Name: "kind", Value: "exported-services"},
}, },
}, },
}, },
@ -576,12 +576,12 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"}, {Name: "kind", Value: "terminating-gateway"},
}, },
}, },
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=partition-exports": { "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
Name: "consul.usage.test.consul.state.config_entries", Name: "consul.usage.test.consul.state.config_entries",
Value: 0, Value: 0,
Labels: []metrics.Label{ Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"}, {Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "partition-exports"}, {Name: "kind", Value: "exported-services"},
}, },
}, },
}, },
@ -803,12 +803,12 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"}, {Name: "kind", Value: "terminating-gateway"},
}, },
}, },
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=partition-exports": { "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
Name: "consul.usage.test.consul.state.config_entries", Name: "consul.usage.test.consul.state.config_entries",
Value: 0, Value: 0,
Labels: []metrics.Label{ Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"}, {Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "partition-exports"}, {Name: "kind", Value: "exported-services"},
}, },
}, },
}, },
@ -1007,12 +1007,12 @@ func TestUsageReporter_emitKVUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"}, {Name: "kind", Value: "terminating-gateway"},
}, },
}, },
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=partition-exports": { "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
Name: "consul.usage.test.consul.state.config_entries", Name: "consul.usage.test.consul.state.config_entries",
Value: 0, Value: 0,
Labels: []metrics.Label{ Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"}, {Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "partition-exports"}, {Name: "kind", Value: "exported-services"},
}, },
}, },
}, },
@ -1201,12 +1201,12 @@ func TestUsageReporter_emitKVUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"}, {Name: "kind", Value: "terminating-gateway"},
}, },
}, },
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=partition-exports": { "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
Name: "consul.usage.test.consul.state.config_entries", Name: "consul.usage.test.consul.state.config_entries",
Value: 0, Value: 0,
Labels: []metrics.Label{ Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"}, {Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "partition-exports"}, {Name: "kind", Value: "exported-services"},
}, },
}, },
}, },

View File

@ -27,7 +27,7 @@ const (
TerminatingGateway string = "terminating-gateway" TerminatingGateway string = "terminating-gateway"
ServiceIntentions string = "service-intentions" ServiceIntentions string = "service-intentions"
MeshConfig string = "mesh" MeshConfig string = "mesh"
PartitionExports string = "partition-exports" ExportedServices string = "exported-services"
ProxyConfigGlobal string = "global" ProxyConfigGlobal string = "global"
MeshConfigMesh string = "mesh" MeshConfigMesh string = "mesh"
@ -45,7 +45,7 @@ var AllConfigEntryKinds = []string{
TerminatingGateway, TerminatingGateway,
ServiceIntentions, ServiceIntentions,
MeshConfig, MeshConfig,
PartitionExports, ExportedServices,
} }
// ConfigEntry is the interface for centralized configuration stored in Raft. // ConfigEntry is the interface for centralized configuration stored in Raft.
@ -533,8 +533,8 @@ func MakeConfigEntry(kind, name string) (ConfigEntry, error) {
return &ServiceIntentionsConfigEntry{Name: name}, nil return &ServiceIntentionsConfigEntry{Name: name}, nil
case MeshConfig: case MeshConfig:
return &MeshConfigEntry{}, nil return &MeshConfigEntry{}, nil
case PartitionExports: case ExportedServices:
return &PartitionExportsConfigEntry{Name: name}, nil return &ExportedServicesConfigEntry{Name: name}, nil
default: default:
return nil, fmt.Errorf("invalid config entry kind: %s", kind) return nil, fmt.Errorf("invalid config entry kind: %s", kind)
} }

View File

@ -7,9 +7,9 @@ import (
"github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/acl"
) )
// PartitionExportsConfigEntry is the top-level struct for exporting a service to be exposed // ExportedServicesConfigEntry is the top-level struct for exporting a service to be exposed
// across other admin partitions. // across other admin partitions.
type PartitionExportsConfigEntry struct { type ExportedServicesConfigEntry struct {
Name string Name string
// Services is a list of services to be exported and the list of partitions // Services is a list of services to be exported and the list of partitions
@ -40,7 +40,7 @@ type ServiceConsumer struct {
Partition string Partition string
} }
func (e *PartitionExportsConfigEntry) ToMap() map[string]map[string][]string { func (e *ExportedServicesConfigEntry) ToMap() map[string]map[string][]string {
resp := make(map[string]map[string][]string) resp := make(map[string]map[string][]string)
for _, svc := range e.Services { for _, svc := range e.Services {
if _, ok := resp[svc.Namespace]; !ok { if _, ok := resp[svc.Namespace]; !ok {
@ -57,7 +57,7 @@ func (e *PartitionExportsConfigEntry) ToMap() map[string]map[string][]string {
return resp return resp
} }
func (e *PartitionExportsConfigEntry) Clone() *PartitionExportsConfigEntry { func (e *ExportedServicesConfigEntry) Clone() *ExportedServicesConfigEntry {
e2 := *e e2 := *e
e2.Services = make([]ExportedService, len(e.Services)) e2.Services = make([]ExportedService, len(e.Services))
for _, svc := range e.Services { for _, svc := range e.Services {
@ -72,11 +72,11 @@ func (e *PartitionExportsConfigEntry) Clone() *PartitionExportsConfigEntry {
return &e2 return &e2
} }
func (e *PartitionExportsConfigEntry) GetKind() string { func (e *ExportedServicesConfigEntry) GetKind() string {
return PartitionExports return ExportedServices
} }
func (e *PartitionExportsConfigEntry) GetName() string { func (e *ExportedServicesConfigEntry) GetName() string {
if e == nil { if e == nil {
return "" return ""
} }
@ -84,14 +84,14 @@ func (e *PartitionExportsConfigEntry) GetName() string {
return e.Name return e.Name
} }
func (e *PartitionExportsConfigEntry) GetMeta() map[string]string { func (e *ExportedServicesConfigEntry) GetMeta() map[string]string {
if e == nil { if e == nil {
return nil return nil
} }
return e.Meta return e.Meta
} }
func (e *PartitionExportsConfigEntry) Normalize() error { func (e *ExportedServicesConfigEntry) Normalize() error {
if e == nil { if e == nil {
return fmt.Errorf("config entry is nil") return fmt.Errorf("config entry is nil")
} }
@ -105,12 +105,12 @@ func (e *PartitionExportsConfigEntry) Normalize() error {
return nil return nil
} }
func (e *PartitionExportsConfigEntry) Validate() error { func (e *ExportedServicesConfigEntry) Validate() error {
if e.Name == "" { if e.Name == "" {
return fmt.Errorf("Name is required") return fmt.Errorf("Name is required")
} }
if e.Name == WildcardSpecifier { if e.Name == WildcardSpecifier {
return fmt.Errorf("partition-exports Name must be the name of a partition, and not a wildcard") return fmt.Errorf("exported-services Name must be the name of a partition, and not a wildcard")
} }
if err := requireEnterprise(e.GetKind()); err != nil { if err := requireEnterprise(e.GetKind()); err != nil {
@ -136,19 +136,19 @@ func (e *PartitionExportsConfigEntry) Validate() error {
return nil return nil
} }
func (e *PartitionExportsConfigEntry) CanRead(authz acl.Authorizer) bool { func (e *ExportedServicesConfigEntry) CanRead(authz acl.Authorizer) bool {
var authzContext acl.AuthorizerContext var authzContext acl.AuthorizerContext
e.FillAuthzContext(&authzContext) e.FillAuthzContext(&authzContext)
return authz.MeshRead(&authzContext) == acl.Allow return authz.MeshRead(&authzContext) == acl.Allow
} }
func (e *PartitionExportsConfigEntry) CanWrite(authz acl.Authorizer) bool { func (e *ExportedServicesConfigEntry) CanWrite(authz acl.Authorizer) bool {
var authzContext acl.AuthorizerContext var authzContext acl.AuthorizerContext
e.FillAuthzContext(&authzContext) e.FillAuthzContext(&authzContext)
return authz.MeshWrite(&authzContext) == acl.Allow return authz.MeshWrite(&authzContext) == acl.Allow
} }
func (e *PartitionExportsConfigEntry) GetRaftIndex() *RaftIndex { func (e *ExportedServicesConfigEntry) GetRaftIndex() *RaftIndex {
if e == nil { if e == nil {
return &RaftIndex{} return &RaftIndex{}
} }
@ -156,7 +156,7 @@ func (e *PartitionExportsConfigEntry) GetRaftIndex() *RaftIndex {
return &e.RaftIndex return &e.RaftIndex
} }
func (e *PartitionExportsConfigEntry) GetEnterpriseMeta() *EnterpriseMeta { func (e *ExportedServicesConfigEntry) GetEnterpriseMeta() *EnterpriseMeta {
if e == nil { if e == nil {
return nil return nil
} }
@ -168,13 +168,13 @@ func (e *PartitionExportsConfigEntry) GetEnterpriseMeta() *EnterpriseMeta {
// correct type. // correct type.
// This method is implemented on the structs type (as apposed to the api type) // This method is implemented on the structs type (as apposed to the api type)
// because that is what the API currently uses to return a response. // because that is what the API currently uses to return a response.
func (e *PartitionExportsConfigEntry) MarshalJSON() ([]byte, error) { func (e *ExportedServicesConfigEntry) MarshalJSON() ([]byte, error) {
type Alias PartitionExportsConfigEntry type Alias ExportedServicesConfigEntry
source := &struct { source := &struct {
Kind string Kind string
*Alias *Alias
}{ }{
Kind: PartitionExports, Kind: ExportedServices,
Alias: (*Alias)(e), Alias: (*Alias)(e),
} }
return json.Marshal(source) return json.Marshal(source)

View File

@ -1665,9 +1665,9 @@ func TestDecodeConfigEntry(t *testing.T) {
}, },
}, },
{ {
name: "partition-exports", name: "exported-services",
snake: ` snake: `
kind = "partition-exports" kind = "exported-services"
name = "foo" name = "foo"
meta { meta {
"foo" = "bar" "foo" = "bar"
@ -1698,7 +1698,7 @@ func TestDecodeConfigEntry(t *testing.T) {
] ]
`, `,
camel: ` camel: `
Kind = "partition-exports" Kind = "exported-services"
Name = "foo" Name = "foo"
Meta { Meta {
"foo" = "bar" "foo" = "bar"
@ -1728,7 +1728,7 @@ func TestDecodeConfigEntry(t *testing.T) {
} }
] ]
`, `,
expect: &PartitionExportsConfigEntry{ expect: &ExportedServicesConfigEntry{
Name: "foo", Name: "foo",
Meta: map[string]string{ Meta: map[string]string{
"foo": "bar", "foo": "bar",

View File

@ -22,7 +22,7 @@ const (
TerminatingGateway string = "terminating-gateway" TerminatingGateway string = "terminating-gateway"
ServiceIntentions string = "service-intentions" ServiceIntentions string = "service-intentions"
MeshConfig string = "mesh" MeshConfig string = "mesh"
PartitionExports string = "partition-exports" ExportedServices string = "exported-services"
ProxyConfigGlobal string = "global" ProxyConfigGlobal string = "global"
MeshConfigMesh string = "mesh" MeshConfigMesh string = "mesh"
@ -277,8 +277,8 @@ func makeConfigEntry(kind, name string) (ConfigEntry, error) {
return &ServiceIntentionsConfigEntry{Kind: kind, Name: name}, nil return &ServiceIntentionsConfigEntry{Kind: kind, Name: name}, nil
case MeshConfig: case MeshConfig:
return &MeshConfigEntry{}, nil return &MeshConfigEntry{}, nil
case PartitionExports: case ExportedServices:
return &PartitionExportsConfigEntry{Name: name}, nil return &ExportedServicesConfigEntry{Name: name}, nil
default: default:
return nil, fmt.Errorf("invalid config entry kind: %s", kind) return nil, fmt.Errorf("invalid config entry kind: %s", kind)
} }

View File

@ -2,14 +2,14 @@ package api
import "encoding/json" import "encoding/json"
// PartitionExportsConfigEntry manages the exported services for a single admin partition. // ExportedServicesConfigEntry manages the exported services for a single admin partition.
// Admin Partitions are a Consul Enterprise feature. // Admin Partitions are a Consul Enterprise feature.
type PartitionExportsConfigEntry struct { type ExportedServicesConfigEntry struct {
// Name is the name of the partition the PartitionExportsConfigEntry applies to. // Name is the name of the partition the ExportedServicesConfigEntry applies to.
// Partitioning is a Consul Enterprise feature. // Partitioning is a Consul Enterprise feature.
Name string `json:",omitempty"` Name string `json:",omitempty"`
// Partition is the partition where the PartitionExportsConfigEntry is stored. // Partition is the partition where the ExportedServicesConfigEntry is stored.
// If the partition does not match the name, the name will overwrite the partition. // If the partition does not match the name, the name will overwrite the partition.
// Partitioning is a Consul Enterprise feature. // Partitioning is a Consul Enterprise feature.
Partition string `json:",omitempty"` Partition string `json:",omitempty"`
@ -49,23 +49,23 @@ type ServiceConsumer struct {
Partition string Partition string
} }
func (e *PartitionExportsConfigEntry) GetKind() string { return PartitionExports } func (e *ExportedServicesConfigEntry) GetKind() string { return ExportedServices }
func (e *PartitionExportsConfigEntry) GetName() string { return e.Name } func (e *ExportedServicesConfigEntry) GetName() string { return e.Name }
func (e *PartitionExportsConfigEntry) GetPartition() string { return e.Name } func (e *ExportedServicesConfigEntry) GetPartition() string { return e.Name }
func (e *PartitionExportsConfigEntry) GetNamespace() string { return IntentionDefaultNamespace } func (e *ExportedServicesConfigEntry) GetNamespace() string { return IntentionDefaultNamespace }
func (e *PartitionExportsConfigEntry) GetMeta() map[string]string { return e.Meta } func (e *ExportedServicesConfigEntry) GetMeta() map[string]string { return e.Meta }
func (e *PartitionExportsConfigEntry) GetCreateIndex() uint64 { return e.CreateIndex } func (e *ExportedServicesConfigEntry) GetCreateIndex() uint64 { return e.CreateIndex }
func (e *PartitionExportsConfigEntry) GetModifyIndex() uint64 { return e.ModifyIndex } func (e *ExportedServicesConfigEntry) GetModifyIndex() uint64 { return e.ModifyIndex }
// MarshalJSON adds the Kind field so that the JSON can be decoded back into the // MarshalJSON adds the Kind field so that the JSON can be decoded back into the
// correct type. // correct type.
func (e *PartitionExportsConfigEntry) MarshalJSON() ([]byte, error) { func (e *ExportedServicesConfigEntry) MarshalJSON() ([]byte, error) {
type Alias PartitionExportsConfigEntry type Alias ExportedServicesConfigEntry
source := &struct { source := &struct {
Kind string Kind string
*Alias *Alias
}{ }{
Kind: PartitionExports, Kind: ExportedServices,
Alias: (*Alias)(e), Alias: (*Alias)(e),
} }
return json.Marshal(source) return json.Marshal(source)

View File

@ -2722,9 +2722,9 @@ func TestParseConfigEntry(t *testing.T) {
}, },
}, },
{ {
name: "partition-exports", name: "exported-services",
snake: ` snake: `
kind = "partition-exports" kind = "exported-services"
name = "foo" name = "foo"
meta { meta {
"foo" = "bar" "foo" = "bar"
@ -2755,7 +2755,7 @@ func TestParseConfigEntry(t *testing.T) {
] ]
`, `,
camel: ` camel: `
Kind = "partition-exports" Kind = "exported-services"
Name = "foo" Name = "foo"
Meta { Meta {
"foo" = "bar" "foo" = "bar"
@ -2787,7 +2787,7 @@ func TestParseConfigEntry(t *testing.T) {
`, `,
snakeJSON: ` snakeJSON: `
{ {
"kind": "partition-exports", "kind": "exported-services",
"name": "foo", "name": "foo",
"meta": { "meta": {
"foo": "bar", "foo": "bar",
@ -2820,7 +2820,7 @@ func TestParseConfigEntry(t *testing.T) {
`, `,
camelJSON: ` camelJSON: `
{ {
"Kind": "partition-exports", "Kind": "exported-services",
"Name": "foo", "Name": "foo",
"Meta": { "Meta": {
"foo": "bar", "foo": "bar",
@ -2851,7 +2851,7 @@ func TestParseConfigEntry(t *testing.T) {
] ]
} }
`, `,
expect: &api.PartitionExportsConfigEntry{ expect: &api.ExportedServicesConfigEntry{
Name: "foo", Name: "foo",
Meta: map[string]string{ Meta: map[string]string{
"foo": "bar", "foo": "bar",

View File

@ -2,21 +2,21 @@
layout: docs layout: docs
page_title: 'Configuration Entry Kind: Partition Exports' page_title: 'Configuration Entry Kind: Partition Exports'
description: >- description: >-
The partition-exports configuration entry enables you to export services from a single file. The exported-services configuration entry enables you to export services from a single file.
Settings in this configuration entry can apply to services in any namespace of the specified partition. Write access to the mesh resource is required. Settings in this configuration entry can apply to services in any namespace of the specified partition. Write access to the mesh resource is required.
--- ---
# Partition Exports # Partition Exports
This topic describes the `partition-exports` configuration entry type. The `partition-exports` configuration entry enables Consul to export service instances to other admin partitions from a single file. This enables your services to be networked across admin partitions. See [Admin Partitions](/docs/enterprise/admin-partitions) for additional information. This topic describes the `exported-services` configuration entry type. The `exported-services` configuration entry enables Consul to export service instances to other admin partitions from a single file. This enables your services to be networked across admin partitions. See [Admin Partitions](/docs/enterprise/admin-partitions) for additional information.
-> **v1.11.0+:** This config entry is supported in Consul versions 1.11.0+. -> **v1.11.0+:** This config entry is supported in Consul versions 1.11.0+.
## Introduction ## Introduction
You can configure Consul to export services contained in an admin partition to one or more additional partitions by declaring the `partition-exports` configuration entry in the `kind` field. This enables you to route traffic between services in different clusters that share a single set of Consul servers. You can configure Consul to export services contained in an admin partition to one or more additional partitions by declaring the `exported-services` configuration entry in the `kind` field. This enables you to route traffic between services in different clusters that share a single set of Consul servers.
You can configure the settings defined in the `partition-exports` configuration entry to apply to all namespaces and federated datacenters. You can configure the settings defined in the `exported-services` configuration entry to apply to all namespaces and federated datacenters.
## Requirements ## Requirements
@ -27,20 +27,20 @@ You can configure the settings defined in the `partition-exports` configuration
## Usage ## Usage
1. Verify that your datacenter meets the conditions specified in the [Requirements](#requirements). 1. Verify that your datacenter meets the conditions specified in the [Requirements](#requirements).
1. Specify the `partition-exports` configuration in the agent configuration file (see [`config_entries`](/docs/agent/options#config_entries)) as described in [Configuration](#configuration). 1. Specify the `exported-services` configuration in the agent configuration file (see [`config_entries`](/docs/agent/options#config_entries)) as described in [Configuration](#configuration).
1. Apply the configuration using one of the following methods: 1. Apply the configuration using one of the following methods:
* Kubernetes CRD: Refer to the [Custom Resource Definitions](/docs/k8s/crds) documentation for details. * Kubernetes CRD: Refer to the [Custom Resource Definitions](/docs/k8s/crds) documentation for details.
* Issue the `consul config write` command: Refer to the [Consul Config Write](/commands/config/write) documentation for details. * Issue the `consul config write` command: Refer to the [Consul Config Write](/commands/config/write) documentation for details.
## Configuration ## Configuration
Configure the following parameters to define a `partition-exports` configuration entry: Configure the following parameters to define a `exported-services` configuration entry:
<CodeTabs heading="Partition exports configuration syntax" tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}> <CodeTabs heading="Partition exports configuration syntax" tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<CodeBlockConfig> <CodeBlockConfig>
```hcl ```hcl
Kind = "partition-exports" Kind = "exported-services"
Partition = "<partition containing services to export>" Partition = "<partition containing services to export>"
Services = [ Services = [
{ {
@ -59,7 +59,7 @@ Services = [
```yaml ```yaml
apiVersion: consul.hashicorp.com/v1alpha1 apiVersion: consul.hashicorp.com/v1alpha1
Kind: PartitionExports Kind: ExportedServices
Partition: <partition containing services to export> Partition: <partition containing services to export>
Services: Services:
- Consumers: - Consumers:
@ -71,7 +71,7 @@ Services:
<CodeBlockConfig> <CodeBlockConfig>
```json ```json
"Kind": "partition-exports", "Kind": "exported-services",
"Partition": "<partition containing services to export>", "Partition": "<partition containing services to export>",
"Services": [ "Services": [
{ {
@ -90,11 +90,11 @@ Services:
### Configuration Parameters ### Configuration Parameters
The following table describes the parameters associated with the `partition-exports` configuration entry. The following table describes the parameters associated with the `exported-services` configuration entry.
| Parameter | Description | Required | Default | | Parameter | Description | Required | Default |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `Kind` | String value that enables the configuration entry. The value should always be `partition-exports` (HCL and JSON) or `PartitionExports` (YAML) | Required | None | | `Kind` | String value that enables the configuration entry. The value should always be `exported-services` (HCL and JSON) or `ExportedServices` (YAML) | Required | None |
| `Partition` | String value that specifies the name of the partition that contains the services you want to export. | Required | None | | `Partition` | String value that specifies the name of the partition that contains the services you want to export. | Required | None |
| `Services` | List of objects that specify which services to export. See [`Services`](#services) for details. | Required | None| | `Services` | List of objects that specify which services to export. See [`Services`](#services) for details. | Required | None|
| `Meta` | Object that defines a map of the max 64 key/value pairs. | Optional | None | | `Meta` | Object that defines a map of the max 64 key/value pairs. | Optional | None |
@ -115,7 +115,7 @@ The following example configures the agent to export the `billing` service from
<CodeBlockConfig> <CodeBlockConfig>
```hcl ```hcl
Kind = "partition-exports" Kind = "exported-services"
Partition = "finance" Partition = "finance"
Services = [ Services = [
@ -147,7 +147,7 @@ Services = [
<CodeBlockConfig> <CodeBlockConfig>
```yaml ```yaml
Kind: partition-exports Kind: exported-services
Partition: finance Partition: finance
Services: Services:
- Consumers: - Consumers:
@ -165,7 +165,7 @@ Services:
<CodeBlockConfig> <CodeBlockConfig>
```json ```json
"Kind": "partition-exports", "Kind": "exported-services",
"Partition": "finance", "Partition": "finance",
"Services": [ "Services": [
{ {
@ -207,4 +207,4 @@ An ACL token with `service:write` permissions is required for the partition from
Exports are available to all services in the consumer partition. In the previous example, any service with `write` permissions for the `frontend` partition will be able to read exports. Exports are available to all services in the consumer partition. In the previous example, any service with `write` permissions for the `frontend` partition will be able to read exports.
See [Health HTTP Endpoint](/api-docs/health) for additional information. See [Health HTTP Endpoint](/api-docs/health) for additional information.

View File

@ -55,7 +55,7 @@ Values specified for [`proxy-defaults`](/docs/connect/config-entries/proxy-defau
### Cross-partition Networking ### Cross-partition Networking
You can configure services to be discoverable and accessible by downstream services in any partition within the datacenter. Specify the upstream services that you want to be available for discovery by configuring the `partition-exports` configuration entry in the partition where the services are registered. Refer to the [`partition-exports` documentation](/docs/connect/config-entries/partition-exports) for details. You can configure services to be discoverable and accessible by downstream services in any partition within the datacenter. Specify the upstream services that you want to be available for discovery by configuring the `exported-services` configuration entry in the partition where the services are registered. Refer to the [`exported-services` documentation](/docs/connect/config-entries/exported-services) for details.
Additionally, the `upstreams` configuration for proxies in the source partition must specify the name of the destination partition so that listeners can be created. Refer to the [Upstream Configuration Reference](/docs/connect/registration/service-registration#upstream-configuration-reference) for additional information. Additionally, the `upstreams` configuration for proxies in the source partition must specify the name of the destination partition so that listeners can be created. Refer to the [Upstream Configuration Reference](/docs/connect/registration/service-registration#upstream-configuration-reference) for additional information.

View File

@ -23,7 +23,7 @@ via Kubernetes Custom Resources. Configuration entries provide cluster-wide defa
You can specify the following values in the `kind` field. Click on a configuration entry to view its documentation: You can specify the following values in the `kind` field. Click on a configuration entry to view its documentation:
- [`Mesh`](/docs/connect/config-entries/mesh) (requires Consul 1.10.0+) - [`Mesh`](/docs/connect/config-entries/mesh) (requires Consul 1.10.0+)
- [`PartitionExports`](/docs/connect/config-entries/partition-exports) - [`ExportedServices`](/docs/connect/config-entries/exported-services)
- [`ProxyDefaults`](/docs/connect/config-entries/proxy-defaults) - [`ProxyDefaults`](/docs/connect/config-entries/proxy-defaults)
- [`ServiceDefaults`](/docs/connect/config-entries/service-defaults) - [`ServiceDefaults`](/docs/connect/config-entries/service-defaults)
- [`ServiceSplitter`](/docs/connect/config-entries/service-splitter) - [`ServiceSplitter`](/docs/connect/config-entries/service-splitter)

View File

@ -152,7 +152,7 @@
}, },
{ {
"title": "Partition Exports", "title": "Partition Exports",
"path": "connect/config-entries/partition-exports" "path": "connect/config-entries/exported-services"
}, },
{ {
"title": "Proxy Defaults", "title": "Proxy Defaults",