kubernetes

package module
v0.8.0 Latest Latest
Warning

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

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

README

Kubernetes

基于 Labels 获取 Service 的服务注册与发现。

安装

go get github.com/aacfactory/fns-contrib/discovery/kubernetes@main

使用

配置文件,其中kind必须是 kubernetes,且必须小写。

{
  "services": {
    "discovery": {
      "enable": true,
      "kind": "kubernetes",
      "config": {
        "namespace": ""      // kubernetes 的 namespace
      }
    }
  }
}

代码注入,没有其它操作了。

import _ "github.com/aacfactory/fns-contrib/discovery/kubernetes"

注意

  • 在 service 的 yaml 文件中需配置 key 为 fns,value 为 service namespace (多个时用 , 连接)的 Labels。
  • 所有的 fns 必须是 clusterIP 类型。
  • Kubernetes 支持版本为 1.20 到 1.22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retriever

func Retriever(option fns.ServiceDiscoveryOption) (discovery fns.ServiceDiscovery, err error)

Types

type Config

type Config struct {
	Namespace string `json:"namespace,omitempty"`
}

type Kube

type Kube struct {
	fns.AbstractServiceDiscovery
	// contains filtered or unexported fields
}

func (*Kube) Close

func (k *Kube) Close()

func (*Kube) Publish

func (k *Kube) Publish(svc fns.Service) (err error)

func (*Kube) Registrations added in v0.8.0

func (k *Kube) Registrations() (registrations map[string]*fns.Registration)

Jump to

Keyboard shortcuts

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