Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Meta on ConsulTerminatingConfigEntry #16749

Conversation

Sol-Stiep
Copy link
Contributor

Description

Changes

  • Added support for ConsulTerminatingConfigEntry meta configuration:
    • Added Meta field to ConsulTerminatingConfigEntry struct and updated its receiver functions.
  • Updated jobspec/parse_service.go
  • Update related tests
  • Update Nomad Documentation for ConsulTerminatingConfigEntry struct.

Testing Changes

To test these changes you need to build a Nomad binary and deploy a cluster with both Nomad and Consul agents and clients.
When you have your cluster running you can run the following job-spec:

job "countdash-terminating" {

  datacenters = ["dc1"]

  group "api" {
    network {
      mode = "host"
      port "port" {
        static = "9001"
      }
    }
    
    service {
      name = "count-api"
      port = "port"
    }

    task "api" {
      driver = "docker"

      config {
        image        = "hashicorpdev/counter-api:v3"
        network_mode = "host"
      }
    }
  }

  group "gateway" {
    network {
      mode = "bridge"
    }

    service {
      name = "api-gateway"

      connect {
        gateway {          
          proxy {}     
         
          terminating {          
            service {
              name = "count-api"
            }
            
            # New Fields:
            meta {
              test-key = "test-value"
              test-key1 = "test-value1"
              test-key2 = "test-value2"
            }
          }
        }
      }
    }
  }
  group "dashboard" {
    network {
      mode = "bridge"

      port "http" {
        static = 9002
        to     = 9002
      }
    }

    service {
      name = "count-dashboard"
      port = "9002"

      connect {
        sidecar_service {
          proxy {
            upstreams {              
              destination_name = "count-api"
              local_bind_port  = 8080
            }
          }
        }
      }
    }

    task "dashboard" {
      driver = "docker"

      env {
        COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
      }

      config {
        image = "hashicorpdev/counter-dashboard:v3"
      }
    }
  }
}

Once the job is running and healthy, use Consul's API to get the terminating gateway's configuration:

curl --request GET http://127.0.0.1:8500/v1/config/terminating-gateway | json_pp

You will get the following JSON output:

[
   {
      "Meta" : {
         "test-key" : "test-value",
         "test-key1" : "test-value1",
         "test-key2" : "test-value2"
      },
      "Name" : "api-gateway",
      "Services" : [
         {
            "Name" : "count-api"
         }
      ],
      "CreateIndex" : 155,
      "Kind" : "terminating-gateway",
      "ModifyIndex" : 155
   }
]

Demo Video

ConsulTerminatingGatewayConfigEntry.mp4

@tgross tgross added this to the 1.7.x milestone Oct 30, 2023
@tgross tgross self-requested a review March 20, 2024 21:03
@tgross tgross modified the milestones: 1.7.x, 1.8.0 Apr 15, 2024
@tgross tgross added the stage/needs-rebase This PR needs to be rebased on main before it can be backported to pick up new BPA workflows label May 17, 2024
@tgross tgross modified the milestones: 1.8.0, 1.8.x Jun 4, 2024
@tgross tgross modified the milestones: 1.8.x, 1.9.x Sep 23, 2024
@tgross
Copy link
Member

tgross commented Nov 8, 2024

We didn't land this work when we did our big Consul refresh as it wasn't at the top of priority queue and was going to need rework to merge anyways. Given the current roadmap it doesn't make sense to try to ship these changes unless its in response to a specific request, so I'm going to close this out (and the other 2 similar PRs).

@tgross tgross closed this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-rebase This PR needs to be rebased on main before it can be backported to pick up new BPA workflows theme/consul
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants