kubernetes

package module
v2.0.0-...-03508dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

Kubernetes Registry Plugin for micro

This is a plugin for go-micro that allows you to use Kubernetes as a registry.

Overview

This registry plugin makes use of Annotations and Labels on a Kubernetes pod to build a service discovery mechanism.

RBAC

If your Kubernetes cluster has RBAC enabled, a role and role binding will need to be created to allow this plugin to list and patch pods.

A cluster role can be used to specify the list and patch requirements, while a role binding per namespace can be used to apply the cluster role. The example RBAC configs below assume your Micro-based services are running in the test namespace, and the pods that contain the services are using the micro-services service account.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: micro-registry
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - list
  - patch
  - watch
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: micro-registry
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: micro-registry
subjects:
- kind: ServiceAccount
  name: micro-services
  namespace: test

Gotchas

  • Registering/Deregistering relies on the HOSTNAME Environment Variable, which inside a pod is the place where it can be retrieved from. (This needs improving)

Connecting to the Kubernetes API

Within a pod

If the --registry_address flag is omitted, the plugin will securely connect to the Kubernetes API using the pods "Service Account". No extra configuration is necessary.

Find out more about service accounts here. http://kubernetes.io/docs/user-guide/accessing-the-cluster/

Outside of Kubernetes

Some functions of the plugin should work, but its not been heavily tested. Currently no TLS support.

Documentation

Overview

Package kubernetes provides a kubernetes registry

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(opts ...registry.Option) registry.Registry

NewRegistry creates a kubernetes registry

Types

This section is empty.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL