Skip to content

Conversation

@hc-github-team-consul-core
Copy link
Collaborator

Backport

This PR is auto-generated from #23133 to be assessed for backporting due to the inclusion of the label backport/1.22.

The below text is copied from the body of the original PR.


Description

The services can be imported across partitions with in a local data center. However there is no API to List the services imported by the downstream partition. The new API /v1/imported-services Lists the imported services across partitions with in a local datacenter.

Testing & Reproduction steps

Step 1: Create consul server agents
Step 2: Create partitions
consul partition create -name upstream -description "Upstream partition with services" -token=root
consul partition create -name downstream -description "Downstream partition consuming services" -token=root
Step 3: Run separate consul client agents for each partitions.
Step 4: Register the services in partitions

consul services register -token=root -http-addr=http://localhost:8510 payment-service.json

payment-service.json

{
  "service": {
    "id": "payments-1",
    "name": "payments",
    "tags": ["upstream", "api", "v1"],
    "port": 8080,
    "address": "127.0.0.1",
    "meta": {
      "version": "1.0.0",
      "environment": "test"
    },
    "check": {
      "name": "Always passing check",
      "ttl": "30s",
      "status": "passing"
    }
  }
}

consul services register -token=root -http-addr=http://localhost:8520 billing-service.json

billing-service.json

{
  "service": {
    "id": "billing-1",
    "name": "billing",
    "tags": ["downstream", "finance", "api", "v2"],
    "port": 8081,
    "address": "127.0.0.1",
    "meta": {
      "version": "2.1.0",
      "environment": "test",
      "team": "finance"
    },
    "check": {
      "name": "Always passing check",
      "ttl": "30s",
      "status": "passing"
    }
  }
}

consul config write -http-addr=http://localhost:8520 -token=root exported-services.hcl

exported-services.hcl

Kind = "exported-services"
Name = "upstream"
Partition = "upstream"

Services = [
  {
    Name = "payments"
    Namespace = "default"
    Consumers = [
      {
        Partition = "downstream"
      }
    ]
  }
]

Step 5: Below curl will help in fetching the imported services

curl -s -H "X-Consul-Token: root" \
  'http://localhost:8500/v1/imported-services?partition=downstream'

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.


Overview of commits

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved Consul Bot automated PR

@github-actions github-actions bot added theme/api Relating to the HTTP API interface theme/cli Flags and documentation for the CLI interface labels Jan 12, 2026
@nitin-sachdev-29 nitin-sachdev-29 merged commit 3b259d3 into release/1.22.x Jan 12, 2026
156 of 158 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme/api Relating to the HTTP API interface theme/cli Flags and documentation for the CLI interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants