kubernetes

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginConfig = `` /* 748-byte string literal not displayed */

	PluginOAuth2 = `` /* 775-byte string literal not displayed */

)
View Source
const (
	Always       = "Always"
	IfNotPresent = "IfNotPresent"
)

Variables

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

Functions

func AddRepo added in v0.4.5

func AddRepo(name, url string) error

func AdminLogin added in v0.4.5

func AdminLogin(password string) (token string, err error)

func CleanInvalidTenants added in v1.0.3

func CleanInvalidTenants(pluginID string, tenants []string, namespace string) error

func CleanToken added in v0.4.5

func CleanToken()

func CoreApply added in v0.4.5

func CoreApply(filenames []string) error

func CoreCreate added in v0.4.5

func CoreCreate(filenames []string) error

func CoreGet added in v0.4.5

func CoreGet(entityID string) error

func CoreList added in v0.4.5

func CoreList(search, selector string) error

func CoreWatch added in v0.4.5

func CoreWatch(entityID string) error

func CreateTenant

func CreateTenant(tenant *TenantCreateIn) error

func DeleteRepo added in v0.4.5

func DeleteRepo(name string) error

func DisablePlugin added in v0.4.5

func DisablePlugin(pluginID, tenantID string) error

func EnablePlugin added in v0.4.5

func EnablePlugin(pluginID, tenantID string) error

func GetConfig added in v0.5.1

func GetConfig(client k8s.Interface, name, namespace string) (*corev1.ConfigMap, error)

func GetRedisPassword added in v1.0.3

func GetRedisPassword(namespace string) (string, error)

func GetStatusAndHealthyInPodList added in v0.2.0

func GetStatusAndHealthyInPodList(appList DaprAppList) (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 added in v0.4.5

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

func GroupByAppID added in v0.4.5

func GroupByAppID(l DaprAppList) map[string]DaprAppList

func Init

func Init(config InitConfiguration) error

Init deploys the tKeel operator using the supplied runtime version.

func InitHelmConfig added in v0.4.7

func InitHelmConfig(namespace string, log action.DebugLog) (*action.Configuration, error)

func InjectConfig added in v0.6.0

func InjectConfig(root *chart.Chart, name, secret string) error

func Install added in v0.4.5

func Install(repo, plugin, version, name string, config []byte) error

func Invoke added in v0.2.0

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

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

func InvokeByPortForward added in v0.4.5

func InvokeByPortForward(pluginID, method string, data []byte, verb string, reqOpts ...HTTPRequestOption) (string, error)

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

func PluginUpgrade added in v0.4.5

func PluginUpgrade(repo, plugin, version, name string, config []byte) error

func RegisterPlugin added in v0.4.5

func RegisterPlugin(plugin string) error

func RegisterPlugins

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

func TenantCreate

func TenantCreate(title, remark, adminName, adminPW string) error

func TenantDelete added in v0.4.5

func TenantDelete(tenantID string) error

func TenantUserCreate added in v0.4.5

func TenantUserCreate(tenantID, username, password string) error

func TenantUserDelete added in v0.4.5

func TenantUserDelete(tenantID, userID string) error

tenant user manage.

func UninstallAllPlugin added in v0.4.5

func UninstallAllPlugin() error

func UninstallPlatform added in v0.4.5

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

UninstallPlatform removes tKeel from a Kubernetes cluster.

func UninstallPlugin added in v0.4.5

func UninstallPlugin(pluginID string) error

func Upgrade added in v0.4.5

func Upgrade(config InitConfiguration) error

func WebsocketByPortForward added in v0.4.5

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

WebsocketByPortForward websocket request to the k8s pod.

func WithAppPod added in v0.4.5

func WithAppPod(pf *PortForward, app *AppPod) error

func WithAppPort added in v0.4.5

func WithAppPort(pf *PortForward, app *AppPod) error

func WithHTTPPort added in v0.4.5

func WithHTTPPort(pf *PortForward, app *AppPod) error

Types

type AddRepoRequest added in v0.4.5

type AddRepoRequest struct {
	URL string `json:"url"`
}

type AppInfo added in v0.4.5

type AppInfo struct {
	AppID     string `csv:"APP ID"      json:"app_id"        yaml:"app_id"`
	HTTPPort  int    `csv:"HTTP PORT"   json:"http_port"     yaml:"http_port"`
	GRPCPort  int    `csv:"GRPC PORT"   json:"grpc_port"     yaml:"grpc_port"`
	AppPort   int    `csv:"APP PORT"    json:"app_port"      yaml:"app_port"`
	PodName   string `csv:"POD NAME"    json:"pod_name"      yaml:"pod_name"`
	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 (*AppInfo) Request added in v0.4.5

func (a *AppInfo) Request(r *rest.Request, method string, data []byte) (*rest.Request, error)

type AppPod added in v0.2.0

type AppPod struct {
	AppInfo
	// contains filtered or unexported fields
}

func GetAppPod added in v0.4.5

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

type AuthRequest added in v0.4.5

type AuthRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type CoreStruct added in v0.4.5

type CoreStruct struct {
	APIVersion string                 `yaml:"apiVersion"` //nolint
	Type       string                 `yaml:"type"`
	ID         string                 `yaml:"id"`
	Source     string                 `yaml:"source"`
	Owner      string                 `yaml:"owner"`
	Properties map[string]interface{} `yaml:"properties"`
}

type DaprAppList added in v0.4.5

type DaprAppList []*AppPod

func ListAppInfos added in v0.4.5

func ListAppInfos(client k8s.Interface, appIDs ...string) (DaprAppList, error)

ListAppInfos ListPluginPods outputs plugins list.

type DaprPod added in v0.2.0

type DaprPod core_v1.Pod

type DaprStatus added in v0.4.5

type DaprStatus struct {
	Installed   bool   `json:"installed"`
	Version     string `json:"version"`
	Namespace   string `json:"namespace"`
	MTLSEnabled bool   `json:"mtls_enabled"`
}

func CheckDapr added in v0.6.0

func CheckDapr() (*DaprStatus, error)

type DeleteResponse added in v0.4.5

type DeleteResponse struct {
	Plugin *Plugin `json:"plugin"`
}

type EnablePluginRequest added in v0.4.5

type EnablePluginRequest struct {
	PluginID string `json:"plugin_id"`
}

type EnableTenant added in v1.0.3

type EnableTenant struct {
	TenantID        string `json:"tenant_id"`
	OperatorID      string `json:"operator_id"`
	EnableTimestamp int    `json:"enable_timestamp"`
}

type HTTPRequestOption added in v0.4.5

type HTTPRequestOption func(*http.Request) error

func InvokeSetHTTPHeader added in v0.4.5

func InvokeSetHTTPHeader(header, val string) HTTPRequestOption

type InitConfiguration

type InitConfiguration struct {
	Version           string
	KeelVersion       string
	CoreVersion       string
	RudderVersion     string
	MiddlewareVersion string
	Namespace         string
	Secret            string
	EnableMTLS        bool
	EnableHA          bool
	DaprVersion       string
	Args              []string
	Wait              bool
	Timeout           uint
	DebugMode         bool
	ConfigFile        string
	Password          string
	Repo              *kitconfig.Repo
	DefaultConfig     bool
	ImagePolicy       string
}

type InstalledListOutput added in v0.4.5

type InstalledListOutput struct {
	Name          string `csv:"NAME"`
	Plugin        string `csv:"PLUGIN"`
	PluginVersion string `csv:"PLUGIN VERSION"`
	Repo          string `csv:"REPO"`
	RegisterAt    string `csv:"REGISTER_AT"`
	Status        string `csv:"STATE"`
	Description   string `csv:"DESCRIPTION"`
}

func InstalledPlugin added in v0.6.0

func InstalledPlugin() ([]InstalledListOutput, error)

func PluginInfo added in v0.4.5

func PluginInfo(pluginID string) ([]InstalledListOutput, error)

type InstallerListOutPut added in v0.4.5

type InstallerListOutPut struct {
	Name    string `csv:"NAME"`
	Version string `csv:"VERSION"`
	Repo    string `csv:"REPO"`
	Status  string `csv:"STATUS"`
}

func InstallerInfo added in v0.4.5

func InstallerInfo(repo, installer, version string) ([]InstallerListOutPut, error)

func InstallerList added in v0.4.5

func InstallerList(repo string) ([]InstallerListOutPut, error)

func InstallerListAll added in v0.4.5

func InstallerListAll() ([]InstallerListOutPut, error)

type ListResponse added in v0.4.5

type ListResponse struct {
	PluginList []*Plugin `json:"plugin_list"`
}

type MiddleConfig added in v0.4.7

type MiddleConfig map[string]map[string]interface{}

func ChartMiddleware added in v0.4.7

func ChartMiddleware(name, version string, config InitConfiguration) (*chart.Chart, MiddleConfig, error)

func (MiddleConfig) Update added in v0.4.7

func (mc MiddleConfig) Update(data MiddleConfig)

type Plugin

type Plugin struct {
	ID                string                  `json:"id,omitempty"`                 // plugin id.
	PluginVersion     string                  `json:"plugin_version,omitempty"`     // plugin version.
	TkeelVersion      string                  `json:"tkeel_version,omitempty"`      // plugin depend tkeel version.
	AddonsPoint       []*v1.AddonsPoint       `json:"addons_point,omitempty"`       // plugin declares addons.
	ImplementedPlugin []*v1.ImplementedPlugin `json:"implemented_plugin,omitempty"` // plugin implemented plugin list.
	Secret            string                  `json:"secret,omitempty"`             // plugin registered secret.
	RegisterTimestamp int64                   `json:"register_timestamp,omitempty"` // register timestamp.
	ActiveTenantes    []string                `json:"active_tenantes,omitempty"`    // active tenant's id list.
	RegisterAddons    []*RegisterAddons       `json:"register_addons,omitempty"`    // register addons router.
	Status            v1.PluginStatus         `json:"status,omitempty"`             // register plugin status.
}

func ListPlugins

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

func Unregister added in v0.4.5

func Unregister(pluginID string) (*Plugin, error)

func UnregisterPlugins added in v0.4.5

func UnregisterPlugins(client k8s.Interface, pluginID string) (*Plugin, error)

func (*Plugin) String added in v0.4.5

func (p *Plugin) String() string

type PluginEnableInfo added in v1.0.3

type PluginEnableInfo struct {
	ID        string `json:"id"`
	Installer struct {
		Repo       string `json:"repo"`
		Name       string `json:"name"`
		Version    string `json:"version"`
		Desc       string `json:"desc"`
		Maintainer []struct {
			Name  string `json:"name"`
			URL   string `json:"url"`
			Email string `json:"email"`
		} `json:"maintainer"`
	} `json:"installer"`
	TkeelVersion      string         `json:"tkeel_version"`
	Secret            string         `json:"secret"`
	RegisterTimestamp int            `json:"register_timestamp"`
	Version           string         `json:"version"`
	Status            int            `json:"status"`
	EnableTenantes    []EnableTenant `json:"enable_tenantes"`
}

type PortForward added in v0.4.5

type PortForward struct {
	Config     *rest.Config
	Method     string
	URL        *url.URL
	Host       string
	LocalPort  int
	RemotePort int
	EmitLogs   bool
	App        *AppPod
	StopCh     chan struct{}
	ReadyCh    chan struct{}
}

PortForward provides a port-forward connection in a kubernetes cluster.

func GetPodPortForward added in v1.0.3

func GetPodPortForward(name, namespace string, port int) (*PortForward, error)

func GetPortforward added in v0.4.5

func GetPortforward(appName string, options ...PortForwardConfigureOption) (*PortForward, error)

func NewPortForward added in v0.4.5

func NewPortForward(
	config *rest.Config,
	namespace, podName string,
	host string, localPort, remotePort int,
	emitLogs bool,
) (*PortForward, error)

NewPortForward returns an instance of PortForward struct that can be used for establishing port-forwarding connection to a pod in kubernetes cluster, specified by namespace and deployName.

func (*PortForward) GetStop added in v0.4.5

func (pf *PortForward) GetStop() <-chan struct{}

GetStop returns StopCh for a PortForward instance. Receiving on StopCh will block until the port forwarding stops.

func (*PortForward) Init added in v0.4.5

func (pf *PortForward) Init() error

Init creates and runs a port-forward connection. This function blocks until connection is established. Note: Caller should call Stop() to finish the connection.

func (*PortForward) Stop added in v0.4.5

func (pf *PortForward) Stop()

Stop terminates port-forwarding connection.

type PortForwardConfigureOption added in v0.4.5

type PortForwardConfigureOption func(*PortForward, *AppPod) error

type RegisterAddons added in v0.4.5

type RegisterAddons struct {
	Addons   string `json:"addons,omitempty"`   // addons name.
	Upstream string `json:"upstream,omitempty"` // upstream path.
}

type RepoListOutput added in v0.4.5

type RepoListOutput struct {
	Name   string `csv:"REPO NAME"`
	Remote string `csv:"REMOTE"`
}

func ListRepo added in v0.4.5

func ListRepo() ([]RepoListOutput, error)

type RepoPluginListOutput added in v0.4.5

type RepoPluginListOutput struct {
	Name        string `csv:"NAME"`
	Version     string `csv:"VERSION"`
	Status      string `csv:"STATUS"`
	Description string `csv:"DESCRIPTION"`
}

func ListPluginsOfTenant added in v1.0.0

func ListPluginsOfTenant(tenant string) ([]RepoPluginListOutput, error)

type RestRequestOption added in v0.4.5

type RestRequestOption func(*rest.Request) error

func InvokeSetRestRequestHeader added in v0.4.5

func InvokeSetRestRequestHeader(header string, val string) RestRequestOption

type SearchCondition added in v0.4.5

type SearchCondition struct {
	Field    string      `json:"field"`
	Operator string      `json:"operator"`
	Value    interface{} `json:"value"`
}

type SearchRequest added in v0.4.5

type SearchRequest struct {
	Query     string             `json:"query"`
	Condition []*SearchCondition `json:"condition"`
}

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 TKeelStatus added in v0.6.0

type TKeelStatus struct {
	Installed bool   `json:"installed"`
	Version   string `json:"version"`
	Namespace string `json:"namespace"`
}

func CheckTKeel added in v0.6.0

func CheckTKeel() (*TKeelStatus, error)

type TenantAdmin added in v0.4.5

type TenantAdmin struct {
	UserName string `json:"username"` //nolint
	Password string `json:"password"` //nolint
}

type TenantCreateIn added in v0.4.5

type TenantCreateIn struct {
	Title  string      `json:"title"`
	Remark string      `json:"remark"`
	Admin  TenantAdmin `json:"admin"`
}

type TenantListOutPut added in v0.4.5

type TenantListOutPut struct {
	ID     string `csv:"ID"`
	Title  string `csv:"TITLE"`
	Remark string `csv:"REMARK"`
}

func TenantInfo added in v0.4.5

func TenantInfo(tenantID string) ([]TenantListOutPut, error)

func TenantList

func TenantList() ([]TenantListOutPut, error)

func TenantPluginList added in v0.6.0

func TenantPluginList(pluginID string) ([]TenantListOutPut, error)

type UserInfo added in v0.4.5

type UserInfo struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type UserListOutPut added in v0.4.5

type UserListOutPut struct {
	ID       string `csv:"ID"`
	Username string `csv:"USERNAME"`
	TenantID string `csv:"TENANT ID"`
}

func TenantUserInfo added in v0.4.5

func TenantUserInfo(tenantID, userID string) ([]UserListOutPut, error)

func TenantUserList added in v0.4.5

func TenantUserList(tenantID string) ([]UserListOutPut, error)

Jump to

Keyboard shortcuts

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