kubernetes

Grey Matter Fabric supports service discovery from Kubernetes. See the Grey Matter Control Kubernetes discovery setup documentation for how to configure this with Grey Matter Control.

Kubernetes Deployments

Kubernetes (k8s) has a number of internal APIs that are used for the complex orchestration of containers. When using k8s as the underlying orchestration platform, Grey Matter Control can utilize some of these APIs to also do easy service announcement and discovery.

The Grey Matter Control server will discover services based on their pod IP and container port, see the kubernetes specifications in the setup docs for how to configure your deployments for service discovery. Also, see the example deployment.

Behavior

As described in the Grey Matter Control service discovery kubernetes docs, the Grey Matter Control server will discover from namespaces specified on startup by the environment variable GM_CONTROL_KUBERNETES_NAMESPACES. In the case that a Kubernetes namespace that Control is configured to discover from is or becomes undiscoverable (see permissions), the Control server follows a specific pattern of behavior.

If a namespace goes down, the Control server will label the connection to the namespace as having a bad state. It will retain the last known state of discovered pods for the namespace and generate clusters for them. If the namespace eventually becomes discoverable again, it will update its pod list accordingly. In the meantime, it will continue to poll the unavailable namespace, and it will be left up to EDS to determine the endpoint health for the last known state of the pods.

Example Deployment

The Kubernetes Deployment below is properly setup (label and port) to be discovered by the Grey Matter Control server.

apiVersion: apps/v1
kind: Deployment
spec:
selector:
matchLabels:
app: example
replicas: 1
template:
metadata:
labels:
gm_cluster: example
spec:
containers:
- name: example-service
image: docker.greymatter.io/internal/example-service:latest
- name: sidecar
image: docker.greymatter.io/release/gm-proxy:1.2.1
imagePullPolicy: Always
ports:
- name: http
containerPort: 9080
- name: metrics
containerPort: 8081
env:
- name: PROXY_DYNAMIC
value: "true"
- name: XDS_CLUSTER
value: example
- name: XDS_HOST
value: gm-control
- name: XDS_PORT
value: "50000"