k8s

package
v0.6.9-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Kibibyte = 1024
	Mebibyte = 1024 * 1024
	Gibibyte = 1024 * 1024 * 1024

	Megabyte = 1000 * 1000
	Gigabyte = 1000 * 1000 * 1000
)
View Source
const (
	DEFAULT_CLUSTER = "default_cluster"
)

Variables

Functions

func AddTwoResourceList added in v0.4.24

func AddTwoResourceList(oldResourceList metav1.ResourceList, newResourceList metav1.ResourceList) metav1.ResourceList

func GetAndUpdateConnectionStatusForOneCluster added in v0.4.24

func GetAndUpdateConnectionStatusForOneCluster(k8sClientSet *kubernetes.Clientset, clusterId int, respMap map[int]error, wg *sync.WaitGroup, mutex *sync.Mutex)

Types

type BatchResourceResponse added in v0.6.4

type BatchResourceResponse struct {
	ManifestResponse *application.ManifestResponse
	Err              error
}

type ClusterCapacityDetail added in v0.4.24

type ClusterCapacityDetail struct {
	Id                int                                   `json:"id,omitempty"`
	Name              string                                `json:"name,omitempty"`
	ErrorInConnection string                                `json:"errorInNodeListing,omitempty"`
	NodeCount         int                                   `json:"nodeCount,omitempty"`
	NodeErrors        map[metav1.NodeConditionType][]string `json:"nodeErrors"`
	NodeK8sVersions   []string                              `json:"nodeK8sVersions"`
	ServerVersion     string                                `json:"serverVersion,omitempty"`
	Cpu               *ResourceDetailObject                 `json:"cpu"`
	Memory            *ResourceDetailObject                 `json:"memory"`
}

type ClusterCronService added in v0.4.24

type ClusterCronService interface {
}

type ClusterCronServiceImpl added in v0.4.24

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

func NewClusterCronServiceImpl added in v0.4.24

func NewClusterCronServiceImpl(logger *zap.SugaredLogger, clusterService cluster.ClusterService,
	k8sApplicationService K8sApplicationService, clusterRepository clusterRepository.ClusterRepository) (*ClusterCronServiceImpl, error)

func (*ClusterCronServiceImpl) GetAndUpdateClusterConnectionStatus added in v0.4.24

func (impl *ClusterCronServiceImpl) GetAndUpdateClusterConnectionStatus()

func (*ClusterCronServiceImpl) HandleErrorInClusterConnections added in v0.4.24

func (impl *ClusterCronServiceImpl) HandleErrorInClusterConnections(respMap map[int]error)

type K8sApplicationRestHandler

type K8sApplicationRestHandler interface {
	GetResource(w http.ResponseWriter, r *http.Request)
	CreateResource(w http.ResponseWriter, r *http.Request)
	UpdateResource(w http.ResponseWriter, r *http.Request)
	DeleteResource(w http.ResponseWriter, r *http.Request)
	ListEvents(w http.ResponseWriter, r *http.Request)
	GetPodLogs(w http.ResponseWriter, r *http.Request)
	GetTerminalSession(w http.ResponseWriter, r *http.Request)
	GetResourceInfo(w http.ResponseWriter, r *http.Request)
	GetHostUrlsByBatch(w http.ResponseWriter, r *http.Request)
}

type K8sApplicationRestHandlerImpl

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

func NewK8sApplicationRestHandlerImpl

func NewK8sApplicationRestHandlerImpl(logger *zap.SugaredLogger,
	k8sApplicationService K8sApplicationService, pump connector.Pump,
	terminalSessionHandler terminal.TerminalSessionHandler,
	enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtilHelm, clusterService cluster.ClusterService,
	helmAppService client.HelmAppService, userService user.UserService) *K8sApplicationRestHandlerImpl

func (*K8sApplicationRestHandlerImpl) CreateResource

func (handler *K8sApplicationRestHandlerImpl) CreateResource(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) DeleteResource

func (handler *K8sApplicationRestHandlerImpl) DeleteResource(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) GetHostUrlsByBatch added in v0.6.4

func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) GetPodLogs

func (handler *K8sApplicationRestHandlerImpl) GetPodLogs(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) GetResource

func (handler *K8sApplicationRestHandlerImpl) GetResource(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) GetResourceInfo added in v0.4.0

func (handler *K8sApplicationRestHandlerImpl) GetResourceInfo(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) GetTerminalSession

func (handler *K8sApplicationRestHandlerImpl) GetTerminalSession(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) ListEvents

func (handler *K8sApplicationRestHandlerImpl) ListEvents(w http.ResponseWriter, r *http.Request)

func (*K8sApplicationRestHandlerImpl) UpdateResource

func (handler *K8sApplicationRestHandlerImpl) UpdateResource(w http.ResponseWriter, r *http.Request)

type K8sApplicationRouter

type K8sApplicationRouter interface {
	InitK8sApplicationRouter(helmRouter *mux.Router)
}

type K8sApplicationRouterImpl

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

func NewK8sApplicationRouterImpl

func NewK8sApplicationRouterImpl(k8sApplicationRestHandler K8sApplicationRestHandler) *K8sApplicationRouterImpl

func (*K8sApplicationRouterImpl) InitK8sApplicationRouter

func (impl *K8sApplicationRouterImpl) InitK8sApplicationRouter(k8sAppRouter *mux.Router)

type K8sApplicationService

type K8sApplicationService interface {
	GetResource(request *ResourceRequestBean) (resp *application.ManifestResponse, err error)
	CreateResource(request *ResourceRequestBean) (resp *application.ManifestResponse, err error)
	UpdateResource(request *ResourceRequestBean) (resp *application.ManifestResponse, err error)
	DeleteResource(request *ResourceRequestBean) (resp *application.ManifestResponse, err error)
	ListEvents(request *ResourceRequestBean) (*application.EventsResponse, error)
	GetPodLogs(request *ResourceRequestBean) (io.ReadCloser, error)
	ValidateResourceRequest(appIdentifier *client.AppIdentifier, request *application.K8sRequestBean) (bool, error)
	GetResourceInfo() (*ResourceInfo, error)
	GetRestConfigByClusterId(clusterId int) (*rest.Config, error)
	GetRestConfigByCluster(cluster *cluster.ClusterBean) (*rest.Config, error)
	GetManifestsByBatch(ctx context.Context, request []ResourceRequestBean) ([]BatchResourceResponse, error)
	FilterServiceAndIngress(resourceTreeInf map[string]interface{}, validRequests []ResourceRequestBean, appDetail bean.AppDetailContainer, appId string) []ResourceRequestBean
	GetUrlsByBatch(resp []BatchResourceResponse) []interface{}
}

type K8sApplicationServiceConfig added in v0.6.4

type K8sApplicationServiceConfig struct {
	BatchSize        int `env:"BATCH_SIZE" envDefault:"5"`
	TimeOutInSeconds int `env:"TIMEOUT_IN_SECONDS" envDefault:"5"`
}

type K8sApplicationServiceImpl

type K8sApplicationServiceImpl struct {
	K8sUtil *util.K8sUtil

	K8sApplicationServiceConfig *K8sApplicationServiceConfig
	// contains filtered or unexported fields
}

func NewK8sApplicationServiceImpl

func NewK8sApplicationServiceImpl(Logger *zap.SugaredLogger,
	clusterService cluster.ClusterService,
	pump connector.Pump, k8sClientService application.K8sClientService,
	helmAppService client.HelmAppService, K8sUtil *util.K8sUtil, aCDAuthConfig *util3.ACDAuthConfig) *K8sApplicationServiceImpl

func (*K8sApplicationServiceImpl) CreateResource

func (*K8sApplicationServiceImpl) DeleteResource

func (*K8sApplicationServiceImpl) FilterServiceAndIngress added in v0.6.4

func (impl *K8sApplicationServiceImpl) FilterServiceAndIngress(resourceTree map[string]interface{}, validRequests []ResourceRequestBean, appDetail bean.AppDetailContainer, appId string) []ResourceRequestBean

func (*K8sApplicationServiceImpl) GetManifestsByBatch added in v0.6.4

func (impl *K8sApplicationServiceImpl) GetManifestsByBatch(ctx context.Context, requests []ResourceRequestBean) ([]BatchResourceResponse, error)

func (*K8sApplicationServiceImpl) GetPodLogs

func (impl *K8sApplicationServiceImpl) GetPodLogs(request *ResourceRequestBean) (io.ReadCloser, error)

func (*K8sApplicationServiceImpl) GetResource

func (*K8sApplicationServiceImpl) GetResourceInfo added in v0.4.0

func (impl *K8sApplicationServiceImpl) GetResourceInfo() (*ResourceInfo, error)

func (*K8sApplicationServiceImpl) GetRestConfigByCluster added in v0.4.24

func (impl *K8sApplicationServiceImpl) GetRestConfigByCluster(cluster *cluster.ClusterBean) (*rest.Config, error)

func (*K8sApplicationServiceImpl) GetRestConfigByClusterId added in v0.4.24

func (impl *K8sApplicationServiceImpl) GetRestConfigByClusterId(clusterId int) (*rest.Config, error)

func (*K8sApplicationServiceImpl) GetUrlsByBatch added in v0.6.4

func (impl *K8sApplicationServiceImpl) GetUrlsByBatch(resp []BatchResourceResponse) []interface{}

func (*K8sApplicationServiceImpl) ListEvents

func (*K8sApplicationServiceImpl) UpdateResource

func (*K8sApplicationServiceImpl) ValidateResourceRequest

func (impl *K8sApplicationServiceImpl) ValidateResourceRequest(appIdentifier *client.AppIdentifier, request *application.K8sRequestBean) (bool, error)

type K8sCapacityRestHandler added in v0.4.24

type K8sCapacityRestHandler interface {
	GetClusterList(w http.ResponseWriter, r *http.Request)
	GetClusterDetail(w http.ResponseWriter, r *http.Request)
	GetNodeList(w http.ResponseWriter, r *http.Request)
	GetNodeDetail(w http.ResponseWriter, r *http.Request)
	UpdateNodeManifest(w http.ResponseWriter, r *http.Request)
}

type K8sCapacityRestHandlerImpl added in v0.4.24

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

func NewK8sCapacityRestHandlerImpl added in v0.4.24

func NewK8sCapacityRestHandlerImpl(logger *zap.SugaredLogger,
	k8sCapacityService K8sCapacityService, userService user.UserService,
	enforcer casbin.Enforcer,
	clusterService cluster.ClusterService,
	environmentService cluster.EnvironmentService) *K8sCapacityRestHandlerImpl

func (*K8sCapacityRestHandlerImpl) CheckRbacForCluster added in v0.4.24

func (handler *K8sCapacityRestHandlerImpl) CheckRbacForCluster(cluster *cluster.ClusterBean, token string) (authenticated bool, err error)

func (*K8sCapacityRestHandlerImpl) GetClusterDetail added in v0.4.24

func (handler *K8sCapacityRestHandlerImpl) GetClusterDetail(w http.ResponseWriter, r *http.Request)

func (*K8sCapacityRestHandlerImpl) GetClusterList added in v0.4.24

func (handler *K8sCapacityRestHandlerImpl) GetClusterList(w http.ResponseWriter, r *http.Request)

func (*K8sCapacityRestHandlerImpl) GetNodeDetail added in v0.4.24

func (handler *K8sCapacityRestHandlerImpl) GetNodeDetail(w http.ResponseWriter, r *http.Request)

func (*K8sCapacityRestHandlerImpl) GetNodeList added in v0.4.24

func (handler *K8sCapacityRestHandlerImpl) GetNodeList(w http.ResponseWriter, r *http.Request)

func (*K8sCapacityRestHandlerImpl) UpdateNodeManifest added in v0.4.24

func (handler *K8sCapacityRestHandlerImpl) UpdateNodeManifest(w http.ResponseWriter, r *http.Request)

type K8sCapacityRouter added in v0.4.24

type K8sCapacityRouter interface {
	InitK8sCapacityRouter(helmRouter *mux.Router)
}

type K8sCapacityRouterImpl added in v0.4.24

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

func NewK8sCapacityRouterImpl added in v0.4.24

func NewK8sCapacityRouterImpl(k8sCapacityRestHandler K8sCapacityRestHandler) *K8sCapacityRouterImpl

func (*K8sCapacityRouterImpl) InitK8sCapacityRouter added in v0.4.24

func (impl *K8sCapacityRouterImpl) InitK8sCapacityRouter(k8sCapacityRouter *mux.Router)

type K8sCapacityService added in v0.4.24

type K8sCapacityService interface {
	GetClusterCapacityDetailList(clusters []*cluster.ClusterBean) ([]*ClusterCapacityDetail, error)
	GetClusterCapacityDetail(cluster *cluster.ClusterBean, callForList bool) (*ClusterCapacityDetail, error)
	GetNodeCapacityDetailsListByCluster(cluster *cluster.ClusterBean) ([]*NodeCapacityDetail, error)
	GetNodeCapacityDetailByNameAndCluster(cluster *cluster.ClusterBean, name string) (*NodeCapacityDetail, error)
	UpdateNodeManifest(request *NodeManifestUpdateDto) (*application.ManifestResponse, error)
}

type K8sCapacityServiceImpl added in v0.4.24

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

func NewK8sCapacityServiceImpl added in v0.4.24

func NewK8sCapacityServiceImpl(Logger *zap.SugaredLogger,
	clusterService cluster.ClusterService,
	k8sApplicationService K8sApplicationService,
	k8sClientService application.K8sClientService,
	clusterCronService ClusterCronService) *K8sCapacityServiceImpl

func (*K8sCapacityServiceImpl) GetClusterCapacityDetail added in v0.4.24

func (impl *K8sCapacityServiceImpl) GetClusterCapacityDetail(cluster *cluster.ClusterBean, callForList bool) (*ClusterCapacityDetail, error)

func (*K8sCapacityServiceImpl) GetClusterCapacityDetailList added in v0.4.24

func (impl *K8sCapacityServiceImpl) GetClusterCapacityDetailList(clusters []*cluster.ClusterBean) ([]*ClusterCapacityDetail, error)

func (*K8sCapacityServiceImpl) GetNodeCapacityDetailByNameAndCluster added in v0.4.24

func (impl *K8sCapacityServiceImpl) GetNodeCapacityDetailByNameAndCluster(cluster *cluster.ClusterBean, name string) (*NodeCapacityDetail, error)

func (*K8sCapacityServiceImpl) GetNodeCapacityDetailsListByCluster added in v0.4.24

func (impl *K8sCapacityServiceImpl) GetNodeCapacityDetailsListByCluster(cluster *cluster.ClusterBean) ([]*NodeCapacityDetail, error)

func (*K8sCapacityServiceImpl) UpdateNodeManifest added in v0.4.24

func (impl *K8sCapacityServiceImpl) UpdateNodeManifest(request *NodeManifestUpdateDto) (*application.ManifestResponse, error)

type LabelAnnotationTaintObject added in v0.4.24

type LabelAnnotationTaintObject struct {
	Key    string `json:"key"`
	Value  string `json:"value"`
	Effect string `json:"effect,omitempty"`
}

type NodeCapacityDetail added in v0.4.24

type NodeCapacityDetail struct {
	Name          string                              `json:"name"`
	Version       string                              `json:"version,omitempty"`
	Kind          string                              `json:"kind,omitempty"`
	Roles         []string                            `json:"roles"`
	K8sVersion    string                              `json:"k8sVersion"`
	Cpu           *ResourceDetailObject               `json:"cpu,omitempty"`
	Memory        *ResourceDetailObject               `json:"memory,omitempty"`
	Age           string                              `json:"age,omitempty"`
	Status        string                              `json:"status,omitempty"`
	PodCount      int                                 `json:"podCount,omitempty"`
	TaintCount    int                                 `json:"taintCount,omitempty"`
	Errors        map[metav1.NodeConditionType]string `json:"errors"`
	InternalIp    string                              `json:"internalIp"`
	ExternalIp    string                              `json:"externalIp"`
	Unschedulable bool                                `json:"unschedulable"`
	CreatedAt     string                              `json:"createdAt"`
	Labels        []*LabelAnnotationTaintObject       `json:"labels,omitempty"`
	Annotations   []*LabelAnnotationTaintObject       `json:"annotations,omitempty"`
	Taints        []*LabelAnnotationTaintObject       `json:"taints,omitempty"`
	Conditions    []*NodeConditionObject              `json:"conditions,omitempty"`
	Resources     []*ResourceDetailObject             `json:"resources,omitempty"`
	Pods          []*PodCapacityDetail                `json:"pods,omitempty"`
	Manifest      unstructured.Unstructured           `json:"manifest,omitempty"`
	ClusterName   string                              `json:"clusterName,omitempty"`
}

type NodeConditionObject added in v0.4.24

type NodeConditionObject struct {
	Type      string `json:"type"`
	HaveIssue bool   `json:"haveIssue"`
	Reason    string `json:"reason"`
	Message   string `json:"message"`
}

type NodeManifestUpdateDto added in v0.4.24

type NodeManifestUpdateDto struct {
	ClusterId     int    `json:"clusterId"`
	Name          string `json:"name"`
	ManifestPatch string `json:"manifestPatch"`
	Version       string `json:"version"`
	Kind          string `json:"kind"`
}

type PodCapacityDetail added in v0.4.24

type PodCapacityDetail struct {
	Name      string                `json:"name"`
	Namespace string                `json:"namespace"`
	Cpu       *ResourceDetailObject `json:"cpu"`
	Memory    *ResourceDetailObject `json:"memory"`
	Age       string                `json:"age"`
	CreatedAt string                `json:"createdAt"`
}

type ResourceDetailObject added in v0.4.24

type ResourceDetailObject struct {
	ResourceName      string `json:"name,omitempty"`
	Capacity          string `json:"capacity,omitempty"`
	Allocatable       string `json:"allocatable,omitempty"`
	Usage             string `json:"usage,omitempty"`
	Request           string `json:"request,omitempty"`
	Limit             string `json:"limit,omitempty"`
	UsagePercentage   string `json:"usagePercentage,omitempty"`
	RequestPercentage string `json:"requestPercentage,omitempty"`
	LimitPercentage   string `json:"limitPercentage,omitempty"`
	//below fields to be used at FE for sorting
	CapacityInBytes    int64 `json:"capacityInBytes,omitempty"`
	AllocatableInBytes int64 `json:"allocatableInBytes,omitempty"`
	UsageInBytes       int64 `json:"usageInBytes,omitempty"`
	RequestInBytes     int64 `json:"requestInBytes,omitempty"`
	LimitInBytes       int64 `json:"limitInBytes,omitempty"`
}

type ResourceInfo added in v0.4.0

type ResourceInfo struct {
	PodName string `json:"podName"`
}

type ResourceRequestBean

type ResourceRequestBean struct {
	AppId         string                      `json:"appId"`
	AppIdentifier *client.AppIdentifier       `json:"-"`
	K8sRequest    *application.K8sRequestBean `json:"k8sRequest"`
}

type Response added in v0.6.4

type Response struct {
	Kind     string   `json:"kind"`
	Name     string   `json:"name"`
	PointsTo string   `json:"pointsTo"`
	Urls     []string `json:"urls"`
}

Jump to

Keyboard shortcuts

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