2018-09-13 14:12:27 +00:00
|
|
|
---
|
2020-04-07 18:55:19 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: Consul Clients Outside of Kubernetes - Kubernetes
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: Consul Clients Outside Kubernetes
|
2020-04-07 18:55:19 +00:00
|
|
|
description: >-
|
|
|
|
Consul clients running on non-Kubernetes nodes can join a Consul cluster
|
|
|
|
running within Kubernetes.
|
2018-09-13 14:12:27 +00:00
|
|
|
---
|
|
|
|
|
2019-12-19 02:02:26 +00:00
|
|
|
# Consul Clients Outside Kubernetes
|
2018-09-13 14:12:27 +00:00
|
|
|
|
2019-12-19 02:02:26 +00:00
|
|
|
Consul clients running on non-Kubernetes nodes can join a Consul cluster running within Kubernetes.
|
2018-09-13 14:12:27 +00:00
|
|
|
|
|
|
|
## Auto-join
|
|
|
|
|
|
|
|
The recommended way to join a cluster running within Kubernetes is to
|
2020-04-13 21:24:10 +00:00
|
|
|
use the ["k8s" cloud auto-join provider](/docs/agent/cloud-auto-join#kubernetes-k8s).
|
2018-09-13 14:12:27 +00:00
|
|
|
|
|
|
|
The auto-join provider dynamically discovers IP addresses to join using
|
|
|
|
the Kubernetes API. It authenticates with Kubernetes using a standard
|
|
|
|
`kubeconfig` file. This works with all major hosted Kubernetes offerings
|
2019-12-06 20:32:33 +00:00
|
|
|
as well as self-hosted installations. The token in the `kubeconfig` file
|
|
|
|
needs to have permissions to list pods in the namespace where Consul servers
|
|
|
|
are deployed.
|
2018-09-13 14:12:27 +00:00
|
|
|
|
|
|
|
The auto-join string below will join a Consul server cluster that is
|
2020-04-09 23:46:54 +00:00
|
|
|
started using the [official Helm chart](/docs/platform/k8s/helm):
|
2018-09-13 14:12:27 +00:00
|
|
|
|
2020-04-07 23:56:08 +00:00
|
|
|
```shell
|
2018-09-13 14:12:27 +00:00
|
|
|
$ consul agent -retry-join 'provider=k8s label_selector="app=consul,component=server"'
|
|
|
|
```
|
|
|
|
|
2020-01-30 03:09:38 +00:00
|
|
|
By default, Consul will join the default gossip port. Pods may set an
|
2018-09-13 14:12:27 +00:00
|
|
|
annotation `consul.hashicorp.com/auto-join-port` to an integer value or
|
|
|
|
a named port to specify the port for the auto-join to return. This enables
|
|
|
|
different pods to have different exposed ports.
|
|
|
|
|
|
|
|
## Networking
|
|
|
|
|
2020-01-30 03:09:38 +00:00
|
|
|
Consul typically requires a fully connected network.
|
|
|
|
Because the Consul Helm chart currently doesn't allow exposing servers' gossip ports via a `hostPort`,
|
2019-12-19 02:02:26 +00:00
|
|
|
nodes outside of Kubernetes joining a cluster running within Kubernetes must be able to communicate
|
2020-01-30 03:09:38 +00:00
|
|
|
to pod IPs via the network. Note that the auto-join provider discussed above will use pod IPs by default.
|
2018-09-13 14:12:27 +00:00
|
|
|
|
|
|
|
-> **Consul Enterprise customers** may use
|
2020-04-09 23:20:00 +00:00
|
|
|
[network segments](/docs/enterprise/network-segments) to
|
2018-09-13 14:12:27 +00:00
|
|
|
enable non-fully-connected topologies. However, out-of-cluster nodes must still
|
|
|
|
be able to communicate with the server pod or host IP addresses.
|