kube

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

kube

kubernetes client-go封装

Documentation

Index

Constants

View Source
const (
	ResourceNvidiaGPU  = "nvidia.com/gpu"
	ResourceTianshuGPU = "iluvatar.ai/gpu"
)

Variables

This section is empty.

Functions

func BuildClusterConfig

func BuildClusterConfig(kubeconfig string) (*rest.Config, error)

func ResourceEqual added in v0.2.0

func ResourceEqual(a, b any, keys []string) bool

Types

type ClusterRole added in v0.1.1

type ClusterRole struct {
	*LinkInfo
	*v1.ClusterRole
	// contains filtered or unexported fields
}

func NewClusterRole added in v0.1.1

func NewClusterRole(ctx context.Context) *ClusterRole

func (*ClusterRole) AggregationRule added in v0.1.1

func (cr *ClusterRole) AggregationRule(matchLabels map[string]string) *ClusterRole

func (*ClusterRole) Annotations added in v0.1.1

func (cr *ClusterRole) Annotations(annotations map[string]string) *ClusterRole

func (*ClusterRole) Create added in v0.1.1

func (cr *ClusterRole) Create() error

func (*ClusterRole) CreateOrUpdate added in v0.1.1

func (cr *ClusterRole) CreateOrUpdate() error

func (*ClusterRole) Delete added in v0.1.1

func (cr *ClusterRole) Delete() error

func (*ClusterRole) Empty added in v0.1.1

func (cr *ClusterRole) Empty() bool

func (*ClusterRole) Equal added in v0.1.1

func (cr *ClusterRole) Equal(keys []string) bool

func (*ClusterRole) Get added in v0.1.1

func (cr *ClusterRole) Get() (*v1.ClusterRole, error)

func (*ClusterRole) Labels added in v0.1.1

func (cr *ClusterRole) Labels(labels map[string]string) *ClusterRole
func (cr *ClusterRole) Link(region, config string) *ClusterRole

func (*ClusterRole) List added in v0.1.1

func (cr *ClusterRole) List() (*v1.ClusterRoleList, error)

func (*ClusterRole) Metadata added in v0.1.1

func (cr *ClusterRole) Metadata(name string) *ClusterRole

func (*ClusterRole) Rule added in v0.1.1

func (cr *ClusterRole) Rule(verbs []string, apiGroups []string, resoueces []string) *ClusterRole

func (*ClusterRole) Update added in v0.1.1

func (cr *ClusterRole) Update() error

type ClusterRoleBinding added in v0.1.1

type ClusterRoleBinding struct {
	*LinkInfo
	*v1.ClusterRoleBinding
	// contains filtered or unexported fields
}

func NewClusterRoleBinding added in v0.1.1

func NewClusterRoleBinding(ctx context.Context) *ClusterRoleBinding

func (*ClusterRoleBinding) Annotations added in v0.1.1

func (crb *ClusterRoleBinding) Annotations(annotations map[string]string) *ClusterRoleBinding

func (*ClusterRoleBinding) Create added in v0.1.1

func (crb *ClusterRoleBinding) Create() error

func (*ClusterRoleBinding) CreateOrUpdate added in v0.1.1

func (crb *ClusterRoleBinding) CreateOrUpdate() error

func (*ClusterRoleBinding) Delete added in v0.1.1

func (crb *ClusterRoleBinding) Delete() error

func (*ClusterRoleBinding) Empty added in v0.1.1

func (crb *ClusterRoleBinding) Empty() bool

func (*ClusterRoleBinding) Equal added in v0.1.1

func (crb *ClusterRoleBinding) Equal(keys []string) bool

func (*ClusterRoleBinding) Get added in v0.1.1

func (*ClusterRoleBinding) Labels added in v0.1.1

func (crb *ClusterRoleBinding) Labels(labels map[string]string) *ClusterRoleBinding
func (crb *ClusterRoleBinding) Link(region, config string) *ClusterRoleBinding

func (*ClusterRoleBinding) List added in v0.1.1

func (*ClusterRoleBinding) Metadata added in v0.1.1

func (crb *ClusterRoleBinding) Metadata(name, namespace string) *ClusterRoleBinding

func (*ClusterRoleBinding) RoleRef added in v0.1.1

func (crb *ClusterRoleBinding) RoleRef(kind, apigroup, name string) *ClusterRoleBinding

func (*ClusterRoleBinding) Subject added in v0.1.1

func (crb *ClusterRoleBinding) Subject(kind, apigroup, name, namespace string) *ClusterRoleBinding

func (*ClusterRoleBinding) Update added in v0.1.1

func (crb *ClusterRoleBinding) Update() error

type ConfigMap

type ConfigMap struct {
	*LinkInfo
	*v1.ConfigMap
	// contains filtered or unexported fields
}

func NewConfigMap

func NewConfigMap(ctx context.Context) *ConfigMap

func (*ConfigMap) Annotations

func (c *ConfigMap) Annotations(annotations map[string]string) *ConfigMap

func (*ConfigMap) Create

func (c *ConfigMap) Create() error

func (*ConfigMap) CreateOrUpdate

func (c *ConfigMap) CreateOrUpdate() error

func (*ConfigMap) Data

func (c *ConfigMap) Data(data map[string]string) *ConfigMap

func (*ConfigMap) Delete

func (c *ConfigMap) Delete() error

func (*ConfigMap) Empty

func (c *ConfigMap) Empty() bool

func (*ConfigMap) Equal added in v0.2.6

func (c *ConfigMap) Equal(keys []string) bool

func (*ConfigMap) Get

func (c *ConfigMap) Get() (*v1.ConfigMap, error)

func (*ConfigMap) Labels

func (c *ConfigMap) Labels(labels map[string]string) *ConfigMap
func (c *ConfigMap) Link(region, config string) *ConfigMap

func (*ConfigMap) Metadata

func (c *ConfigMap) Metadata(name, namespace string) *ConfigMap

func (*ConfigMap) Update

func (c *ConfigMap) Update() error

type Container

type Container struct {
	*v1.Container
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer(ctx context.Context) *Container

func (*Container) Args

func (c *Container) Args(args []string) *Container

func (*Container) Capabilitie added in v0.3.0

func (c *Container) Capabilitie(add v1.Capability, drop v1.Capability) *Container

func (*Container) Command

func (c *Container) Command(cmds []string) *Container

func (*Container) EnvFromSecret

func (c *Container) EnvFromSecret(secretName string) *Container

func (*Container) Envs

func (c *Container) Envs(envs map[string]string, refs map[string]string) *Container

func (*Container) Image

func (c *Container) Image(image string) *Container

func (*Container) ImagePullPolicy

func (c *Container) ImagePullPolicy(policy v1.PullPolicy) *Container

func (*Container) Metadata

func (c *Container) Metadata(name string) *Container

func (*Container) Port

func (c *Container) Port(name string, port int32, protocal v1.Protocol) *Container

func (*Container) Privileged

func (c *Container) Privileged(privileged bool) *Container

func (*Container) Resource

func (container *Container) Resource(cpu, memory, gpu, ephemeralStorage uint, gpuType string) *Container

func (*Container) VolumeMount

func (c *Container) VolumeMount(name, mountPath string, readOnly bool) *Container

type DaemonSet

type DaemonSet struct {
	*LinkInfo
	*appsv1.DaemonSet
	// contains filtered or unexported fields
}

func NewDaemonSet

func NewDaemonSet(ctx context.Context) *DaemonSet

func (*DaemonSet) Annotations

func (d *DaemonSet) Annotations(annotations map[string]string) *DaemonSet

func (*DaemonSet) Create

func (d *DaemonSet) Create() error

func (*DaemonSet) CreateOrUpdate

func (d *DaemonSet) CreateOrUpdate() error

func (*DaemonSet) Delete

func (d *DaemonSet) Delete() error

func (*DaemonSet) Empty

func (d *DaemonSet) Empty() bool

func (*DaemonSet) Equal added in v0.2.2

func (d *DaemonSet) Equal(keys []string) bool

func (*DaemonSet) Get

func (d *DaemonSet) Get() (*v1.DaemonSet, error)

func (*DaemonSet) Labels

func (d *DaemonSet) Labels(labels map[string]string) *DaemonSet
func (d *DaemonSet) Link(region, config string) *DaemonSet

func (*DaemonSet) Metadata

func (d *DaemonSet) Metadata(name, namespace string) *DaemonSet

func (*DaemonSet) Rollout

func (d *DaemonSet) Rollout() error

implement the rollout method

func (*DaemonSet) Selector

func (d *DaemonSet) Selector(labels map[string]string) *DaemonSet

func (*DaemonSet) Template

func (d *DaemonSet) Template(pt *PodTemplate) *DaemonSet

func (*DaemonSet) Update

func (d *DaemonSet) Update() error

type Deployment

type Deployment struct {
	*LinkInfo
	*appsv1.Deployment
	// contains filtered or unexported fields
}

func NewDeployment

func NewDeployment(ctx context.Context) *Deployment

func (*Deployment) Create

func (d *Deployment) Create() error

func (*Deployment) CreateOrUpdate

func (d *Deployment) CreateOrUpdate() error

func (*Deployment) Delete

func (d *Deployment) Delete() error

func (*Deployment) Empty

func (d *Deployment) Empty() bool

func (*Deployment) Equal added in v0.2.0

func (d *Deployment) Equal(keys []string) bool

func (*Deployment) Get

func (d *Deployment) Get() (*appsv1.Deployment, error)

func (*Deployment) GetReplicas added in v0.2.0

func (d *Deployment) GetReplicas() (int32, error)

func (*Deployment) Labels

func (d *Deployment) Labels(labels map[string]string) *Deployment
func (d *Deployment) Link(region, config string) *Deployment

func (*Deployment) Metadata

func (d *Deployment) Metadata(name, namespace string) *Deployment

func (*Deployment) Replicas

func (d *Deployment) Replicas(replicas int32) *Deployment

func (*Deployment) Rollout

func (d *Deployment) Rollout() error

implement the rollout method

func (*Deployment) Selector

func (d *Deployment) Selector(selector map[string]string) *Deployment

func (*Deployment) Strategy

func (d *Deployment) Strategy(strategy appsv1.DeploymentStrategy) *Deployment

func (*Deployment) Template

func (d *Deployment) Template(pod *PodTemplate) *Deployment

func (*Deployment) Update

func (d *Deployment) Update() error

type Endpoint

type Endpoint struct {
	*LinkInfo
	*v1.Endpoints
	// contains filtered or unexported fields
}

func NewEndpoint

func NewEndpoint(ctx context.Context) *Endpoint

func (*Endpoint) Address

func (e *Endpoint) Address(ip, nodeName, hostName string) *Endpoint

func (*Endpoint) Addresses

func (e *Endpoint) Addresses() ([]v1.EndpointAddress, error)

func (*Endpoint) Create

func (e *Endpoint) Create() error

func (*Endpoint) CreateOrUpdate

func (e *Endpoint) CreateOrUpdate() error

func (*Endpoint) Delete

func (e *Endpoint) Delete() error

func (*Endpoint) Get

func (e *Endpoint) Get() (*v1.Endpoints, error)
func (e *Endpoint) Link(region, config string) *Endpoint

func (*Endpoint) Metadata

func (e *Endpoint) Metadata(name, namespace string) *Endpoint

func (*Endpoint) Port

func (e *Endpoint) Port(name string, port int32, protocol v1.Protocol) *Endpoint

func (*Endpoint) Ports

func (e *Endpoint) Ports() ([]v1.EndpointPort, error)

func (*Endpoint) Subset

func (e *Endpoint) Subset(subsets []string) *Endpoint

func (*Endpoint) Update

func (e *Endpoint) Update() error

type FlatteItem added in v0.2.0

type FlatteItem struct {
	Name string
	Val  any
	Kind string
}

type Interface

type Interface interface {
	Pod() PodInterface
}

type KubeClient

type KubeClient struct {
	*kubernetes.Clientset
}

func NewKubeClient

func NewKubeClient(region, kubeconfig string) *KubeClient

func (*KubeClient) Namespaces

func (cs *KubeClient) Namespaces() typev1.NamespaceInterface

func (*KubeClient) ResourceQuotas

func (cs *KubeClient) ResourceQuotas(namespace string) typev1.ResourceQuotaInterface

type LinkInfo

type LinkInfo struct {
	Region string `json:"region"`
	Config string `json:"config"`
}

type Pod

type Pod struct {
	*LinkInfo
	*v1.Pod
	// contains filtered or unexported fields
}

func NewPod

func NewPod(ctx context.Context) *Pod

func (*Pod) Annotations

func (p *Pod) Annotations(annotations map[string]string) *Pod

func (*Pod) Container

func (p *Pod) Container(container v1.Container) *Pod

func (*Pod) Create

func (p *Pod) Create() error

func (*Pod) CreateOrUpdate

func (p *Pod) CreateOrUpdate() error

func (Pod) Delete

func (p Pod) Delete() error

func (*Pod) Get

func (p *Pod) Get(replace bool) (*Pod, error)

func (*Pod) ImagePullSecrets

func (p *Pod) ImagePullSecrets(secrets []string) *Pod

func (*Pod) Labels

func (p *Pod) Labels(labels map[string]string) *Pod
func (p *Pod) Link(region, config string) *Pod

func (*Pod) Metadata

func (p *Pod) Metadata(name, namespace string) *Pod

func (*Pod) RestartPolicy

func (p *Pod) RestartPolicy(policy v1.RestartPolicy) *Pod

func (*Pod) Toleration

func (p *Pod) Toleration(toleration []v1.Toleration) *Pod

func (*Pod) Update

func (p *Pod) Update() error

func (*Pod) Volume

func (p *Pod) Volume(volumes v1.Volume) *Pod

type PodInterface

type PodInterface interface {
	Create() error
	Delete() error
	Update() error
	Get() (*Pod, error)
	CreateOrUpdate() error
}

type PodTemplate

type PodTemplate struct {
	*v1.PodTemplate
	// contains filtered or unexported fields
}

func NewPodTemplate

func NewPodTemplate(ctx context.Context) *PodTemplate

func (*PodTemplate) Annotations

func (pt *PodTemplate) Annotations(annotations map[string]string) *PodTemplate

func (*PodTemplate) Container

func (pt *PodTemplate) Container(container v1.Container) *PodTemplate

func (*PodTemplate) ImagePullSecrets

func (pt *PodTemplate) ImagePullSecrets(secrets []string) *PodTemplate

func (*PodTemplate) Labels

func (pt *PodTemplate) Labels(labels map[string]string) *PodTemplate

func (*PodTemplate) Metadata

func (pt *PodTemplate) Metadata(name string) *PodTemplate

func (*PodTemplate) RestartPolicy

func (pt *PodTemplate) RestartPolicy(policy v1.RestartPolicy) *PodTemplate

func (*PodTemplate) SecurityContext

func (pt *PodTemplate) SecurityContext(user, group, fsGroup int64) *PodTemplate

func (*PodTemplate) ServiceAccount added in v0.1.9

func (pt *PodTemplate) ServiceAccount(serviceAccount string) *PodTemplate

func (*PodTemplate) Toleration

func (pt *PodTemplate) Toleration(toleration []v1.Toleration) *PodTemplate

func (*PodTemplate) Volume

func (pt *PodTemplate) Volume(volumes v1.Volume) *PodTemplate

type PodsGetter

type PodsGetter interface {
	Pods() PodInterface
}

type Secret

type Secret struct {
	*LinkInfo
	*v1.Secret
	// contains filtered or unexported fields
}

func NewSecret

func NewSecret(ctx context.Context) *Secret

func (*Secret) Annotations

func (s *Secret) Annotations(annotations map[string]string) *Secret

func (*Secret) Create

func (s *Secret) Create() error

func (*Secret) CreateOrUpdate

func (s *Secret) CreateOrUpdate() error

func (*Secret) Data

func (s *Secret) Data(data map[string][]byte) *Secret

func (*Secret) Delete

func (s *Secret) Delete() error

func (*Secret) Empty

func (s *Secret) Empty() bool

func (*Secret) Equal added in v0.2.5

func (s *Secret) Equal(keys []string) bool

func (*Secret) Get

func (s *Secret) Get() (*v1.Secret, error)

func (*Secret) Immutable

func (s *Secret) Immutable(immutable bool) *Secret

func (*Secret) Labels

func (s *Secret) Labels(labels map[string]string) *Secret
func (s *Secret) Link(region, config string) *Secret

func (*Secret) Metadata

func (s *Secret) Metadata(name, namespace string) *Secret

func (*Secret) StringData

func (s *Secret) StringData(data map[string]string) *Secret

func (*Secret) StringDataEqual added in v0.0.2

func (s *Secret) StringDataEqual() bool

func (*Secret) Type

func (s *Secret) Type(t v1.SecretType) *Secret

func (*Secret) Update

func (s *Secret) Update() error

type Service

type Service struct {
	*LinkInfo
	*v1.Service
	// contains filtered or unexported fields
}

func NewService

func NewService(ctx context.Context) *Service

func (*Service) Create

func (s *Service) Create() error

func (*Service) CreateOrUpdate

func (s *Service) CreateOrUpdate() error

func (*Service) Delete

func (s *Service) Delete() error

func (*Service) Empty

func (s *Service) Empty() bool

func (*Service) Equal added in v0.0.8

func (s *Service) Equal(keys []string) bool

func (*Service) Get

func (s *Service) Get() (*v1.Service, error)

func (*Service) Labels

func (s *Service) Labels(labels map[string]string) *Service
func (s *Service) Link(region, config string) *Service

func (*Service) Metadata

func (s *Service) Metadata(name, namespace string) *Service

func (*Service) Port

func (s *Service) Port(name string, port, NodePort int32, protocal v1.Protocol) *Service

func (*Service) Selector

func (s *Service) Selector(selector map[string]string) *Service

func (*Service) Type

func (s *Service) Type(serviceType v1.ServiceType) *Service

func (*Service) Update

func (s *Service) Update() error

type ServiceAccount added in v0.1.1

type ServiceAccount struct {
	*LinkInfo
	*v1.ServiceAccount
	// contains filtered or unexported fields
}

func NewServiceAccount added in v0.1.1

func NewServiceAccount(ctx context.Context) *ServiceAccount

func (*ServiceAccount) Annotations added in v0.1.1

func (sa *ServiceAccount) Annotations(annotations map[string]string) *ServiceAccount

func (*ServiceAccount) AutomountServiceAccountToken added in v0.1.1

func (sa *ServiceAccount) AutomountServiceAccountToken(automount bool) *ServiceAccount

func (*ServiceAccount) Create added in v0.1.1

func (sa *ServiceAccount) Create() error

func (*ServiceAccount) CreateOrUpdate added in v0.1.1

func (sa *ServiceAccount) CreateOrUpdate() error

func (*ServiceAccount) Delete added in v0.1.1

func (sa *ServiceAccount) Delete() error

func (*ServiceAccount) Empty added in v0.1.1

func (sa *ServiceAccount) Empty() bool

func (*ServiceAccount) Equal added in v0.1.1

func (sa *ServiceAccount) Equal(keys []string) bool

func (*ServiceAccount) Get added in v0.1.1

func (sa *ServiceAccount) Get() (*v1.ServiceAccount, error)

func (*ServiceAccount) Labels added in v0.1.1

func (sa *ServiceAccount) Labels(labels map[string]string) *ServiceAccount
func (sa *ServiceAccount) Link(region, config string) *ServiceAccount

func (*ServiceAccount) List added in v0.1.1

func (sa *ServiceAccount) List() (*v1.ServiceAccountList, error)

func (*ServiceAccount) Metadata added in v0.1.1

func (sa *ServiceAccount) Metadata(name, namespace string) *ServiceAccount

func (*ServiceAccount) Secret added in v0.1.1

func (sa *ServiceAccount) Secret(kind, secretName, namespace string) *ServiceAccount

func (*ServiceAccount) Update added in v0.1.1

func (sa *ServiceAccount) Update() error

type Volume

type Volume struct {
	*v1.Volume
	// contains filtered or unexported fields
}

func NewVolume

func NewVolume(ctx context.Context) *Volume

func (*Volume) ConfigMap

func (v *Volume) ConfigMap(configMapName string, items []v1.KeyToPath, mode int32) *Volume

func (*Volume) EmptyDir

func (v *Volume) EmptyDir(medium string) *Volume

func (*Volume) HostPath

func (v *Volume) HostPath(path string, t v1.HostPathType) *Volume

func (*Volume) Metadata

func (v *Volume) Metadata(name string) *Volume

func (*Volume) Secret

func (v *Volume) Secret(secretName string, items []v1.KeyToPath, mode int32) *Volume

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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