<p>So I'm currently running on my local Kubernetes cluster (running on docker) the stable/consul chart from helm.</p>

<pre><code>  $ helm install -n wet-fish --namespace consul stable/consul
</code></pre>

<p>This creates two services</p>

<pre><code>==&gt; v1/Service
NAME                TYPE       CLUSTER-IP      EXTERNAL-IP  PORT(S)                                                                           AGE
wet-fish-consul     ClusterIP  None            &lt;none&gt;       8500/TCP,8400/TCP,8301/TCP,8301/UDP,8302/TCP,8302/UDP,8300/TCP,8600/TCP,8600/UDP  0s
wet-fish-consul-ui  NodePort   10.110.229.223  &lt;none&gt;       8500:30276/TCP     
</code></pre>

<p>So this means I can run <code>localhost:30276</code> and see the consul ui.</p>

<p>Now I'm running on my local machine</p>

<pre><code>  $ consul agent -dev -config-dir=./consul.d -node=machine
  $ consul join 127.0.0.1:30276
</code></pre>

<p>This just results in:</p>

<pre><code>Error joining address '127.0.0.1:30276': Unexpected response code: 500 (1 error occurred:
        * Failed to join 127.0.0.1: received invalid msgType (72), expected pushPullMsg (6) from=127.0.0.1:30276

)
Failed to join any nodes.
</code></pre>

<p>and </p>

<pre><code>2020/01/17 15:17:35 [WARN] agent: (LAN) couldn't join: 0 Err: 1 error occurred:
        * Failed to join 127.0.0.1: received invalid msgType (72), expected pushPullMsg (6) from=127.0.0.1:30276

    2020/01/17 15:17:35 [ERR] http: Request PUT /v1/agent/join/127.0.0.1:30276, error: 1 error occurred:
        * Failed to join 127.0.0.1: received invalid msgType (72), expected pushPullMsg (6) from=127.0.0.1:30276

 from=127.0.0.1:59693
</code></pre>

<p>There must be a way to have a local consul agent running that can connect to the k8s consul server...</p>

<p>This is on a Mac, so networking isn't as good....</p>

Callum Linington
<p>There may be two problems here, the first is that consul agent -dev starts the agent in dev mode. By default dev mode is going to start both a server and an agent. This might be part of the reason behind the error.</p>

<p>The other problem could be due to localhost, the server running in Kubernetes will attempt to health check local agents. It needs to be able to ping the local agent, so even if you manage to join in the first step, it would probably fail health checks.</p>

<p>I agree about networking on Mac it does not make things easy, one thing you will probably have to do is set the advertise address for the local agent (non kube). Docker for mac has a host name <code>docker.for.mac.localhost</code> which is a routable ip to the local machine from a container. When starting the local agent if you set the advertise address to the ip value of that host Kubernetes Consul server should be able to route to the locally running agent.</p>

<p>Potential fix:
1. Ensure local agent is starting in client mode (manually configure not -dev)
2. Set advertise advertise address to an ip address which is routable from Kubernetes <code>docker.for.mac.localhost</code></p>

<p>Give me a shout if that does not work for you, I have used a setup like this myself, 9/10 it is networking between Docker and the local machine.</p>

<p>Kind regards,</p>

<p>Nic</p>
