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

How to register external consul agent with consul server running on K8 #14

Closed
ervikrant06 opened this issue Oct 5, 2018 · 1 comment

Comments

@ervikrant06
Copy link

ervikrant06 commented Oct 5, 2018

Deployed consul using helm chart on minikube. By default consul-server is headless service.

 kubectl get svc
NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                   AGE
consul-dns      ClusterIP   10.103.165.156   <none>        53/TCP,53/UDP                                                             4h
consul-server   ClusterIP   None             <none>        8500/TCP,8301/TCP,8301/UDP,8302/TCP,8302/UDP,8300/TCP,8600/TCP,8600/UDP   4h
consul-ui       NodePort    10.103.15.241    <none>        80:30613/TCP                                                              4h
kubernetes      ClusterIP   10.96.0.1        <none>        443/TCP                                                                   5h
my-nginx        NodePort    10.102.190.41    <none>        80:32513/TCP                                                              1h

If I am running a consul agent outside the K8 cluster how can I register it with consul server running on K8.

Tried the options like port-forward but it's listening on the loopback address only which will not work in my scenario.

I am running minikube (192.168.99.100) on my mac. I started docker-machine (192.168.99.101) on which I wanted to start the consul-agent and connect it with consul server running on K8.

$ kubectl port-forward consul-server-0 8500:8500
Forwarding from 127.0.0.1:8500 -> 8500

Running consul-agent on docker-machine.

docker@consul1:~$ docker run -d --rm --net=host consul agent --retry-join=192.168.99.100:8500 -bind=192.168.99.101
f82b6b20e004b214ca1db5d497d3b056c35d4571c36096c88061fca6b90feda0

docker@consul1:~$ docker logs f82b6b20e004
==> Starting Consul agent...
==> Consul agent running!
           Version: 'v1.2.3'
           Node ID: '36bda601-4cb8-5125-d765-5419ff6a1144'
         Node name: 'consul1'
        Datacenter: 'dc1' (Segment: '')
            Server: false (Bootstrap: false)
       Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, DNS: 8600)
      Cluster Addr: 192.168.99.101 (LAN: 8301, WAN: 8302)
           Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false

==> Log data will now stream in as it occurs:

    2018/10/05 18:50:13 [INFO] serf: EventMemberJoin: consul1 192.168.99.101
    2018/10/05 18:50:13 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp)
    2018/10/05 18:50:13 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp)
    2018/10/05 18:50:13 [INFO] agent: Started HTTP server on 127.0.0.1:8500 (tcp)
    2018/10/05 18:50:13 [INFO] agent: started state syncer
    2018/10/05 18:50:13 [INFO] agent: Retry join LAN is supported for: aliyun aws azure digitalocean gce k8s os packet scaleway softlayer triton vsphere
    2018/10/05 18:50:13 [INFO] agent: Joining LAN cluster...
    2018/10/05 18:50:13 [INFO] agent: (LAN) joining: [192.168.99.100:8500]
    2018/10/05 18:50:13 [WARN] manager: No servers available
    2018/10/05 18:50:13 [ERR] agent: failed to sync remote state: No known Consul servers
    2018/10/05 18:50:23 [INFO] agent: (LAN) joined: 0 Err: 1 error(s) occurred:

* Failed to join 192.168.99.100: read tcp 192.168.99.101:52520->192.168.99.100:8500: i/o timeout
    2018/10/05 18:50:23 [WARN] agent: Join LAN failed: <nil>, retrying in 30s

How can I make this work?

@mitchellh
Copy link
Contributor

These issues shouldn't be used for general Q&A, please ask this question on the Consul mailing list. We try to keep issues for actual feature requests or bug reports for the particular project.

I'll post one response here but if you want follow-ups please pick it back up on the ML. The recommended approach for an agent to join a server running in K8S is documented here: https://www.consul.io/docs/platform/k8s/out-of-cluster-nodes.html As documented there, a certain amount of network connectivity between the agents is necessary. Some other options are given there if that isn't possible, but its pretty limiting.

ndhanushkodi pushed a commit to ndhanushkodi/consul-k8s that referenced this issue Jul 9, 2021
t-eckert pushed a commit that referenced this issue Sep 8, 2022
# This is the 1st commit message:

Add service for terminating-gateways

# This is the commit message #2:

Add gateway-kind:terminating to deployment

# This is the commit message #3:

Add registration path for terminating gateways

# This is the commit message #4:

Add BATS tests

# This is the commit message #5:

Remove registration from terminating gateways deployment

# This is the commit message #6:

Set ports AFAIK in service

# This is the commit message #7:

Begin setting values for endpoints controller

# This is the commit message #8:

Copy values from deployment to endpoints controller (as comment)

# This is the commit message #9:

Use connect-init instead of acl-init

# This is the commit message #10:

Remove guards from term gw service (they will get hit by the deployment)

# This is the commit message #11:

Range over gateways to produce a service for each deployment

# This is the commit message #12:

Add test for multiple gateways

# This is the commit message #13:

Remove the format script

# This is the commit message #14:

Note which parts of the config have been set
wilkermichael added a commit that referenced this issue Oct 13, 2022
wilkermichael added a commit that referenced this issue Oct 14, 2022
wilkermichael added a commit that referenced this issue Oct 17, 2022
wilkermichael added a commit that referenced this issue Oct 18, 2022
wilkermichael added a commit that referenced this issue Oct 18, 2022
wilkermichael added a commit that referenced this issue Oct 18, 2022
ishustava pushed a commit that referenced this issue Feb 18, 2023
…ul-636-apply-code-review-consul-address

[CONSUL-636] Apply Code Review: Consul Address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants