mirror of https://github.com/status-im/consul.git
Merge pull request #11739 from hashicorp/ap/exports-rename
This commit is contained in:
commit
a725f06c83
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
api: **(Enterprise Only)** rename partition-exports config entry to exported-services.
|
||||
```
|
|
@ -16,10 +16,10 @@ type Config struct {
|
|||
|
||||
type ExportFetcher interface {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
|
@ -1980,6 +1980,6 @@ func filterACL(r *ACLResolver, token string, subj interface{}) error {
|
|||
|
||||
type partitionInfoNoop struct{}
|
||||
|
||||
func (p *partitionInfoNoop) ExportsForPartition(partition string) acl.PartitionExports {
|
||||
return acl.PartitionExports{}
|
||||
func (p *partitionInfoNoop) ExportsForPartition(partition string) acl.ExportedServices {
|
||||
return acl.ExportedServices{}
|
||||
}
|
||||
|
|
|
@ -594,10 +594,10 @@ func (c *ConfigEntry) ResolveServiceConfig(args *structs.ServiceConfigRequest, r
|
|||
}
|
||||
|
||||
func gateWriteToSecondary(targetDC, localDC, primaryDC, kind string) error {
|
||||
// Partition exports are gated from interactions from secondary DCs
|
||||
// ExportedServices entries are gated from interactions from secondary DCs
|
||||
// because non-default partitions cannot be created in secondaries
|
||||
// and services cannot be exported to another datacenter.
|
||||
if kind != structs.PartitionExports {
|
||||
if kind != structs.ExportedServices {
|
||||
return nil
|
||||
}
|
||||
if localDC == "" {
|
||||
|
@ -611,10 +611,10 @@ func gateWriteToSecondary(targetDC, localDC, primaryDC, kind string) error {
|
|||
|
||||
switch {
|
||||
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:
|
||||
return fmt.Errorf("partition-exports writes must not target secondary datacenters.")
|
||||
return fmt.Errorf("exported-services writes must not target secondary datacenters.")
|
||||
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -2093,7 +2093,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "",
|
||||
localDC: "dc1",
|
||||
primaryDC: "",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2102,7 +2102,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "",
|
||||
localDC: "dc1",
|
||||
primaryDC: "dc1",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2111,7 +2111,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "dc1",
|
||||
localDC: "dc1",
|
||||
primaryDC: "dc1",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2120,7 +2120,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "dc2",
|
||||
localDC: "dc1",
|
||||
primaryDC: "",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
wantErr: "writes must not target secondary datacenters",
|
||||
},
|
||||
|
@ -2130,7 +2130,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "dc2",
|
||||
localDC: "dc1",
|
||||
primaryDC: "dc1",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
wantErr: "writes must not target secondary datacenters",
|
||||
},
|
||||
|
@ -2140,7 +2140,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "dc2",
|
||||
localDC: "dc2",
|
||||
primaryDC: "dc1",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
wantErr: "writes must not target secondary datacenters",
|
||||
},
|
||||
|
@ -2150,7 +2150,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
targetDC: "",
|
||||
localDC: "dc2",
|
||||
primaryDC: "dc1",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
wantErr: "must target the primary datacenter explicitly",
|
||||
},
|
||||
|
@ -2158,7 +2158,7 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||
name: "empty local DC",
|
||||
args: args{
|
||||
localDC: "",
|
||||
kind: structs.PartitionExports,
|
||||
kind: structs.ExportedServices,
|
||||
},
|
||||
wantErr: "unknown local datacenter",
|
||||
},
|
||||
|
@ -2179,7 +2179,7 @@ func Test_gateWriteToSecondary_AllowedKinds(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, kind := range structs.AllConfigEntryKinds {
|
||||
if kind == structs.PartitionExports {
|
||||
if kind == structs.ExportedServices {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ func (s *Server) reconcileLocalConfig(ctx context.Context, configs []structs.Con
|
|||
defer ticker.Stop()
|
||||
|
||||
for i, entry := range configs {
|
||||
// Partition exports only apply to the primary datacenter.
|
||||
if entry.GetKind() == structs.PartitionExports {
|
||||
// Exported services only apply to the primary datacenter.
|
||||
if entry.GetKind() == structs.ExportedServices {
|
||||
continue
|
||||
}
|
||||
req := structs.ConfigEntryRequest{
|
||||
|
|
|
@ -395,7 +395,7 @@ func validateProposedConfigEntryInGraph(
|
|||
}
|
||||
case structs.ServiceIntentions:
|
||||
case structs.MeshConfig:
|
||||
case structs.PartitionExports:
|
||||
case structs.ExportedServices:
|
||||
default:
|
||||
return fmt.Errorf("unhandled kind %q during validation of %q", kindName.Kind, kindName.Name)
|
||||
}
|
||||
|
|
|
@ -178,12 +178,12 @@ func TestUsageReporter_emitNodeUsage_OSS(t *testing.T) {
|
|||
{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",
|
||||
Value: 0,
|
||||
Labels: []metrics.Label{
|
||||
{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"},
|
||||
},
|
||||
},
|
||||
"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",
|
||||
Value: 0,
|
||||
Labels: []metrics.Label{
|
||||
{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"},
|
||||
},
|
||||
},
|
||||
"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",
|
||||
Value: 0,
|
||||
Labels: []metrics.Label{
|
||||
{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"},
|
||||
},
|
||||
},
|
||||
"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",
|
||||
Value: 0,
|
||||
Labels: []metrics.Label{
|
||||
{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"},
|
||||
},
|
||||
},
|
||||
"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",
|
||||
Value: 0,
|
||||
Labels: []metrics.Label{
|
||||
{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"},
|
||||
},
|
||||
},
|
||||
"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",
|
||||
Value: 0,
|
||||
Labels: []metrics.Label{
|
||||
{Name: "datacenter", Value: "dc1"},
|
||||
{Name: "kind", Value: "partition-exports"},
|
||||
{Name: "kind", Value: "exported-services"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ const (
|
|||
TerminatingGateway string = "terminating-gateway"
|
||||
ServiceIntentions string = "service-intentions"
|
||||
MeshConfig string = "mesh"
|
||||
PartitionExports string = "partition-exports"
|
||||
ExportedServices string = "exported-services"
|
||||
|
||||
ProxyConfigGlobal string = "global"
|
||||
MeshConfigMesh string = "mesh"
|
||||
|
@ -45,7 +45,7 @@ var AllConfigEntryKinds = []string{
|
|||
TerminatingGateway,
|
||||
ServiceIntentions,
|
||||
MeshConfig,
|
||||
PartitionExports,
|
||||
ExportedServices,
|
||||
}
|
||||
|
||||
// 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
|
||||
case MeshConfig:
|
||||
return &MeshConfigEntry{}, nil
|
||||
case PartitionExports:
|
||||
return &PartitionExportsConfigEntry{Name: name}, nil
|
||||
case ExportedServices:
|
||||
return &ExportedServicesConfigEntry{Name: name}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid config entry kind: %s", kind)
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"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.
|
||||
type PartitionExportsConfigEntry struct {
|
||||
type ExportedServicesConfigEntry struct {
|
||||
Name string
|
||||
|
||||
// Services is a list of services to be exported and the list of partitions
|
||||
|
@ -40,7 +40,7 @@ type ServiceConsumer struct {
|
|||
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)
|
||||
for _, svc := range e.Services {
|
||||
if _, ok := resp[svc.Namespace]; !ok {
|
||||
|
@ -57,7 +57,7 @@ func (e *PartitionExportsConfigEntry) ToMap() map[string]map[string][]string {
|
|||
return resp
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) Clone() *PartitionExportsConfigEntry {
|
||||
func (e *ExportedServicesConfigEntry) Clone() *ExportedServicesConfigEntry {
|
||||
e2 := *e
|
||||
e2.Services = make([]ExportedService, len(e.Services))
|
||||
for _, svc := range e.Services {
|
||||
|
@ -72,11 +72,11 @@ func (e *PartitionExportsConfigEntry) Clone() *PartitionExportsConfigEntry {
|
|||
return &e2
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) GetKind() string {
|
||||
return PartitionExports
|
||||
func (e *ExportedServicesConfigEntry) GetKind() string {
|
||||
return ExportedServices
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) GetName() string {
|
||||
func (e *ExportedServicesConfigEntry) GetName() string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ func (e *PartitionExportsConfigEntry) GetName() string {
|
|||
return e.Name
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) GetMeta() map[string]string {
|
||||
func (e *ExportedServicesConfigEntry) GetMeta() map[string]string {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
return e.Meta
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) Normalize() error {
|
||||
func (e *ExportedServicesConfigEntry) Normalize() error {
|
||||
if e == nil {
|
||||
return fmt.Errorf("config entry is nil")
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ func (e *PartitionExportsConfigEntry) Normalize() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) Validate() error {
|
||||
func (e *ExportedServicesConfigEntry) Validate() error {
|
||||
if e.Name == "" {
|
||||
return fmt.Errorf("Name is required")
|
||||
}
|
||||
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 {
|
||||
|
@ -136,19 +136,19 @@ func (e *PartitionExportsConfigEntry) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) CanRead(authz acl.Authorizer) bool {
|
||||
func (e *ExportedServicesConfigEntry) CanRead(authz acl.Authorizer) bool {
|
||||
var authzContext acl.AuthorizerContext
|
||||
e.FillAuthzContext(&authzContext)
|
||||
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
|
||||
e.FillAuthzContext(&authzContext)
|
||||
return authz.MeshWrite(&authzContext) == acl.Allow
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) GetRaftIndex() *RaftIndex {
|
||||
func (e *ExportedServicesConfigEntry) GetRaftIndex() *RaftIndex {
|
||||
if e == nil {
|
||||
return &RaftIndex{}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ func (e *PartitionExportsConfigEntry) GetRaftIndex() *RaftIndex {
|
|||
return &e.RaftIndex
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) GetEnterpriseMeta() *EnterpriseMeta {
|
||||
func (e *ExportedServicesConfigEntry) GetEnterpriseMeta() *EnterpriseMeta {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -168,13 +168,13 @@ func (e *PartitionExportsConfigEntry) GetEnterpriseMeta() *EnterpriseMeta {
|
|||
// correct 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.
|
||||
func (e *PartitionExportsConfigEntry) MarshalJSON() ([]byte, error) {
|
||||
type Alias PartitionExportsConfigEntry
|
||||
func (e *ExportedServicesConfigEntry) MarshalJSON() ([]byte, error) {
|
||||
type Alias ExportedServicesConfigEntry
|
||||
source := &struct {
|
||||
Kind string
|
||||
*Alias
|
||||
}{
|
||||
Kind: PartitionExports,
|
||||
Kind: ExportedServices,
|
||||
Alias: (*Alias)(e),
|
||||
}
|
||||
return json.Marshal(source)
|
||||
|
|
|
@ -1665,9 +1665,9 @@ func TestDecodeConfigEntry(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "partition-exports",
|
||||
name: "exported-services",
|
||||
snake: `
|
||||
kind = "partition-exports"
|
||||
kind = "exported-services"
|
||||
name = "foo"
|
||||
meta {
|
||||
"foo" = "bar"
|
||||
|
@ -1698,7 +1698,7 @@ func TestDecodeConfigEntry(t *testing.T) {
|
|||
]
|
||||
`,
|
||||
camel: `
|
||||
Kind = "partition-exports"
|
||||
Kind = "exported-services"
|
||||
Name = "foo"
|
||||
Meta {
|
||||
"foo" = "bar"
|
||||
|
@ -1728,7 +1728,7 @@ func TestDecodeConfigEntry(t *testing.T) {
|
|||
}
|
||||
]
|
||||
`,
|
||||
expect: &PartitionExportsConfigEntry{
|
||||
expect: &ExportedServicesConfigEntry{
|
||||
Name: "foo",
|
||||
Meta: map[string]string{
|
||||
"foo": "bar",
|
||||
|
|
|
@ -22,7 +22,7 @@ const (
|
|||
TerminatingGateway string = "terminating-gateway"
|
||||
ServiceIntentions string = "service-intentions"
|
||||
MeshConfig string = "mesh"
|
||||
PartitionExports string = "partition-exports"
|
||||
ExportedServices string = "exported-services"
|
||||
|
||||
ProxyConfigGlobal string = "global"
|
||||
MeshConfigMesh string = "mesh"
|
||||
|
@ -277,8 +277,8 @@ func makeConfigEntry(kind, name string) (ConfigEntry, error) {
|
|||
return &ServiceIntentionsConfigEntry{Kind: kind, Name: name}, nil
|
||||
case MeshConfig:
|
||||
return &MeshConfigEntry{}, nil
|
||||
case PartitionExports:
|
||||
return &PartitionExportsConfigEntry{Name: name}, nil
|
||||
case ExportedServices:
|
||||
return &ExportedServicesConfigEntry{Name: name}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid config entry kind: %s", kind)
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ package api
|
|||
|
||||
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.
|
||||
type PartitionExportsConfigEntry struct {
|
||||
// Name is the name of the partition the PartitionExportsConfigEntry applies to.
|
||||
type ExportedServicesConfigEntry struct {
|
||||
// Name is the name of the partition the ExportedServicesConfigEntry applies to.
|
||||
// Partitioning is a Consul Enterprise feature.
|
||||
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.
|
||||
// Partitioning is a Consul Enterprise feature.
|
||||
Partition string `json:",omitempty"`
|
||||
|
@ -49,23 +49,23 @@ type ServiceConsumer struct {
|
|||
Partition string
|
||||
}
|
||||
|
||||
func (e *PartitionExportsConfigEntry) GetKind() string { return PartitionExports }
|
||||
func (e *PartitionExportsConfigEntry) GetName() string { return e.Name }
|
||||
func (e *PartitionExportsConfigEntry) GetPartition() string { return e.Name }
|
||||
func (e *PartitionExportsConfigEntry) GetNamespace() string { return IntentionDefaultNamespace }
|
||||
func (e *PartitionExportsConfigEntry) GetMeta() map[string]string { return e.Meta }
|
||||
func (e *PartitionExportsConfigEntry) GetCreateIndex() uint64 { return e.CreateIndex }
|
||||
func (e *PartitionExportsConfigEntry) GetModifyIndex() uint64 { return e.ModifyIndex }
|
||||
func (e *ExportedServicesConfigEntry) GetKind() string { return ExportedServices }
|
||||
func (e *ExportedServicesConfigEntry) GetName() string { return e.Name }
|
||||
func (e *ExportedServicesConfigEntry) GetPartition() string { return e.Name }
|
||||
func (e *ExportedServicesConfigEntry) GetNamespace() string { return IntentionDefaultNamespace }
|
||||
func (e *ExportedServicesConfigEntry) GetMeta() map[string]string { return e.Meta }
|
||||
func (e *ExportedServicesConfigEntry) GetCreateIndex() uint64 { return e.CreateIndex }
|
||||
func (e *ExportedServicesConfigEntry) GetModifyIndex() uint64 { return e.ModifyIndex }
|
||||
|
||||
// MarshalJSON adds the Kind field so that the JSON can be decoded back into the
|
||||
// correct type.
|
||||
func (e *PartitionExportsConfigEntry) MarshalJSON() ([]byte, error) {
|
||||
type Alias PartitionExportsConfigEntry
|
||||
func (e *ExportedServicesConfigEntry) MarshalJSON() ([]byte, error) {
|
||||
type Alias ExportedServicesConfigEntry
|
||||
source := &struct {
|
||||
Kind string
|
||||
*Alias
|
||||
}{
|
||||
Kind: PartitionExports,
|
||||
Kind: ExportedServices,
|
||||
Alias: (*Alias)(e),
|
||||
}
|
||||
return json.Marshal(source)
|
||||
|
|
|
@ -2722,9 +2722,9 @@ func TestParseConfigEntry(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "partition-exports",
|
||||
name: "exported-services",
|
||||
snake: `
|
||||
kind = "partition-exports"
|
||||
kind = "exported-services"
|
||||
name = "foo"
|
||||
meta {
|
||||
"foo" = "bar"
|
||||
|
@ -2755,7 +2755,7 @@ func TestParseConfigEntry(t *testing.T) {
|
|||
]
|
||||
`,
|
||||
camel: `
|
||||
Kind = "partition-exports"
|
||||
Kind = "exported-services"
|
||||
Name = "foo"
|
||||
Meta {
|
||||
"foo" = "bar"
|
||||
|
@ -2787,7 +2787,7 @@ func TestParseConfigEntry(t *testing.T) {
|
|||
`,
|
||||
snakeJSON: `
|
||||
{
|
||||
"kind": "partition-exports",
|
||||
"kind": "exported-services",
|
||||
"name": "foo",
|
||||
"meta": {
|
||||
"foo": "bar",
|
||||
|
@ -2820,7 +2820,7 @@ func TestParseConfigEntry(t *testing.T) {
|
|||
`,
|
||||
camelJSON: `
|
||||
{
|
||||
"Kind": "partition-exports",
|
||||
"Kind": "exported-services",
|
||||
"Name": "foo",
|
||||
"Meta": {
|
||||
"foo": "bar",
|
||||
|
@ -2851,7 +2851,7 @@ func TestParseConfigEntry(t *testing.T) {
|
|||
]
|
||||
}
|
||||
`,
|
||||
expect: &api.PartitionExportsConfigEntry{
|
||||
expect: &api.ExportedServicesConfigEntry{
|
||||
Name: "foo",
|
||||
Meta: map[string]string{
|
||||
"foo": "bar",
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: 'Configuration Entry Kind: Partition Exports'
|
||||
page_title: 'Configuration Entry Kind: Exported Services'
|
||||
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.
|
||||
---
|
||||
|
||||
# Partition Exports
|
||||
# Exported Services
|
||||
|
||||
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+.
|
||||
|
||||
## 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
|
||||
|
||||
* A Consul Enterprise binary
|
||||
* A partition that corresponds to the configuration entry. As in, the partition exports config entry for partition "frontend" requires that the "frontend" partition exists
|
||||
* A partition that corresponds to the configuration entry. As in, the exported services config entry for partition "frontend" requires that the "frontend" partition exists
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
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:
|
||||
* 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.
|
||||
|
||||
## 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="Exported services configuration syntax" tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
|
||||
<CodeBlockConfig>
|
||||
|
||||
```hcl
|
||||
Kind = "partition-exports"
|
||||
Kind = "exported-services"
|
||||
Partition = "<partition containing services to export>"
|
||||
Services = [
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ Services = [
|
|||
|
||||
```yaml
|
||||
apiVersion: consul.hashicorp.com/v1alpha1
|
||||
Kind: PartitionExports
|
||||
Kind: ExportedServices
|
||||
Partition: <partition containing services to export>
|
||||
Services:
|
||||
- Consumers:
|
||||
|
@ -71,7 +71,7 @@ Services:
|
|||
<CodeBlockConfig>
|
||||
|
||||
```json
|
||||
"Kind": "partition-exports",
|
||||
"Kind": "exported-services",
|
||||
"Partition": "<partition containing services to export>",
|
||||
"Services": [
|
||||
{
|
||||
|
@ -90,11 +90,11 @@ Services:
|
|||
|
||||
### 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 |
|
||||
| --- | --- | --- | --- |
|
||||
| `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 |
|
||||
| `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 |
|
||||
|
@ -115,7 +115,7 @@ The following example configures the agent to export the `billing` service from
|
|||
<CodeBlockConfig>
|
||||
|
||||
```hcl
|
||||
Kind = "partition-exports"
|
||||
Kind = "exported-services"
|
||||
Partition = "finance"
|
||||
|
||||
Services = [
|
||||
|
@ -147,7 +147,7 @@ Services = [
|
|||
<CodeBlockConfig>
|
||||
|
||||
```yaml
|
||||
Kind: partition-exports
|
||||
Kind: exported-services
|
||||
Partition: finance
|
||||
Services:
|
||||
- Consumers:
|
||||
|
@ -165,7 +165,7 @@ Services:
|
|||
<CodeBlockConfig>
|
||||
|
||||
```json
|
||||
"Kind": "partition-exports",
|
||||
"Kind": "exported-services",
|
||||
"Partition": "finance",
|
||||
"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.
|
||||
|
||||
See [Health HTTP Endpoint](/api-docs/health) for additional information.
|
||||
See [Health HTTP Endpoint](/api-docs/health) for additional information.
|
|
@ -55,7 +55,7 @@ Values specified for [`proxy-defaults`](/docs/connect/config-entries/proxy-defau
|
|||
|
||||
### 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.
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
||||
- [`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)
|
||||
- [`ServiceDefaults`](/docs/connect/config-entries/service-defaults)
|
||||
- [`ServiceSplitter`](/docs/connect/config-entries/service-splitter)
|
||||
|
|
|
@ -151,8 +151,8 @@
|
|||
"path": "connect/config-entries/mesh"
|
||||
},
|
||||
{
|
||||
"title": "Partition Exports",
|
||||
"path": "connect/config-entries/partition-exports"
|
||||
"title": "Exported Services",
|
||||
"path": "connect/config-entries/exported-services"
|
||||
},
|
||||
{
|
||||
"title": "Proxy Defaults",
|
||||
|
|
|
@ -86,6 +86,11 @@ module.exports = [
|
|||
destination: '/docs/connect/registration/sidecar-service',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: '/docs/connect/config-entries/partition-exports',
|
||||
destination: '/docs/connect/config-entries/exported-services',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: '/docs/enterprise/license',
|
||||
destination: '/docs/enterprise/license/overview',
|
||||
|
|
Loading…
Reference in New Issue