innerdomain

package
v1.5.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: 5 Imported by: 0

Documentation

Overview

Package innerdomain , interconversion between k8s & marathon internal domain

旧版本的内部地址格式

<servicename>.<servicegroup-name>.<servicegroup-namespace>.<suffix1>.<suffix2>.marathon.l4lb.thisdcos.directory

e.g. (marathon) prototype.prod-6056.services.v1.runtimes.marathon.l4lb.thisdcos.directory (k8s) 不存在旧版本k8s地址 (marathon) consul.consul-afdb5eb0327848e19f3d414eb345dfdd.addons-2126.v1.runtimes.marathon.l4lb.thisdcos.directory (k8s) 不存在旧版本k8s地址

新版本的内部地址格式

marathon:

<servicename>.<namespace>.marathon.l4lb.thisdcos.directory

k8s:

<servicename>.<namespace>.svc.cluster.local

_LIMIT_: <namespace> 最长63位, <namespace> 必须保持唯一

e.g. (marathon) blog-service.<namespace>.marathon.l4lb.thisdcos.directory (k8s) blog-service.<namespace>.svc.cluster.local

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAddr 输入地址不规范
	ErrInvalidAddr = errors.New("invalid input address")
	// ErrMarathonLegacyAddr marathon _旧版_ 内部域名不满足规则
	ErrMarathonLegacyAddr = fmt.Errorf("invalid legacy marathon addr, not satisfy regexp: %v",
		marathonLegacyRegex)
	// ErrMarathonAddr marathon 内部域名不满足规则
	ErrMarathonAddr = fmt.Errorf("invalid marathon addr, not satisfy regexp: %v", marathonRegex)
	// ErrK8SAddr k8s 内部域名不满足规则
	ErrK8SAddr = fmt.Errorf("invalid k8s addr: not satisfy regexp: %v", k8sRegex)
	// ErrTooLongNamespace 内部域名的 namespace 部分过长
	ErrTooLongNamespace = errors.New("internal addr's namespace length > 63")
	// ErrNoLegacyK8SAddr 不存在 k8s _旧版_ 内部域名
	ErrNoLegacyK8SAddr = errors.New("can't generate legacy k8s internal addr")
)

Functions

func MustParseWithEnv

func MustParseWithEnv(originAddr string, k8s bool) string

func ParseWithEnv

func ParseWithEnv(originAddr string, k8s bool) (string, error)

ParseWithEnv

Types

type InnerDomain

type InnerDomain struct {
	// contains filtered or unexported fields
}

InnerDomain 代表内部地址

func New

func New(servicename, namespace string) (InnerDomain, error)

New 根据 servicename, namespace 构建 InnerDomain

func Parse

func Parse(originAddr string) (InnerDomain, error)

Parse 从 host 解析出 InnerDomain

func (*InnerDomain) K8S

func (i *InnerDomain) K8S() (string, error)

K8S 生成 k8s 版本的内部地址

func (*InnerDomain) Marathon

func (i *InnerDomain) Marathon() (string, error)

Marathon 生成 marathon 版本的内部地址

func (*InnerDomain) MustK8S

func (i *InnerDomain) MustK8S() string

MustK8S 类似 K8S,如果出错则panic

func (*InnerDomain) MustMarathon

func (i *InnerDomain) MustMarathon() string

MustMarathon 类似 Marathon,如果出错则 panic

Jump to

Keyboard shortcuts

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