<p>I am trying to do Consul setup via Kubernetes, helm chart, <a href="https://www.consul.io/docs/k8s/helm" rel="nofollow noreferrer">https://www.consul.io/docs/k8s/helm</a></p>
<p>Based on my pre-Kubernetes knowledge: services, using Consul access via Consul Agent, running on each host and listening on hosts IP</p>
<p>Now, I deployed via Helm chart to Kubernetes cluster. First misunderstanding the terminology, Consul Agent vs Client in this setup? I presume it is the same</p>
<p>Now, set up:</p>
<p>Helm chart config (Terraform fragment), nothing specific to Clients/Agent's and their service:</p>
<pre><code>global:
  name: &quot;consul&quot;
  datacenter: &quot;${var.consul_config.datacenter}&quot;
server:
  storage: &quot;${var.consul_config.storage}&quot;
  connect: false

syncCatalog:
  enabled: true
  default: true
  k8sAllowNamespaces: ['*']
  k8sDenyNamespaces: [${join(&quot;,&quot;, var.consul_config.k8sDenyNamespaces)}]
</code></pre>
<p>Pods, client/agent ones are DaemonSet, not in host network mode</p>
<pre><code>kubectl get pods
NAME                                  READY   STATUS    RESTARTS   AGE
consul-8l587                          1/1     Running   0          11h
consul-cfd8z                          1/1     Running   0          11h
consul-server-0                       1/1     Running   0          11h
consul-server-1                       1/1     Running   0          11h
consul-server-2                       1/1     Running   0          11h
consul-sync-catalog-8b688ff9b-klqrv   1/1     Running   0          11h
consul-vrmtp                          1/1     Running   0          11h
</code></pre>
<p>Services</p>
<pre><code> kubectl get service
NAME            TYPE           CLUSTER-IP       EXTERNAL-IP             PORT(S)                                                                   AGE
consul          ExternalName   &lt;none&gt;           consul.service.consul   &lt;none&gt;                                                                    11h
consul-dns      ClusterIP      172.20.124.238   &lt;none&gt;                  53/TCP,53/UDP                                                             11h
consul-server   ClusterIP      None             &lt;none&gt;                  8500/TCP,8301/TCP,8301/UDP,8302/TCP,8302/UDP,8300/TCP,8600/TCP,8600/UDP   11h
consul-ui       ClusterIP      172.20.131.29    &lt;none&gt;                  80/TCP                                                                    11h
</code></pre>
<p><strong>Question 1</strong> Where is a service, to target Client (Agent) pods, but not Server's pods ? Did I miss it in helm chart?</p>
<p>My plan is, while I am not going to use Host (Kubernetes node) networking:</p>
<ol>
<li>Find the Client/Agent service or make my own. So, it will be used by the Consul's user's. E.g., this service address I will specify for Consul template init pod of the Consul template. In the config consuming application</li>
</ol>
<pre><code>kubectl get pods --selector app=consul,component=client,release=consul
consul-8l587   1/1     Running   0          11h
consul-cfd8z   1/1     Running   0          11h
consul-vrmtp   1/1     Running   0          11h

</code></pre>
<ol start="2">
<li>Optional: will add a topologyKeys in to agent service, so each consumer will not cross host boundary</li>
</ol>
<p><strong>Question 2</strong> Is it right approach? Or it is different for Consul  Kubernetes deployments</p>

Vetal
<p>You can use the Kubernetes downward API to inject the IP of host as an environment variable for your pod.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: consul-example
spec:
  containers:
    - name: example
      image: 'consul:latest'
      env:
        - name: HOST_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
      command:
        - '/bin/sh'
        - '-ec'
        - |
          export CONSUL_HTTP_ADDR=&quot;${HOST_IP}:8500&quot;
          consul kv put hello world
  restartPolicy: Never
</code></pre>
<p>See <a href="https://www.consul.io/docs/k8s/installation/install#accessing-the-consul-http-api" rel="nofollow noreferrer">https://www.consul.io/docs/k8s/installation/install#accessing-the-consul-http-api</a> for more info.</p>
