Register services to Consul in Kubernetes


I could use some help with registering services that are running locally. My goal is to start consul unaware services locally on my Mac which can be registered in the Consul servers. Consul is running in kubernetes. I used port forward like so: kubectl port-forward service/consul-server 8501:8501 … and this works without errors…

I’m trying the demo here: Connect Services with Consul Service Mesh | Consul - HashiCorp Learn

First issue is that “consul reload” works, but I can’t resolve this error and nothing shows up in localhost:8501 UI:

==> Consul Connect proxy starting…
Handling connection for 8501
==> Error preparing configuration: No sidecar proxy registered for socat

I’ve also tried to register a dependent service by following this: Consul Connect … and after running the command: consul connect proxy -sidecar-for web it starts successfully, but still nothing shows up in the UI at localhost:8501 …

One last thing, I just noticed that when I try to query the services with curl, I’m getting this error: "Client sent an HTTP request to an HTTPS server"

What am I missing?


Hi Michael,

Could you try the following guide instead that walks you through creating intentions using our new CRD interface for Kubernetes? Manage Consul Service Mesh using Kubernetes Custom Resource Definitions (CRDs) | Consul - HashiCorp Learn. The guide you linked is a good primer for you for Consul on VMs, but the experience is slightly different for Kubernetes.

For Kubernetes, we automatically bring up the sidecar for you (which is Envoy) if you have either provided an annotation for your pod or deployment or set the connect.default value to true in your Helm config.

Hi David

Thank you for the reply. This is great CRD info which I was not aware of. One more question. If I just start a simple service on my laptop, is there a way to connect this to my Consul server running in kubernetes? I haven’t been able to get this work correctly.

Hi Mike,

You’ll need to follow the instructions here on either joining the pod network or joining via host ports: Consul Clients Outside of Kubernetes - Kubernetes | Consul by HashiCorp.

I’m curious, could you describe the use case some more on where you’d like your own laptop to the Server running on Kubernetes? If this is for development, I would either give Consul on K8s for minikube or kind a try and just run everything in a single Datacenter and logical network.

kind: Consul Service Discovery and Mesh on Kubernetes in Docker (kind) | Consul - HashiCorp Learn
minikube: Consul Service Discovery and Mesh on Minikube | Consul - HashiCorp Learn

Hi David,

Thanks for the info. Regarding our use case…it’s a bit unclear right now… besides needing this for development, we also have fleet of on-prem systems which run services so thoses bare metal systems will be needing to connect to consul as well… and for development I’m sure that at some point I’ll push for the dev’s to use minikube or k8s… as you suggested… but for now I just want to be able to set up a simple local connection to consul in my k8s cluster…

The join doc that you sent has almost worked, but I’ve been unable resolve this error: [ERROR] agent.anti_entropy: failed to sync remote state: error="No known Consul servers"

Here is a snippet from my configuration:

** enabled: true**
** replicas: 3**
** exposeGossipAndRPCPorts: true**
** ports:**
** serflan:**
** port: 9301**
** enabled: true**
** grpc: true**
** exposeGossipPorts: true**

Here is the command I’m using:

consul agent -advertise=“x.x.x.x” -data-dir=/tmp/consul -retry-join=‘provider=k8s host_network=true label_selector=“app=consul,component=server”’ -bind= -datacenter=“dc1” -hcl='ports { grpc = 8502 }'

Here is a snippet of the output of the command:

==> Starting Consul agent…
** Version: ‘1.8.4’**
** Node ID: ‘23eb4355-a05b-74c1-a50b-63bb62708f3d’**
** Node name: ‘mjw.local’**
** Datacenter: ‘dc1’ (Segment: ‘’)**
** Server: false (Bootstrap: false)**
** Client Addr: [] (HTTP: 8500, HTTPS: -1, gRPC: 8502, DNS: 8600)**
** Cluster Addr: (LAN: 8301, WAN: 8302)**
** Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false, Auto-Encrypt-TLS: false**
2021-02-16T19:09:33.571-0800 [INFO] agent.router: Initializing LAN area manager
** 2021-02-16T19:09:33.571-0800 [INFO] agent: Started DNS server: address= network=tcp**
** 2021-02-16T19:09:33.572-0800 [INFO] agent: Started DNS server: address= network=udp**
** 2021-02-16T19:09:33.572-0800 [INFO] agent: Started HTTP server: address= network=tcp**
** 2021-02-16T19:09:33.573-0800 [INFO] agent: Started gRPC server: address= network=tcp**
2021-02-16T19:09:33.573-0800 [INFO] agent: Joining cluster…: cluster=LAN
2021-02-16T19:09:33.573-0800 [INFO] agent: started state syncer
==> Consul agent running!
2021-02-16T19:09:33.573-0800 [WARN] agent.router.manager: No servers available
** 2021-02-16T19:09:33.573-0800 [ERROR] agent.anti_entropy: failed to sync remote state: error=“No known Consul servers”**

any suggestions are appreciated…