Documentation ¶
Index ¶
- Constants
- func CreateStaticIPFile(ip string) error
- func IsStaticIPFileExist() (bool, error)
- func ReadStaticIP() (ip string, err error)
- type K8sInfo
- type K8sSvc
- func (s *K8sSvc) CreateReplicaSet(ctx context.Context, opts *containersvc.CreateServiceOptions) error
- func (s *K8sSvc) CreateService(ctx context.Context, opts *containersvc.CreateServiceOptions) error
- func (s *K8sSvc) CreateServiceVolume(ctx context.Context, service string, memberIndex int64, volumeID string, ...) (existingVolumeID string, err error)
- func (s *K8sSvc) DeleteReplicaSet(ctx context.Context, service string) error
- func (s *K8sSvc) DeleteService(ctx context.Context, cluster string, service string) error
- func (s *K8sSvc) DeleteServiceVolume(ctx context.Context, service string, memberIndex int64, journal bool) error
- func (s *K8sSvc) DeleteTask(ctx context.Context, cluster string, service string, taskType string) error
- func (s *K8sSvc) GetContainerSvcType() string
- func (s *K8sSvc) GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
- func (s *K8sSvc) GetServiceTask(ctx context.Context, cluster string, service string, ...) (serviceTaskID string, err error)
- func (s *K8sSvc) GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
- func (s *K8sSvc) IsServiceExist(ctx context.Context, cluster string, service string) (bool, error)
- func (s *K8sSvc) ListActiveServiceTasks(ctx context.Context, cluster string, service string) (serviceTaskIDs map[string]bool, err error)
- func (s *K8sSvc) RunTask(ctx context.Context, opts *containersvc.RunTaskOptions) (taskID string, err error)
- func (s *K8sSvc) ScaleService(ctx context.Context, cluster string, service string, desiredCount int64) error
- func (s *K8sSvc) StopService(ctx context.Context, cluster string, service string) error
Constants ¶
const ( // K8sServiceInitContainerImage is the common init container image for all services in k8s. K8sServiceInitContainerImage = common.OrgName + common.SystemName + "-initcontainer" K8sServiceStopContainerImage = common.OrgName + common.SystemName + "-stopcontainer" EnvInitContainerTestMode = "TESTMODE" EnvInitContainerCluster = "CLUSTER" EnvInitContainerServiceName = "SERVICE_NAME" EnvInitContainerPodName = "POD_NAME" )
Variables ¶
This section is empty.
Functions ¶
func CreateStaticIPFile ¶ added in v0.9.3
CreateStaticIPFile writes the static ip into file, so the container stop could delete the attached ip.
func IsStaticIPFileExist ¶ added in v0.9.3
IsStaticIPFileExist returns whether the static ip file exists.
func ReadStaticIP ¶ added in v0.9.3
ReadStaticIP reads the member's static ip from file.
Types ¶
type K8sInfo ¶ added in v0.9.3
type K8sInfo struct {
// contains filtered or unexported fields
}
func NewK8sInfo ¶ added in v0.9.3
func (*K8sInfo) GetContainerClusterID ¶ added in v0.9.3
func (*K8sInfo) GetLocalContainerInstanceID ¶ added in v0.9.3
type K8sSvc ¶
type K8sSvc struct {
// contains filtered or unexported fields
}
K8sSvc implements the containersvc interface for kubernetes. https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster
func NewK8sSvc ¶
func NewK8sSvc(cluster string, cloudPlatform string, dbType string, namespace string) (*K8sSvc, error)
NewK8sSvc creates a new K8sSvc instance. TODO support different namespaces for different services? Wait for the real requirement.
func NewTestK8sSvc ¶ added in v0.9.3
func NewTestK8sSvc(cluster string, cloudPlatform string, namespace string, config *rest.Config) (*K8sSvc, error)
NewTestK8sSvc creates a new K8sSvc instance for test.
func (*K8sSvc) CreateReplicaSet ¶ added in v0.9.3
func (s *K8sSvc) CreateReplicaSet(ctx context.Context, opts *containersvc.CreateServiceOptions) error
CreateReplicaSet creates a k8s replicaset. Note: currently volume is skipped for ReplicaSet.
func (*K8sSvc) CreateService ¶
func (s *K8sSvc) CreateService(ctx context.Context, opts *containersvc.CreateServiceOptions) error
CreateService creates the headless service, storage class and statefulset.
func (*K8sSvc) CreateServiceVolume ¶ added in v0.9.3
func (s *K8sSvc) CreateServiceVolume(ctx context.Context, service string, memberIndex int64, volumeID string, volumeSizeGB int64, journal bool) (existingVolumeID string, err error)
CreateServiceVolume creates PV and PVC for the service member.
func (*K8sSvc) DeleteReplicaSet ¶ added in v0.9.3
DeleteReplicaSet deletes a k8s replicaset.
func (*K8sSvc) DeleteService ¶
DeleteService deletes the service on the container platform. Expect no error (nil) if service does not exist.
func (*K8sSvc) DeleteServiceVolume ¶ added in v0.9.3
func (s *K8sSvc) DeleteServiceVolume(ctx context.Context, service string, memberIndex int64, journal bool) error
DeleteServiceVolume deletes the pv and pvc for the service member.
func (*K8sSvc) DeleteTask ¶
func (s *K8sSvc) DeleteTask(ctx context.Context, cluster string, service string, taskType string) error
DeleteTask deletes the task.
func (*K8sSvc) GetContainerSvcType ¶ added in v0.9.3
GetContainerSvcType gets the containersvc type.
func (*K8sSvc) GetServiceStatus ¶
func (s *K8sSvc) GetServiceStatus(ctx context.Context, cluster string, service string) (*common.ServiceStatus, error)
GetServiceStatus returns the service status.
func (*K8sSvc) GetServiceTask ¶
func (s *K8sSvc) GetServiceTask(ctx context.Context, cluster string, service string, containerInstanceID string) (serviceTaskID string, err error)
GetServiceTask gets the service task on the container instance.
func (*K8sSvc) GetTaskStatus ¶
func (s *K8sSvc) GetTaskStatus(ctx context.Context, cluster string, taskID string) (*common.TaskStatus, error)
GetTaskStatus gets the task status.
func (*K8sSvc) IsServiceExist ¶
IsServiceExist checks if service exists. If not exist, return false & nil. If exists, return true & nil. If meets any error, error will be returned.
func (*K8sSvc) ListActiveServiceTasks ¶
func (s *K8sSvc) ListActiveServiceTasks(ctx context.Context, cluster string, service string) (serviceTaskIDs map[string]bool, err error)
ListActiveServiceTasks lists the active (pending and running) tasks of the service.
func (*K8sSvc) RunTask ¶
func (s *K8sSvc) RunTask(ctx context.Context, opts *containersvc.RunTaskOptions) (taskID string, err error)
RunTask runs a task.
Directories ¶
Path | Synopsis |
---|---|
Note: the example only works with the code within the same release/branch.
|
Note: the example only works with the code within the same release/branch. |