kube

package
v0.0.0-...-a4cc684 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ComponentMap = map[string]ComponentName{
	"admin":      Admin,
	"grafana":    Grafana,
	"nacos":      Nacos,
	"zookeeper":  Zookeeper,
	"prometheus": Prometheus,
	"skywalking": Skywalking,
	"zipkin":     Zipkin,
}

Functions

func BuildConfig

func BuildConfig(kubecfgPath string, ctx string) (*rest.Config, error)

BuildConfig loading rules: 1. kubeconfig if it not empty string 2. Config(s) in KUBECONFIG environment variable 3. In cluster config if running in-cluster 4. Use $HOME/.kube/config

func CompareObject

func CompareObject(objA, objB *Object) (string, error)

CompareObject compares two objects and returns diff.

func CompareObjects

func CompareObjects(objsA, objsB Objects) (string, string, string)

CompareObjects compares object lists and returns diff, add, err using util.DiffYAML. It compares objects with same hash value(Namespace:Kind:Name) and returns diff. For objects that only one list have, it returns add. For objects that could not be parsed successfully, it returns err. Refer to TestCompareObjects for examples.

func OverlayObject

func OverlayObject(base *unstructured.Unstructured, overlay *unstructured.Unstructured) error

OverlayObject uses JSON patch strategy to overlay two unstructured objects

Types

type AdminComponent

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

func (*AdminComponent) RenderManifest

func (ac *AdminComponent) RenderManifest() (string, error)

func (*AdminComponent) Run

func (ac *AdminComponent) Run() error

type Component

type Component interface {
	Run() error
	RenderManifest() (string, error)
}

Component is used to represent dubbo control plane module, eg: zookeeper

func NewAdminComponent

func NewAdminComponent(spec *v1alpha1.AdminSpec, opts ...ComponentOption) (Component, error)

func NewGrafanaComponent

func NewGrafanaComponent(spec *v1alpha1.GrafanaSpec, opts ...ComponentOption) (Component, error)

func NewNacosComponent

func NewNacosComponent(spec *v1alpha1.NacosSpec, opts ...ComponentOption) (Component, error)

func NewPrometheusComponent

func NewPrometheusComponent(spec *v1alpha1.PrometheusSpec, opts ...ComponentOption) (Component, error)

func NewSkywalkingComponent

func NewSkywalkingComponent(spec *v1alpha1.SkywalkingSpec, opts ...ComponentOption) (Component, error)

func NewZipkinComponent

func NewZipkinComponent(spec *v1alpha1.ZipkinSpec, opts ...ComponentOption) (Component, error)

func NewZookeeperComponent

func NewZookeeperComponent(spec *v1alpha1.ZookeeperSpec, opts ...ComponentOption) (Component, error)

type ComponentName

type ComponentName string
const (
	Admin      ComponentName = "admin"
	Grafana    ComponentName = "grafana"
	Nacos      ComponentName = "nacos"
	Zookeeper  ComponentName = "zookeeper"
	Prometheus ComponentName = "prometheus"
	Skywalking ComponentName = "skywalking"
	Zipkin     ComponentName = "zipkin"
)

type ComponentOption

type ComponentOption func(*ComponentOptions)

func WithChartPath

func WithChartPath(path string) ComponentOption

func WithNamespace

func WithNamespace(namespace string) ComponentOption

func WithRepoURL

func WithRepoURL(url string) ComponentOption

func WithVersion

func WithVersion(version string) ComponentOption

type ComponentOptions

type ComponentOptions struct {
	Namespace string

	// local
	ChartPath string

	// remote
	RepoURL string
	Version string
}

type CtlClient

type CtlClient struct {
	client.Client
	// contains filtered or unexported fields
}

CtlClient wraps controller-runtime clientgen and is used by dubboctl

func NewCtlClient

func NewCtlClient(opts ...CtlClientOption) (*CtlClient, error)

func (*CtlClient) ApplyManifest

func (cli *CtlClient) ApplyManifest(manifest string, ns string, name ComponentName) error

ApplyManifest applies manifest to certain namespace If there is not this namespace, create it first

func (*CtlClient) ApplyObject

func (cli *CtlClient) ApplyObject(obj *unstructured.Unstructured) error

ApplyObject creates or updates unstructured object

func (*CtlClient) CreateNamespace

func (cli *CtlClient) CreateNamespace(ns string) error

func (*CtlClient) RemoveManifest

func (cli *CtlClient) RemoveManifest(manifest string, ns string) error

func (*CtlClient) RemoveObject

func (cli *CtlClient) RemoveObject(obj *unstructured.Unstructured) error

type CtlClientOption

type CtlClientOption func(*CtlClientOptions)

func WithCli

func WithCli(cli client.Client) CtlClientOption

func WithContext

func WithContext(ctx string) CtlClientOption

func WithKubeConfigPath

func WithKubeConfigPath(path string) CtlClientOption

type CtlClientOptions

type CtlClientOptions struct {
	// for normal use
	// path to kubeconfig
	KubeConfigPath string
	// specify cluster in kubeconfig to use
	Context string

	// for test
	Cli client.Client
}

type DubboOperator

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

func NewDubboOperator

func NewDubboOperator(spec *v1alpha1.DubboConfigSpec, cli *CtlClient) (*DubboOperator, error)

NewDubboOperator accepts cli directly for testing and normal use. For now, every related command needs a dedicated DubboOperator.

func (*DubboOperator) ApplyManifest

func (do *DubboOperator) ApplyManifest(manifestMap map[ComponentName]string) error

ApplyManifest apply bootstrap manifests to k8s cluster

func (*DubboOperator) RemoveManifest

func (do *DubboOperator) RemoveManifest(manifestMap map[ComponentName]string) error

RemoveManifest removes resources represented by bootstrap manifests

func (*DubboOperator) RenderManifest

func (do *DubboOperator) RenderManifest() (map[ComponentName]string, error)

RenderManifest renders bootstrap manifests specified by DubboConfigSpec.

func (*DubboOperator) Run

func (do *DubboOperator) Run() error

Run must be invoked before invoking other functions.

type GrafanaComponent

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

func (*GrafanaComponent) RenderManifest

func (gc *GrafanaComponent) RenderManifest() (string, error)

func (*GrafanaComponent) Run

func (gc *GrafanaComponent) Run() error

type NacosComponent

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

func (*NacosComponent) RenderManifest

func (nc *NacosComponent) RenderManifest() (string, error)

func (*NacosComponent) Run

func (nc *NacosComponent) Run() error

type Object

type Object struct {
	Namespace string
	Name      string
	Group     string
	Kind      string
	// contains filtered or unexported fields
}

Object wraps k8s Unstructured and exposes the fields we need

func NewObject

func NewObject(obj *unstructured.Unstructured, yamlStr string) *Object

func ParseObjectFromManifest

func ParseObjectFromManifest(manifest string) (*Object, error)

ParseObjectFromManifest parse Object from manifest which represents a single K8s object

func (*Object) Hash

func (obj *Object) Hash() string

func (*Object) IsEqual

func (obj *Object) IsEqual(another *Object) bool

func (*Object) IsValid

func (obj *Object) IsValid() bool

func (*Object) SetNamespace

func (obj *Object) SetNamespace(ns string)

func (*Object) Unstructured

func (obj *Object) Unstructured() *unstructured.Unstructured

func (*Object) YAML

func (obj *Object) YAML() string

type Objects

type Objects []*Object

func ParseObjectsFromManifest

func ParseObjectsFromManifest(manifest string, continueOnErr bool) (Objects, error)

ParseObjectsFromManifest parse Objects from manifest which divided by YAML separator "\n---\n"

func (Objects) SortMap

func (objs Objects) SortMap() (map[string]*Object, []string)

SortMap generates corresponding map and sorted keys

type PortForward

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

func NewPortForward

func NewPortForward(podName, namespace, localAddress string, localPort, podPort int, cfg *rest.Config) (*PortForward, error)

func (*PortForward) Run

func (pf *PortForward) Run() error

func (*PortForward) Stop

func (pf *PortForward) Stop()

Stop close stopCh and free up resources

func (*PortForward) Wait

func (pf *PortForward) Wait()

Wait wait for closing stopCh which means that Stop function is the only way to trigger

type PrometheusComponent

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

func (*PrometheusComponent) RenderManifest

func (pc *PrometheusComponent) RenderManifest() (string, error)

func (*PrometheusComponent) Run

func (pc *PrometheusComponent) Run() error

type SkywalkingComponent

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

func (*SkywalkingComponent) RenderManifest

func (sc *SkywalkingComponent) RenderManifest() (string, error)

func (*SkywalkingComponent) Run

func (sc *SkywalkingComponent) Run() error

type ZipkinComponent

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

func (*ZipkinComponent) RenderManifest

func (zc *ZipkinComponent) RenderManifest() (string, error)

func (*ZipkinComponent) Run

func (zc *ZipkinComponent) Run() error

type ZookeeperComponent

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

func (*ZookeeperComponent) RenderManifest

func (zc *ZookeeperComponent) RenderManifest() (string, error)

func (*ZookeeperComponent) Run

func (zc *ZookeeperComponent) Run() error

Jump to

Keyboard shortcuts

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