k8s

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResourceNotFoundErr = "Unable to locate Kubernetes resource."
)

Functions

func GetClientErrorMessage added in v0.7.2

func GetClientErrorMessage(err error) string

func IsBadRequestErr added in v0.7.2

func IsBadRequestErr(err error) bool

func IsClusterStringContainsFluxField added in v0.7.2

func IsClusterStringContainsFluxField(str string) bool

func IsResourceNotFoundErr added in v0.6.29

func IsResourceNotFoundErr(err error) bool

func IsServerTimeoutErr added in v0.7.2

func IsServerTimeoutErr(err error) bool

func ParseK8sClientErrorToApiError added in v0.7.2

func ParseK8sClientErrorToApiError(err error) *util.ApiError

func StripPrereleaseFromK8sVersion added in v0.7.0

func StripPrereleaseFromK8sVersion(k8sVersion string) string

StripPrereleaseFromK8sVersion takes in k8sVersion and stripe pre-release from semver version and return sanitized k8sVersion or error if invalid version provided, e.g. if k8sVersion = "1.25.16-eks-b9c9ed7", then it returns "1.25.16".

Types

type BatchResourceResponse

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

type CmCsRequestBean added in v0.7.2

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

func NewCmCsRequestBean added in v0.7.2

func NewCmCsRequestBean(clusterId int, namespace string) *CmCsRequestBean

func (*CmCsRequestBean) GetClusterId added in v0.7.2

func (req *CmCsRequestBean) GetClusterId() int

func (*CmCsRequestBean) GetExternalCmList added in v0.7.2

func (req *CmCsRequestBean) GetExternalCmList() []string

func (*CmCsRequestBean) GetExternalCsList added in v0.7.2

func (req *CmCsRequestBean) GetExternalCsList() []string

func (*CmCsRequestBean) GetNamespace added in v0.7.2

func (req *CmCsRequestBean) GetNamespace() string

func (*CmCsRequestBean) SetClusterId added in v0.7.2

func (req *CmCsRequestBean) SetClusterId(clusterId int) *CmCsRequestBean

func (*CmCsRequestBean) SetExternalCmList added in v0.7.2

func (req *CmCsRequestBean) SetExternalCmList(externalCmList ...string) *CmCsRequestBean

func (*CmCsRequestBean) SetExternalCsList added in v0.7.2

func (req *CmCsRequestBean) SetExternalCsList(externalCsList ...string) *CmCsRequestBean

func (*CmCsRequestBean) SetNamespace added in v0.7.2

func (req *CmCsRequestBean) SetNamespace(namespace string) *CmCsRequestBean

type K8sApplicationServiceConfig

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

type K8sCommonService

type K8sCommonService interface {
	GetResource(ctx context.Context, request *ResourceRequestBean) (resp *ResourceGetResponse, err error)
	GetDataFromConfigMaps(ctx context.Context, request *CmCsRequestBean) (map[string]*apiV1.ConfigMap, error)
	GetDataFromSecrets(ctx context.Context, request *CmCsRequestBean) (map[string]*apiV1.Secret, error)
	UpdateResource(ctx context.Context, request *ResourceRequestBean) (resp *k8s.ManifestResponse, err error)
	DeleteResource(ctx context.Context, request *ResourceRequestBean) (resp *k8s.ManifestResponse, err error)
	ListEvents(ctx context.Context, request *ResourceRequestBean) (*k8s.EventsResponse, error)
	GetRestConfigByClusterId(ctx context.Context, clusterId int) (*rest.Config, error, *cluster.ClusterBean)
	GetManifestsByBatch(ctx context.Context, request []ResourceRequestBean) ([]BatchResourceResponse, error)
	FilterK8sResources(ctx context.Context, resourceTreeInf map[string]interface{}, appDetail bean.AppDetailContainer, appId string, kindsToBeFiltered []string, externalArgoAppName string) []ResourceRequestBean
	RotatePods(ctx context.Context, request *RotatePodRequest) (*RotatePodResponse, error)
	GetCoreClientByClusterId(clusterId int) (*kubernetes.Clientset, *clientV1.CoreV1Client, error)
	GetCoreClientByClusterIdForExternalArgoApps(req *cluster.EphemeralContainerRequest) (*kubernetes.Clientset, *clientV1.CoreV1Client, error)
	GetK8sServerVersion(clusterId int) (*version.Info, error)
	PortNumberExtraction(resp []BatchResourceResponse, resourceTree map[string]interface{}) map[string]interface{}
	GetRestConfigOfCluster(ctx context.Context, request *ResourceRequestBean) (*rest.Config, error)
	GetK8sConfigAndClients(ctx context.Context, cluster *cluster.ClusterBean) (*rest.Config, *http.Client, *kubernetes.Clientset, error)
	GetK8sConfigAndClientsByClusterId(ctx context.Context, clusterId int) (*rest.Config, *http.Client, *kubernetes.Clientset, error)
	GetPreferredVersionForAPIGroup(ctx context.Context, clusterId int, groupName string) (string, error)
}

type K8sCommonServiceImpl

type K8sCommonServiceImpl struct {
	K8sUtil *k8s.K8sServiceImpl

	K8sApplicationServiceConfig *K8sApplicationServiceConfig
	// contains filtered or unexported fields
}

func NewK8sCommonServiceImpl

func NewK8sCommonServiceImpl(Logger *zap.SugaredLogger, k8sUtils *k8s.K8sServiceImpl,
	clusterService cluster.ClusterService,
	argoApplicationReadService read.ArgoApplicationReadService) *K8sCommonServiceImpl

func (*K8sCommonServiceImpl) DeleteResource

func (impl *K8sCommonServiceImpl) DeleteResource(ctx context.Context, request *ResourceRequestBean) (*k8s.ManifestResponse, error)

func (*K8sCommonServiceImpl) FilterK8sResources

func (impl *K8sCommonServiceImpl) FilterK8sResources(ctx context.Context, resourceTree map[string]interface{}, appDetail bean.AppDetailContainer, appId string, kindsToBeFiltered []string, externalArgoAppName string) []ResourceRequestBean

func (*K8sCommonServiceImpl) GetCoreClientByClusterId

func (impl *K8sCommonServiceImpl) GetCoreClientByClusterId(clusterId int) (*kubernetes.Clientset, *clientV1.CoreV1Client, error)

func (*K8sCommonServiceImpl) GetCoreClientByClusterIdForExternalArgoApps added in v0.6.29

func (impl *K8sCommonServiceImpl) GetCoreClientByClusterIdForExternalArgoApps(req *cluster.EphemeralContainerRequest) (*kubernetes.Clientset, *clientV1.CoreV1Client, error)

func (*K8sCommonServiceImpl) GetDataFromConfigMaps added in v0.7.2

func (impl *K8sCommonServiceImpl) GetDataFromConfigMaps(ctx context.Context, request *CmCsRequestBean) (map[string]*apiV1.ConfigMap, error)

func (*K8sCommonServiceImpl) GetDataFromSecrets added in v0.7.2

func (impl *K8sCommonServiceImpl) GetDataFromSecrets(ctx context.Context, request *CmCsRequestBean) (map[string]*apiV1.Secret, error)

func (*K8sCommonServiceImpl) GetK8sConfigAndClients added in v0.7.2

func (impl *K8sCommonServiceImpl) GetK8sConfigAndClients(ctx context.Context, cluster *cluster.ClusterBean) (*rest.Config, *http.Client, *kubernetes.Clientset, error)

func (*K8sCommonServiceImpl) GetK8sConfigAndClientsByClusterId added in v0.7.2

func (impl *K8sCommonServiceImpl) GetK8sConfigAndClientsByClusterId(ctx context.Context, clusterId int) (*rest.Config, *http.Client, *kubernetes.Clientset, error)

func (*K8sCommonServiceImpl) GetK8sServerVersion

func (impl *K8sCommonServiceImpl) GetK8sServerVersion(clusterId int) (*version.Info, error)

func (*K8sCommonServiceImpl) GetManifestsByBatch

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

func (*K8sCommonServiceImpl) GetPreferredVersionForAPIGroup added in v0.7.2

func (impl *K8sCommonServiceImpl) GetPreferredVersionForAPIGroup(ctx context.Context, clusterId int, groupName string) (string, error)

func (*K8sCommonServiceImpl) GetResource

func (*K8sCommonServiceImpl) GetRestConfigByClusterId

func (impl *K8sCommonServiceImpl) GetRestConfigByClusterId(ctx context.Context, clusterId int) (*rest.Config, error, *cluster.ClusterBean)

func (*K8sCommonServiceImpl) GetRestConfigOfCluster added in v0.7.2

func (impl *K8sCommonServiceImpl) GetRestConfigOfCluster(ctx context.Context, request *ResourceRequestBean) (*rest.Config, error)

func (*K8sCommonServiceImpl) ListEvents

func (impl *K8sCommonServiceImpl) ListEvents(ctx context.Context, request *ResourceRequestBean) (*k8s.EventsResponse, error)

func (*K8sCommonServiceImpl) PortNumberExtraction added in v0.6.23

func (impl *K8sCommonServiceImpl) PortNumberExtraction(resp []BatchResourceResponse, resourceTree map[string]interface{}) map[string]interface{}

func (*K8sCommonServiceImpl) RotatePods

func (impl *K8sCommonServiceImpl) RotatePods(ctx context.Context, request *RotatePodRequest) (*RotatePodResponse, error)

func (*K8sCommonServiceImpl) UpdateResource

func (impl *K8sCommonServiceImpl) UpdateResource(ctx context.Context, request *ResourceRequestBean) (*k8s.ManifestResponse, error)

type LogsDownloadBean added in v0.6.29

type LogsDownloadBean struct {
	FileName string `json:"fileName"`
	LogsData string `json:"data"`
}

type PodContainerList

type PodContainerList struct {
	Containers          []string
	InitContainers      []string
	EphemeralContainers []string
}

type ResourceGetResponse added in v0.6.28

type ResourceGetResponse struct {
	ManifestResponse *k8s.ManifestResponse `json:"manifestResponse"`
	SecretViewAccess bool                  `json:"secretViewAccess"` // imp: only for resource browser, this is being used to check whether a user can see obscured secret values or not.
}

type ResourceRequestBean

type ResourceRequestBean struct {
	AppId                       string                     `json:"appId"`
	AppType                     int                        `json:"appType,omitempty"`        // 0: DevtronApp, 1: HelmApp, 2:ArgoApp, 3 fluxApp
	DeploymentType              int                        `json:"deploymentType,omitempty"` // 0: DevtronApp, 1: HelmApp
	AppIdentifier               *helmBean.AppIdentifier    `json:"-"`
	K8sRequest                  *k8s.K8sRequestBean        `json:"k8sRequest"`
	DevtronAppIdentifier        *bean.DevtronAppIdentifier `json:"-"`         // For Devtron App Resources
	ClusterId                   int                        `json:"clusterId"` // clusterId is used when request is for direct cluster (not for helm release)
	ExternalArgoApplicationName string                     `json:"externalArgoApplicationName,omitempty"`
	ExternalFluxAppIdentifier   *bean2.FluxAppIdentifier   `json: "-"`
}

func (*ResourceRequestBean) IsValidAppType added in v0.7.2

func (r *ResourceRequestBean) IsValidAppType() bool

func (*ResourceRequestBean) IsValidDeploymentType added in v0.7.2

func (r *ResourceRequestBean) IsValidDeploymentType() bool

type RotatePodRequest

type RotatePodRequest struct {
	ClusterId int                      `json:"clusterId"`
	Resources []k8s.ResourceIdentifier `json:"resources"`
}

type RotatePodResponse

type RotatePodResponse struct {
	Responses     []*bean.RotatePodResourceResponse `json:"responses"`
	ContainsError bool                              `json:"containsError"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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