kubernetes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Client = dapr.Client
View Source
var ErrDaprNotInstall = errors.New("dapr is not installed in your cluster")

Functions

func DeletePlugins

func DeletePlugins(client k8s.Interface, pluginID string) error

DeletePlugins curl -XDELETE "http://192.168.123.11:30777/v1/plugins/keel-echo"

func GetStatusAndHealthyInPodList added in v0.2.0

func GetStatusAndHealthyInPodList(podList DaprPodList) (status string, healthy string)

GetStatusAndHealthyInPodList loop through all replicas and update to Running/Healthy status only if all instances are Running and Healthy.

func GetTKeelNameSpace

func GetTKeelNameSpace(client k8s.Interface) (string, error)

func Init

func Init(config InitConfiguration) (err error)

Init deploys the tKeel operator using the supplied runtime version.

func InstallPlugin added in v0.2.0

func InstallPlugin(config InitConfiguration, releaseName, pluginRepo, pluginName, version string) error

InstallPlugin deploys the tKeel plugin.

func Invoke added in v0.2.0

func Invoke(pluginID, method string, data []byte, verb string) (string, error)

Invoke is a command to invoke a remote or local dapr instance.

func Register

func Register(pluginID string) error

func RegisterPlugins

func RegisterPlugins(client k8s.Interface, pluginID string) error

func Remove added in v0.2.0

func Remove(pluginID string) error

func Uninstall

func Uninstall(namespace string, timeout uint, debugMode bool) error

Uninstall removes tKeel from a Kubernetes cluster.

Types

type App added in v0.2.0

type App struct {
	AppID     string `csv:"APP ID"   json:"appId"   yaml:"appId"`
	AppPort   string `csv:"APP PORT" json:"appPort" yaml:"appPort"`
	PodName   string `csv:"POD NAME" json:"podName" yaml:"podName"`
	NameSpace string `csv:"NAMESPACE" json:"nameSpace" yaml:"nameSpace"`
	Age       string `csv:"AGE"      json:"age"     yaml:"age"`
	Created   string `csv:"CREATED"  json:"created" yaml:"created"`
	Version   string `csv:"VERSION"  json:"version" yaml:"version"`
}

func (App) Request added in v0.2.0

func (a App) Request(r *rest.Request) *rest.Request

type DaprPod added in v0.2.0

type DaprPod core_v1.Pod

func AppPod added in v0.2.0

func AppPod(client k8s.Interface, appID string) (*DaprPod, error)

func (*DaprPod) App added in v0.2.0

func (p *DaprPod) App() App

type DaprPodList added in v0.2.0

type DaprPodList []DaprPod

func ListPluginPods added in v0.2.0

func ListPluginPods(client k8s.Interface, appIDs ...string) (DaprPodList, error)

List outputs plugins.

Example
client, err := Client()
if err != nil {
	fmt.Println(err)
}
{
	ret, err := ListPluginPods(client)
	if err != nil {
		panic(err)
	}
	fmt.Println("pods:", len(ret))

	ret, err = ListPluginPods(client, "rudder")
	if err != nil {
		panic(err)
	}
	fmt.Println("pods:", len(ret))

	for _, p := range ret {
		app := p.App()
		if app.AppID == "rudder" {
			res := app.Request(client.CoreV1().RESTClient().Get()).Suffix("v1/plugins")
			ret := res.Do(context.TODO())
			raw, err := ret.Raw()
			fmt.Println(string(raw), err)
		}
	}
}
Output:

pods: 4
pods: 1
{"pluginList":[{"id":"keel-echo","tkeel_version":"v0.2.0","secret":"changeme","register_timestamp":1637909273}]} <nil>

func (DaprPodList) GroupByAppID added in v0.2.0

func (l DaprPodList) GroupByAppID() map[string]DaprPodList

type InitConfiguration

type InitConfiguration struct {
	Version    string
	Namespace  string
	EnableMTLS bool
	EnableHA   bool
	Args       []string
	Wait       bool
	Timeout    uint
	DebugMode  bool
}

type ListOutput

type ListOutput struct {
	AppID   string `csv:"APP ID"`
	AppPort string `csv:"APP PORT"`
	Age     string `csv:"AGE"`
	Created string `csv:"CREATED"`
	Status  string `json:"status"`
}

ListOutput represents the application ID, application port and creation time.

type Plugin

type Plugin struct {
	PluginID     string `json:"plugin_id"`
	Version      string `json:"version"`
	Secret       string `json:"secret"`
	RegisterTime int64  `json:"register_time"`
	Status       string `json:"status"`
}

func ListPlugins

func ListPlugins(client k8s.Interface) ([]Plugin, error)

type PluginResponse

type PluginResponse struct {
	Ret  int      `json:"ret"`
	Msg  string   `json:"msg"`
	Data []Plugin `json:"data"`
}

type StatusClient

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

func NewStatusClient

func NewStatusClient() (*StatusClient, error)

Create a new k8s client for status commands.

type StatusOutput

type StatusOutput struct {
	Name         string `csv:"NAME"`
	Namespace    string `csv:"NAMESPACE"`
	Healthy      string `csv:"HEALTHY"`
	Status       string `csv:"STATUS"`
	PluginStatus string `csv:"PLUGINSTATUS"`
	Replicas     int    `csv:"REPLICAS"`
	Version      string `csv:"VERSION"`
	Age          string `csv:"AGE"`
	Created      string `csv:"CREATED"`
}

StatusOutput represents the status of a named tKeel resource.

func List

func List() ([]StatusOutput, error)

type TenantCreateResp

type TenantCreateResp struct {
	TenantID    string `json:"tenant_id"`
	Title       string `json:"title"`
	CreatedTime int64  `json:"created_time"`
	TenantAdmin User   `json:"tenant_admin"`
}

func CreateTenant

func CreateTenant(client k8s.Interface, namespace, tenantTitle string) (*TenantCreateResp, error)

func TenantCreate

func TenantCreate(tenantTitle string) (*TenantCreateResp, error)

type TenantCreateResponse

type TenantCreateResponse struct {
	Ret  int              `json:"ret"`
	Msg  string           `json:"msg"`
	Data TenantCreateResp `json:"data"`
}

type TenantListData

type TenantListData struct {
	TenantList []TenantCreateResp `json:"tenant_list"`
}

func ListTenant

func ListTenant(client k8s.Interface, namespace string) (*TenantListData, error)

func TenantList

func TenantList() (*TenantListData, error)

type TenantListResponse

type TenantListResponse struct {
	Ret  int            `json:"ret"`
	Msg  string         `json:"msg"`
	Data TenantListData `json:"data"`
}

type User

type User struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Password   string `json:"password"`
	TenantID   string `json:"tenant_id"`
	Email      string `json:"email"`
	CreateTime int64  `json:"create_time"`
}

Jump to

Keyboard shortcuts

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