Documentation ¶
Overview ¶
Package k8s implements managing the servicegroup by k8s cluster
Index ¶
- Constants
- func ConvertEventStatus(reason string) string
- func ConvertToHostAlias(hosts []string) []apiv1.HostAlias
- func DefaultHealthCheck(service *apistructs.Service) *apiv1.Probe
- func FillHealthCheckProbe(service *apistructs.Service) *apiv1.Probe
- func GenTolerations() []apiv1.Toleration
- func GenerateEvent(sg *apistructs.ServiceGroup) events.RuntimeEvent
- func IsGroupStateful(sg *apistructs.ServiceGroup) bool
- func MakeNamespace(sg *apistructs.ServiceGroup) string
- func NewCheckProbe() *apiv1.Probe
- func NewHealthCheck(hc *apistructs.NewHealthCheck) *apiv1.Probe
- func OldHealthCheck(hc *apistructs.HealthCheck) *apiv1.Probe
- func ParseJobHostBindTemplate(hostPath string, clusterInfo map[string]string) (string, error)
- func SetHealthCheck(container *apiv1.Container, service *apistructs.Service)
- func ValidateRuntime(specObj interface{}, action string) (*apistructs.ServiceGroup, error)
- type Event
- type Kubernetes
- func (k *Kubernetes) AddContainersEnv(containers []apiv1.Container, service *apistructs.Service, ...) error
- func (k *Kubernetes) AddPodMountVolume(service *apistructs.Service, podSpec *apiv1.PodSpec, ...) error
- func (k *Kubernetes) AddSpotEmptyDir(podSpec *apiv1.PodSpec)
- func (k *Kubernetes) Addr() string
- func (k *Kubernetes) CPUOvercommit(limit float64) float64
- func (k *Kubernetes) Cancel(ctx context.Context, specObj interface{}) (interface{}, error)
- func (k *Kubernetes) CapacityInfo() apistructs.CapacityInfoData
- func (k *Kubernetes) CleanUpBeforeDelete()
- func (k *Kubernetes) CopyErdaSecrets(originns, dstns string) ([]apiv1.Secret, error)
- func (k *Kubernetes) Create(ctx context.Context, specObj interface{}) (interface{}, error)
- func (k *Kubernetes) CreateNamespace(ns string, sg *apistructs.ServiceGroup) error
- func (k *Kubernetes) CreateService(service *apistructs.Service) error
- func (k *Kubernetes) CreateStatefulGroup(sg *apistructs.ServiceGroup, layers [][]*apistructs.Service) error
- func (k *Kubernetes) DeleteNamespace(ns string) error
- func (k *Kubernetes) DeletePV(sg *apistructs.ServiceGroup) error
- func (k *Kubernetes) DeleteService(namespace, name string) error
- func (k *Kubernetes) Destroy(ctx context.Context, specObj interface{}) error
- func (k *Kubernetes) GetK8SAddr() string
- func (k *Kubernetes) GetService(namespace, name string) (*apiv1.Service, error)
- func (k *Kubernetes) GetStatefulStatus(sg *apistructs.ServiceGroup) (apistructs.StatusDesc, error)
- func (m *Kubernetes) IPToHostname(ip string) string
- func (k *Kubernetes) Inspect(ctx context.Context, specObj interface{}) (interface{}, error)
- func (k *Kubernetes) InspectStateful(sg *apistructs.ServiceGroup) (*apistructs.ServiceGroup, error)
- func (k *Kubernetes) InstanceEvent(event Event, runtimeName string, notifier eventboxapi.Notifier)
- func (*Kubernetes) JobVolumeCreate(ctx context.Context, spec interface{}) (string, error)
- func (k *Kubernetes) KillPod(podname string) error
- func (k *Kubernetes) Kind() executortypes.Kind
- func (k *Kubernetes) MemoryOvercommit(limit int) int
- func (k *Kubernetes) Name() executortypes.Name
- func (k *Kubernetes) NewHealthcheckProbe(service *apistructs.Service) *apiv1.Probe
- func (k *Kubernetes) NewImageSecret(namespace string) error
- func (k *Kubernetes) NewRuntimeImageSecret(namespace string, sg *apistructs.ServiceGroup) error
- func (k *Kubernetes) NotfoundNamespace(ns string) (bool, error)
- func (k *Kubernetes) Precheck(ctx context.Context, specObj interface{}) (apistructs.ServiceGroupPrecheckData, error)
- func (k *Kubernetes) PutService(svc *apiv1.Service) error
- func (k *Kubernetes) Remove(ctx context.Context, specObj interface{}) error
- func (k *Kubernetes) ResourceInfo(brief bool) (apistructs.ClusterResourceInfoData, error)
- func (k *Kubernetes) SecretVolume(secret *apiv1.Secret) (apiv1.Volume, apiv1.VolumeMount)
- func (k *Kubernetes) SetFineGrainedCPU(container *apiv1.Container, extra map[string]string, cpuSubscribeRatio float64) error
- func (m *Kubernetes) SetNodeLabels(_ executortypes.NodeLabelSetting, hosts []string, labels map[string]string) error
- func (k *Kubernetes) SetOverCommitMem(container *apiv1.Container, memSubscribeRatio float64) error
- func (k *Kubernetes) Status(ctx context.Context, specObj interface{}) (apistructs.StatusDesc, error)
- func (k *Kubernetes) Terminal(namespace, podname, containername string, upperConn *websocket.Conn)
- func (k *Kubernetes) Update(ctx context.Context, specObj interface{}) (interface{}, error)
- func (k *Kubernetes) UpdateNamespace(ns string, sg *apistructs.ServiceGroup) error
- type OneGroupInfo
- type StatefulsetInfo
- type Winsize
Constants ¶
const ( // DefaultServiceDNSSuffix k8s service dns fixed suffix DefaultServiceDNSSuffix = "svc.cluster.local" EnableServiceLinks = "ENABLE_SERVICE_LINKS" )
const ( // SUBSCRIBE_RATIO_SUFFIX the key suffix of the super ratio SUBSCRIBE_RATIO_SUFFIX = "_SUBSCRIBE_RATIO" // CPU_NUM_QUOTA cpu limit key CPU_NUM_QUOTA = "CPU_NUM_QUOTA" // CPU_CFS_PERIOD_US 100000 /sys/fs/cgroup/cpu/cpu.cfs_period_us default value CPU_CFS_PERIOD_US int = 100000 // MIN_CPU_SIZE Minimum application cpu value MIN_CPU_SIZE = 0.1 // ProjectNamespace Env LabelServiceGroupID = "servicegroup-id" KeyServiceGroupID = "SERVICE_GROUP_ID" KeyOriginServiceName = "ORIGIN_SERVICE_NAME" ProjectNamespaceServiceNameNameKey = "PROJECT_NAMESPACE_SERVICE_NAME" ProjectNamespace = "PROJECT_NAMESPACE" )
const ( Error = '1' Ping = '2' Pong = '3' Input = '4' Output = '5' GetSize = '6' Size = '7' SetSize = '8' )
const ( // aliyun registry AliyunRegistry = "aliyun-registry" CustomRegistry = "custom-registry" )
const ( ServiceType = "SERVICE_TYPE" StatelessService = "STATELESS_SERVICE" IsStatelessService = "true" ServiceAddon = "ADDONS" ServicePerNode = "per_node" )
Variables ¶
This section is empty.
Functions ¶
func ConvertEventStatus ¶
ConvertEventStatus convert k8s status
func ConvertToHostAlias ¶
func DefaultHealthCheck ¶
func DefaultHealthCheck(service *apistructs.Service) *apiv1.Probe
DefaultHealthCheck The user has not configured any health check, and the first port is checked by layer 4 tcp by default
func FillHealthCheckProbe ¶
func FillHealthCheckProbe(service *apistructs.Service) *apiv1.Probe
FillHealthCheckProbe Fill out k8s probe based on service
func GenTolerations ¶
func GenTolerations() []apiv1.Toleration
func GenerateEvent ¶
func GenerateEvent(sg *apistructs.ServiceGroup) events.RuntimeEvent
func IsGroupStateful ¶
func IsGroupStateful(sg *apistructs.ServiceGroup) bool
IsGroupStateful Determine whether it is a stateful service the caller have to make sure sg is not nil Generally speaking, those with "SERVICE_TYPE" set to "ADDONS" are stateful applications, However, some of the ADDONS types still want to be deployed in a stateless manner, adding STATELESS_SERVICE To distinguish whether the ADDONS type is stateful or stateless, the default is to execute according to state
func MakeNamespace ¶
func MakeNamespace(sg *apistructs.ServiceGroup) string
MakeNamespace Generate a Namespace name Each runtime corresponds to a k8s namespace on k8s, format is ${runtimeNamespace}--${runtimeName}
func NewCheckProbe ¶
NewCheckProbe Create k8s probe default object
func NewHealthCheck ¶
func NewHealthCheck(hc *apistructs.NewHealthCheck) *apiv1.Probe
NewHealthCheck Configure the new version of Dice health check
func OldHealthCheck ¶
func OldHealthCheck(hc *apistructs.HealthCheck) *apiv1.Probe
OldHealthCheck Compatible with Dice old version health detection
func ParseJobHostBindTemplate ¶
ParseJobHostBindTemplate Analyze the hostPath template and convert it to the cluster info value
func SetHealthCheck ¶
func SetHealthCheck(container *apiv1.Container, service *apistructs.Service)
func ValidateRuntime ¶
func ValidateRuntime(specObj interface{}, action string) (*apistructs.ServiceGroup, error)
ValidateRuntime check runtime validity
Types ¶
type Kubernetes ¶
type Kubernetes struct { ClusterInfo *clusterinfo.ClusterInfo // contains filtered or unexported fields }
Kubernetes is the Executor struct for k8s cluster
func New ¶
func New(name executortypes.Name, clusterName string, options map[string]string) (*Kubernetes, error)
New new kubernetes executor struct
func (*Kubernetes) AddContainersEnv ¶
func (k *Kubernetes) AddContainersEnv(containers []apiv1.Container, service *apistructs.Service, sg *apistructs.ServiceGroup) error
AddContainersEnv Add container environment variables
func (*Kubernetes) AddPodMountVolume ¶
func (k *Kubernetes) AddPodMountVolume(service *apistructs.Service, podSpec *apiv1.PodSpec, secretvolmounts []apiv1.VolumeMount, secretvolumes []apiv1.Volume) error
AddPodMountVolume Add pod volume configuration
func (*Kubernetes) AddSpotEmptyDir ¶
func (k *Kubernetes) AddSpotEmptyDir(podSpec *apiv1.PodSpec)
func (*Kubernetes) CPUOvercommit ¶
func (k *Kubernetes) CPUOvercommit(limit float64) float64
func (*Kubernetes) Cancel ¶
func (k *Kubernetes) Cancel(ctx context.Context, specObj interface{}) (interface{}, error)
Cancel implements canceling manipulating servicegroup
func (*Kubernetes) CapacityInfo ¶
func (k *Kubernetes) CapacityInfo() apistructs.CapacityInfoData
func (*Kubernetes) CleanUpBeforeDelete ¶
func (k *Kubernetes) CleanUpBeforeDelete()
func (*Kubernetes) CopyErdaSecrets ¶
func (k *Kubernetes) CopyErdaSecrets(originns, dstns string) ([]apiv1.Secret, error)
CopyErdaSecrets Copy the secret under orignns namespace to dstns
func (*Kubernetes) Create ¶
func (k *Kubernetes) Create(ctx context.Context, specObj interface{}) (interface{}, error)
Create implements creating servicegroup based on k8s api
func (*Kubernetes) CreateNamespace ¶
func (k *Kubernetes) CreateNamespace(ns string, sg *apistructs.ServiceGroup) error
CreateNamespace create namespace
func (*Kubernetes) CreateService ¶
func (k *Kubernetes) CreateService(service *apistructs.Service) error
CreateService create k8s service
func (*Kubernetes) CreateStatefulGroup ¶
func (k *Kubernetes) CreateStatefulGroup(sg *apistructs.ServiceGroup, layers [][]*apistructs.Service) error
CreateStatefulGroup create statefull group
func (*Kubernetes) DeleteNamespace ¶
func (k *Kubernetes) DeleteNamespace(ns string) error
DeleteNamespace delete namepsace
func (*Kubernetes) DeletePV ¶
func (k *Kubernetes) DeletePV(sg *apistructs.ServiceGroup) error
func (*Kubernetes) DeleteService ¶
func (k *Kubernetes) DeleteService(namespace, name string) error
DeleteService delete k8s service
func (*Kubernetes) Destroy ¶
func (k *Kubernetes) Destroy(ctx context.Context, specObj interface{}) error
Destroy implements deleting servicegroup based on k8s api
func (*Kubernetes) GetK8SAddr ¶
func (k *Kubernetes) GetK8SAddr() string
func (*Kubernetes) GetService ¶
func (k *Kubernetes) GetService(namespace, name string) (*apiv1.Service, error)
GetService get k8s service
func (*Kubernetes) GetStatefulStatus ¶
func (k *Kubernetes) GetStatefulStatus(sg *apistructs.ServiceGroup) (apistructs.StatusDesc, error)
TODO: State need more precise
func (*Kubernetes) IPToHostname ¶
func (m *Kubernetes) IPToHostname(ip string) string
func (*Kubernetes) Inspect ¶
func (k *Kubernetes) Inspect(ctx context.Context, specObj interface{}) (interface{}, error)
Inspect implements getting servicegroup info
func (*Kubernetes) InspectStateful ¶
func (k *Kubernetes) InspectStateful(sg *apistructs.ServiceGroup) (*apistructs.ServiceGroup, error)
func (*Kubernetes) InstanceEvent ¶
func (k *Kubernetes) InstanceEvent(event Event, runtimeName string, notifier eventboxapi.Notifier)
func (*Kubernetes) JobVolumeCreate ¶
func (*Kubernetes) JobVolumeCreate(ctx context.Context, spec interface{}) (string, error)
func (*Kubernetes) KillPod ¶
func (k *Kubernetes) KillPod(podname string) error
func (*Kubernetes) Kind ¶
func (k *Kubernetes) Kind() executortypes.Kind
Kind implements executortypes.Executor interface
func (*Kubernetes) MemoryOvercommit ¶
func (k *Kubernetes) MemoryOvercommit(limit int) int
func (*Kubernetes) Name ¶
func (k *Kubernetes) Name() executortypes.Name
Name implements executortypes.Executor interface
func (*Kubernetes) NewHealthcheckProbe ¶
func (k *Kubernetes) NewHealthcheckProbe(service *apistructs.Service) *apiv1.Probe
func (*Kubernetes) NewImageSecret ¶
func (k *Kubernetes) NewImageSecret(namespace string) error
NewImageSecret create new image pull secret 1, create imagePullSecret of this namespace 2, put this secret into serviceaccount of the namespace
func (*Kubernetes) NewRuntimeImageSecret ¶
func (k *Kubernetes) NewRuntimeImageSecret(namespace string, sg *apistructs.ServiceGroup) error
NewImageSecret create mew image pull secret 1, create imagePullSecret of this namespace 2, Add the secret of the image that needs to be authenticated to the secret of the namespace 3, put this secret into serviceaccount of the namespace
func (*Kubernetes) NotfoundNamespace ¶
func (k *Kubernetes) NotfoundNamespace(ns string) (bool, error)
NotfoundNamespace not found namespace
func (*Kubernetes) Precheck ¶
func (k *Kubernetes) Precheck(ctx context.Context, specObj interface{}) (apistructs.ServiceGroupPrecheckData, error)
func (*Kubernetes) PutService ¶
func (k *Kubernetes) PutService(svc *apiv1.Service) error
PutService update k8s service
func (*Kubernetes) Remove ¶
func (k *Kubernetes) Remove(ctx context.Context, specObj interface{}) error
Remove implements removing servicegroup based on k8s api
func (*Kubernetes) ResourceInfo ¶
func (k *Kubernetes) ResourceInfo(brief bool) (apistructs.ClusterResourceInfoData, error)
func (*Kubernetes) SecretVolume ¶
func (k *Kubernetes) SecretVolume(secret *apiv1.Secret) (apiv1.Volume, apiv1.VolumeMount)
SecretVolume
func (*Kubernetes) SetFineGrainedCPU ¶
func (k *Kubernetes) SetFineGrainedCPU(container *apiv1.Container, extra map[string]string, cpuSubscribeRatio float64) error
SetFineGrainedCPU Set proper cpu ratio & quota
func (*Kubernetes) SetNodeLabels ¶
func (m *Kubernetes) SetNodeLabels(_ executortypes.NodeLabelSetting, hosts []string, labels map[string]string) error
SetNodeLabels set the labels of k8s node
func (*Kubernetes) SetOverCommitMem ¶
func (k *Kubernetes) SetOverCommitMem(container *apiv1.Container, memSubscribeRatio float64) error
func (*Kubernetes) Status ¶
func (k *Kubernetes) Status(ctx context.Context, specObj interface{}) (apistructs.StatusDesc, error)
Status implements getting servicegroup status based on k8s api
func (*Kubernetes) Terminal ¶
func (k *Kubernetes) Terminal(namespace, podname, containername string, upperConn *websocket.Conn)
func (*Kubernetes) Update ¶
func (k *Kubernetes) Update(ctx context.Context, specObj interface{}) (interface{}, error)
Update implements updating servicegroup based on k8s api Does not support updating cloud disk (pvc)
func (*Kubernetes) UpdateNamespace ¶
func (k *Kubernetes) UpdateNamespace(ns string, sg *apistructs.ServiceGroup) error
UpdateNamespace
type OneGroupInfo ¶
type OneGroupInfo struct {
// contains filtered or unexported fields
}
OneGroupInfo Returns information about the statefulset corresponding to the group
type StatefulsetInfo ¶
type StatefulsetInfo struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package configmap manipulates the k8s api of configmap object
|
Package configmap manipulates the k8s api of configmap object |
Package deployment manipulates the k8s api of deployment object
|
Package deployment manipulates the k8s api of deployment object |
Package event manipulates the k8s api of event object Package event manipulates the k8s api of event object Package event manipulates the k8s api of event object
|
Package event manipulates the k8s api of event object Package event manipulates the k8s api of event object Package event manipulates the k8s api of event object |
Package ingress manipulates the k8s api of ingress object
|
Package ingress manipulates the k8s api of ingress object |
Package k8sapi contains necessary k8s types and objects
|
Package k8sapi contains necessary k8s types and objects |
Package k8serror encapsulates error of k8s object
|
Package k8serror encapsulates error of k8s object |
Package k8sservice manipulates the k8s api of service object
|
Package k8sservice manipulates the k8s api of service object |
Package namespace manipulates the k8s api of namespace object
|
Package namespace manipulates the k8s api of namespace object |
Package persistentvolume manipulates the k8s api of persistentvolume object
|
Package persistentvolume manipulates the k8s api of persistentvolume object |
Package persistentvolumeclaim manipulates the k8s api of persistentvolumeclaim object
|
Package persistentvolumeclaim manipulates the k8s api of persistentvolumeclaim object |
Package pod manipulates the k8s api of pod object
|
Package pod manipulates the k8s api of pod object |
Package role manipulates the k8s api of role object
|
Package role manipulates the k8s api of role object |
Package rolebinding manipulates the k8s api of rolebinding object
|
Package rolebinding manipulates the k8s api of rolebinding object |
Package secret manipulates the k8s api of secret object
|
Package secret manipulates the k8s api of secret object |
Package serviceaccount manipulates the k8s api of serviceaccount object
|
Package serviceaccount manipulates the k8s api of serviceaccount object |
Package statefulset manipulates the k8s api of statefulset object
|
Package statefulset manipulates the k8s api of statefulset object |