kubernetes

package
v0.0.0-...-d4a7eef Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCpuQuotaExceeded                     = errors.New("cpu quota exceeded")
	ErrMemoryQuotaExceeded                  = errors.New("memory quota exceeded")
	ErrEphemeralStorageStorageQuotaExceeded = errors.New("ephemeral-storage quota exceeded")
)
View Source
var (
	InClusterAuth    = "inCluster"
	OutOfClusterAuth = "outOfCluster"
	LeaseRun         = leaderelection.RunOrDie
)

Functions

func IsBoundServiceAccount

func IsBoundServiceAccount(subject rbacv1.Subject, username, namespace string) bool

func NewGlobalHelper

func NewGlobalHelper(opts ...Option) error

Types

type Auth

type Auth struct {
	Type     string
	Token    string
	FilePath string
	CAFile   string
	RestConf *rest.Config
}

type ClusterRoleBindingClient

type ClusterRoleBindingClient interface {
	List(context.Context, metav1.ListOptions) (*rbacv1.ClusterRoleBindingList, error)
	Create(ctx context.Context, clusterRoleBinding *rbacv1.ClusterRoleBinding, opts metav1.CreateOptions) (*rbacv1.ClusterRoleBinding, error)
}

type ConfigMapClient

type ConfigMapClient interface {
	Create(ctx context.Context, configMap *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error)
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

type DeploymentClient

type DeploymentClient interface {
	Get(ctx context.Context, name string, opts metav1.GetOptions) (*appsv1.Deployment, error)
}

type EventClient

type EventClient interface {
	List(ctx context.Context, opts metav1.ListOptions) (*corev1.EventList, error)
}

type Fetch

type Fetch struct {
	Interval int
	Retry    int
}

type Helper

func GetGlobalHelper

func GetGlobalHelper() *Helper

func NewHelper

func NewHelper(opts ...Option) (*Helper, error)

func (*Helper) ApplyDynamicResource

func (h *Helper) ApplyDynamicResource(reader io.Reader) error

func (*Helper) CreateClusterRole

func (h *Helper) CreateClusterRole(name string, rbacRules []rbacv1.PolicyRule) (*rbacv1.ClusterRole, error)

func (*Helper) CreateClusterRoleBinding

func (h *Helper) CreateClusterRoleBinding(metaData metav1.ObjectMeta, roleRef rbacv1.RoleRef, subjects []rbacv1.Subject) (*rbacv1.ClusterRoleBinding, error)

func (*Helper) CreateConfigMap

func (h *Helper) CreateConfigMap(configMap *corev1.ConfigMap) (*corev1.ConfigMap, error)

func (*Helper) CreateJob

func (h *Helper) CreateJob(job *batchv1.Job) (*batchv1.Job, error)

func (*Helper) CreateNamespace

func (h *Helper) CreateNamespace(metadata metav1.ObjectMeta) error

func (*Helper) CreateResourceQuota

func (h *Helper) CreateResourceQuota(name string, resourceQuota *corev1.ResourceQuota) (*corev1.ResourceQuota, error)

func (*Helper) CreateRoleBinding

func (h *Helper) CreateRoleBinding(metadata metav1.ObjectMeta, roleRef *rbacv1.RoleRef, subjects []rbacv1.Subject) (*rbacv1.RoleBinding, error)

func (*Helper) CreateSecret

func (h *Helper) CreateSecret(secret *corev1.Secret) (*corev1.Secret, error)

func (*Helper) CreateServiceAccount

func (h *Helper) CreateServiceAccount(metadata metav1.ObjectMeta) (*corev1.ServiceAccount, error)

func (*Helper) CreateStorageClass

func (h *Helper) CreateStorageClass(storageClass *storagev1.StorageClass) (*storagev1.StorageClass, error)

func (*Helper) CreateTokenSecret

func (h *Helper) CreateTokenSecret(secretName, serviceAccountName string) (*corev1.Secret, error)

func (*Helper) DeleteConfigMap

func (h *Helper) DeleteConfigMap(name string) error

func (*Helper) DeleteJob

func (h *Helper) DeleteJob(name string) error

func (*Helper) DeleteNamespace

func (h *Helper) DeleteNamespace(namespace string) error

func (*Helper) DeleteRoleBindings

func (h *Helper) DeleteRoleBindings(username string, namespaces []string) error

func (*Helper) DeleteRoleBindingsIfTheServiceAccountIsIncluded

func (h *Helper) DeleteRoleBindingsIfTheServiceAccountIsIncluded(username, namespace string) error

func (*Helper) DeleteSecret

func (h *Helper) DeleteSecret(secretName string) error

func (*Helper) DeleteServiceAccount

func (h *Helper) DeleteServiceAccount(name string) error

func (*Helper) DisableCurrentDefaultStorageClasses

func (h *Helper) DisableCurrentDefaultStorageClasses() error

func (*Helper) GenTokenSecretOpts

func (h *Helper) GenTokenSecretOpts(secretName, serviceAccountName string) *corev1.Secret

func (*Helper) GetClusterRole

func (h *Helper) GetClusterRole(name string) (*rbacv1.ClusterRole, error)

func (*Helper) GetDeployment

func (h *Helper) GetDeployment(name string) (*appsv1.Deployment, error)

func (*Helper) GetJob

func (h *Helper) GetJob(name string) (*batchv1.Job, error)

func (*Helper) GetNamespace

func (h *Helper) GetNamespace(namespace string) (*corev1.Namespace, error)

func (*Helper) GetNode

func (h *Helper) GetNode(name string) (*corev1.Node, error)

func (*Helper) GetNodeIP

func (h *Helper) GetNodeIP(nodeName string, addrType string) (string, error)

func (*Helper) GetRole

func (h *Helper) GetRole(name string) (*rbacv1.Role, error)

func (*Helper) GetSecret

func (h *Helper) GetSecret(secretName string) (*corev1.Secret, error)

func (*Helper) GetServiceAccount

func (h *Helper) GetServiceAccount(name string) (*corev1.ServiceAccount, error)

func (*Helper) GetStorageClass

func (h *Helper) GetStorageClass(name string) (*storagev1.StorageClass, error)

func (*Helper) GetSvc

func (h *Helper) GetSvc(name string) (*corev1.Service, error)

func (*Helper) GetSvcNodePortByTargetPort

func (h *Helper) GetSvcNodePortByTargetPort(svcName string, targetPort int) (int, error)

func (*Helper) GetTokenSecret

func (h *Helper) GetTokenSecret(secretName string) (*corev1.Secret, error)

func (*Helper) IsNamespaceExist

func (h *Helper) IsNamespaceExist(namespace string) bool

func (*Helper) ListClusterRoleBinding

func (h *Helper) ListClusterRoleBinding(opt metav1.ListOptions) (*rbacv1.ClusterRoleBindingList, error)

func (*Helper) ListCustomResourceDefinition

func (h *Helper) ListCustomResourceDefinition() (*apiextensionsv1.CustomResourceDefinitionList, error)

func (*Helper) ListEvent

func (h *Helper) ListEvent(opt metav1.ListOptions) (*corev1.EventList, error)

func (*Helper) ListJobs

func (h *Helper) ListJobs(opt metav1.ListOptions) (*batchv1.JobList, error)

func (*Helper) ListNamespace

func (h *Helper) ListNamespace(opt metav1.ListOptions) (*corev1.NamespaceList, error)

func (*Helper) ListNodes

func (h *Helper) ListNodes() (*corev1.NodeList, error)

func (*Helper) ListPod

func (h *Helper) ListPod(opt metav1.ListOptions) (*corev1.PodList, error)

func (*Helper) ListResourceQuota

func (h *Helper) ListResourceQuota(opts metav1.ListOptions) (*corev1.ResourceQuotaList, error)

func (*Helper) ListRoleBindings

func (h *Helper) ListRoleBindings(opt metav1.ListOptions) (*rbacv1.RoleBindingList, error)

func (*Helper) ListServiceAccount

func (h *Helper) ListServiceAccount(opt metav1.ListOptions) (*corev1.ServiceAccountList, error)

func (*Helper) ListStorageClasses

func (h *Helper) ListStorageClasses() (*storagev1.StorageClassList, error)

func (*Helper) PatchClusterRole

func (h *Helper) PatchClusterRole(name string, dataToPatch []byte) error

func (*Helper) PatchNamespace

func (h *Helper) PatchNamespace(namespace string, patchData []byte) error

func (*Helper) PatchStorageClasses

func (h *Helper) PatchStorageClasses(storageClasses []storagev1.StorageClass, patchData []byte) error

func (*Helper) RunLeaseCron

func (h *Helper) RunLeaseCron(ctx *context.Context)

func (*Helper) SetAuth

func (h *Helper) SetAuth() error

func (*Helper) SetClusterRoleBindingClient

func (h *Helper) SetClusterRoleBindingClient()

func (*Helper) SetClusterRoleClient

func (h *Helper) SetClusterRoleClient()

func (*Helper) SetConfigMapClient

func (h *Helper) SetConfigMapClient(namespace string)

func (*Helper) SetCustomResourceDefinitionClient

func (h *Helper) SetCustomResourceDefinitionClient()

func (*Helper) SetDefaultStorageClass

func (h *Helper) SetDefaultStorageClass(name string) error

func (*Helper) SetDeploymentClient

func (h *Helper) SetDeploymentClient()

func (*Helper) SetEventClient

func (h *Helper) SetEventClient()

func (*Helper) SetJobClient

func (h *Helper) SetJobClient(namespace string)

func (*Helper) SetLeaseClient

func (h *Helper) SetLeaseClient(id string, name string, namespace string)

func (*Helper) SetLeaseCron

func (h *Helper) SetLeaseCron(schedule func())

func (*Helper) SetNamespaceClient

func (h *Helper) SetNamespaceClient()

func (*Helper) SetNodeClient

func (h *Helper) SetNodeClient()

func (*Helper) SetPodClient

func (h *Helper) SetPodClient(namespace string)

func (*Helper) SetResourceQuotaClient

func (h *Helper) SetResourceQuotaClient(namespace string)

func (*Helper) SetRoleBindingClient

func (h *Helper) SetRoleBindingClient(namespace string)

func (*Helper) SetRoleClient

func (h *Helper) SetRoleClient(namespace string)

func (*Helper) SetSVCClient

func (h *Helper) SetSVCClient()

func (*Helper) SetSecretClient

func (h *Helper) SetSecretClient(namespace string)

func (*Helper) SetServiceAccountClient

func (h *Helper) SetServiceAccountClient(namespace string)

func (*Helper) SetStorageClassClient

func (h *Helper) SetStorageClassClient()

func (*Helper) UpdateNode

func (h *Helper) UpdateNode(node *corev1.Node) (*corev1.Node, error)

func (*Helper) UpdateResourceQuota

func (h *Helper) UpdateResourceQuota(name string, patchData []byte) error

type JobClient

type JobClient interface {
	Create(ctx context.Context, job *batchv1.Job, opts metav1.CreateOptions) (*batchv1.Job, error)
	Get(ctx context.Context, name string, opts metav1.GetOptions) (*batchv1.Job, error)
	List(ctx context.Context, opts metav1.ListOptions) (*batchv1.JobList, error)
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

type NamespaceClient

type NamespaceClient interface {
	Get(context.Context, string, metav1.GetOptions) (*corev1.Namespace, error)
	Create(context.Context, *corev1.Namespace, metav1.CreateOptions) (*corev1.Namespace, error)
	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *corev1.Namespace, err error)
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
	List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error)
}

type Option

type Option func(*Options)

func AuthFile

func AuthFile(file string) Option

func AuthType

func AuthType(authType string) Option

func Namespace

func Namespace(name string) Option

type Options

type Options struct {
	Namespace string
	URL       string
	Auth

	metav1.ListOptions

	Fetch
}
var (
	Opts *Options
)

type PodClient

type PodClient interface {
	List(ctx context.Context, opts metav1.ListOptions) (*corev1.PodList, error)
	GetLogs(name string, opts *corev1.PodLogOptions) *rest.Request
}

type ResourceQuotaClient

type ResourceQuotaClient interface {
	List(ctx context.Context, opts metav1.ListOptions) (*corev1.ResourceQuotaList, error)
	Create(ctx context.Context, resourceQuota *corev1.ResourceQuota, opts metav1.CreateOptions) (*corev1.ResourceQuota, error)
	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *corev1.ResourceQuota, err error)
}

type SvcClient

type SvcClient interface {
	Get(context.Context, string, metav1.GetOptions) (*corev1.Service, error)
}

Jump to

Keyboard shortcuts

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