Documentation
¶
Index ¶
- Constants
- func AppTemplateToYamlString(tpl AppTemplate, cluster, namespace, podVersion string) (string, error)
- func CreateK8sNamespace(cluster, namespace string) error
- func CreateRegistrySecret(cluster, namespace string, envID int64) error
- func DeployAppTemplates(appTplList []AppTemplate, projectid, envID int64, ...) error
- func GenDefaultIngressObject(svc *apiv1.Service, ingObjMeta metav1.ObjectMeta, defPort int32, ...) *extensions.Ingress
- func GenerateDeployName(appname string) string
- func GetImageVersion(image string) string
- func GetResourceVersion(res interface{}, resType ResType, exparam string) string
- func TriggerApplicationCreate(clusterName, namespace, templateStr string, projectID, envID int64, force bool) error
- type AppDetail
- type AppEvent
- type AppItem
- type AppParam
- type AppPod
- type AppPodBasicParam
- type AppPodDetail
- type AppRes
- func (ar *AppRes) DeleteApp(namespace, appname string) error
- func (ar *AppRes) GetAppDetail(namespace, name string) (*AppDetail, error)
- func (ar *AppRes) GetAppEvent(namespace, appName string) ([]AppEvent, error)
- func (ar *AppRes) GetAppListByPagination(filterQuery *query.FilterQuery, projectID int64, cluster string) (*query.QueryResult, error)
- func (ar *AppRes) GetAppPodLog(namespace, appName, podName, containerName string) (string, error)
- func (ar *AppRes) GetAppPodStatus(namespace, appName, podName string) (interface{}, error)
- func (ar *AppRes) GetAppServiceDetail(namespace, appDeploymentName, nodeIP string) ([]*ServiceDetail, error)
- func (ar *AppRes) GetDeployRuntime(app models.CaasApplication, deploymentName string) (string, string, error)
- func (ar *AppRes) InstallApp(namespace, tname string, template Template, eparam *ExtensionParam) error
- func (ar *AppRes) ReconfigureApp(app models.CaasApplication, template AppTemplate) (*AppDetail, error)
- func (ar *AppRes) Restart(namespace, appname string) error
- func (ar *AppRes) RollingUpdateApp(namespace, appname string, param []ContainerParam) error
- func (ar *AppRes) ScaleApp(namespace, appname string, replicas int) error
- func (ar *AppRes) SetDeployStatus(namespace, appname, status string) error
- func (ar *AppRes) SetLabels(namespace, name string, labels map[string]string) error
- func (ar *AppRes) UninstallApp(app models.CaasApplication) error
- type AppResourceItem
- type AppStatus
- type AppTemplate
- type ContainerItem
- type ContainerParam
- type DeployConfig
- type DeployWorker
- type DeploymentRes
- func (kr *DeploymentRes) AppIsExisted(appname string) (bool, error)
- func (kr *DeploymentRes) Create(obj interface{}) error
- func (kr *DeploymentRes) Delete(appname string) error
- func (kr *DeploymentRes) DeletePods(options *metav1.ListOptions, appname string) error
- func (kr *DeploymentRes) GetOwnerForPod(pod apiv1.Pod, ref *metav1.OwnerReference) interface{}
- func (kr *DeploymentRes) Restart(appname string) error
- func (kr *DeploymentRes) Scale(appname string, replicas int) error
- func (kr *DeploymentRes) Status(appname string) (*AppStatus, error)
- func (kr *DeploymentRes) Update(app models.CaasApplication, obj interface{}) (int, error)
- type EventItem
- type ExtensionParam
- type KubeAppInterface
- type KubeAppRes
- func (kr *KubeAppRes) CheckAppIsExisted(appname string) (bool, error)
- func (kr *KubeAppRes) CreateAppResource(template AppTemplate) error
- func (kr *KubeAppRes) CreateService(svcList []*apiv1.Service) error
- func (kr *KubeAppRes) DeleteAppResource(template AppTemplate) error
- func (kr *KubeAppRes) DeleteApplication(appname string) error
- func (kr *KubeAppRes) Restart(appname string) error
- func (kr *KubeAppRes) Scale(appname string, replicas int) error
- func (kr *KubeAppRes) SetAppStatus(app *models.CaasApplication)
- func (kr *KubeAppRes) UpdateAppResource(app *models.CaasApplication, new, old AppTemplate, all bool) error
- type KubeAppValidator
- type KubeSvcValidator
- type NamespaceListFunction
- type NativeAppTemplate
- func (tp *NativeAppTemplate) DefaultLabel() AppTemplate
- func (tp *NativeAppTemplate) GenerateAppObject(cluster, namespace, tplname string, projectID int64) (*models.CaasApplication, error)
- func (tp *NativeAppTemplate) GenerateKubeObject(cluster, namespace string) (map[string]interface{}, error)
- func (tp *NativeAppTemplate) GetAppKind() string
- func (tp *NativeAppTemplate) GetAppName() string
- func (tp *NativeAppTemplate) Image(param []ContainerParam) AppTemplate
- func (tp *NativeAppTemplate) Replicas(replicas int) AppTemplate
- func (tp *NativeAppTemplate) String() (string, error)
- func (tp *NativeAppTemplate) UpdateAppObject(app *models.CaasApplication) error
- type NativeTemplate
- func (t *NativeTemplate) CreateNoAppResource(client kubernetes.Interface, cluster, namespace string, objs []ResObject)
- func (t *NativeTemplate) Default(envID int64) Template
- func (t *NativeTemplate) Deploy(projectID, envID int64, cluster, namespace, tname string, ...) error
- func (t *NativeTemplate) GenNativeAppTemplate(namespace, appname string) ([]*NativeAppTemplate, []ResObject, error)
- func (t *NativeTemplate) GetAppResourceNames() ([]AppResourceItem, error)
- func (t *NativeTemplate) GetContainerImages() ([]*ContainerItem, error)
- func (t *NativeTemplate) GetExample() []byte
- func (t *NativeTemplate) Validate() error
- type ObjectValidator
- type PatcherFunction
- type Pod
- type PodContainer
- type ResObject
- type ResType
- type RollBackFunc
- type RollingUpdateApp
- type ServiceDetail
- type StatefulRes
- func (kr *StatefulRes) AppIsExisted(appname string) (bool, error)
- func (kr *StatefulRes) Create(obj interface{}) error
- func (kr *StatefulRes) Delete(appname string) error
- func (kr *StatefulRes) DeletePods(options *metav1.ListOptions, appname string) error
- func (kr *StatefulRes) GetOwnerForPod(pod apiv1.Pod, ref *metav1.OwnerReference) interface{}
- func (kr *StatefulRes) Restart(appname string) error
- func (kr *StatefulRes) Scale(appname string, replicas int) error
- func (kr *StatefulRes) Status(appname string) (*AppStatus, error)
- func (kr *StatefulRes) Update(app models.CaasApplication, obj interface{}) (int, error)
- type Template
- type TemplateInfo
- type TemplateRes
- func (tr *TemplateRes) CreateTemplate(template models.CaasTemplate) (*models.CaasTemplate, error)
- func (tr *TemplateRes) DeleteTemplate(namespace, name string) error
- func (tr *TemplateRes) GetTemplateByID(id int64) (*models.CaasTemplate, int, error)
- func (tr *TemplateRes) GetTemplateByName(namespace, name string) (*models.CaasTemplate, int, error)
- func (tr *TemplateRes) UpdateTemplate(template models.CaasTemplate) (*models.CaasTemplate, error)
- type VersionWeight
- type WorkerResult
Constants ¶
View Source
const ( AppKindDaemonSet = "daemonset" AppKindDeployment = "deployment" AppKindStatefulSet = "statefulset" LABLE_APPNAME_KEY = "app" LABLE_APPVERSION_KEY = "version" ServiceKind = "service" ConfigMapKind = "configmap" SecretKind = "secret" DescriptionAnnotationKey = "description" OwnerNameAnnotationKey = "owner_name" DEFAULT_PROJECT_ID = 0 YamlSeparator = "---\n" IngApiVersion = "extensions/v1beta1" )
View Source
const ( RESTART_LABLE = "caas_restart" RESTART_LABLE_VALUE = "true" )
View Source
const ( INIT_APPNAME = "" DefaultVersion = "latest" APP_PROTOCOL_HTTP = "http" )
View Source
const ( PodStatusRunning = "Running" PodStatusNotReady = "NotReady" )
View Source
const TemplateMaxSize = 1024000 //1000KB
Variables ¶
This section is empty.
Functions ¶
func AppTemplateToYamlString ¶
func AppTemplateToYamlString(tpl AppTemplate, cluster, namespace, podVersion string) (string, error)
func CreateK8sNamespace ¶
func CreateRegistrySecret ¶
func DeployAppTemplates ¶
func DeployAppTemplates(appTplList []AppTemplate, projectid, envID int64, cluster, namespace, tname string, eparam *ExtensionParam) error
func GenDefaultIngressObject ¶
func GenDefaultIngressObject(svc *apiv1.Service, ingObjMeta metav1.ObjectMeta, defPort int32, domainName, domainSuffix string) *extensions.Ingress
func GenerateDeployName ¶
func GetImageVersion ¶
func GetResourceVersion ¶
Types ¶
type AppDetail ¶
type AppDetail struct { AppItem Services []*ServiceDetail `json:"services,omitempty"` Pods []*AppPod `json:"pods,omitempty"` }
type AppParam ¶
type AppParam struct { Name string `json:"name"` //appname Containers []ContainerParam `json:"containers,omitempty"` Replicas *intstr.IntOrString `json:"replicas,omitempty"` }
type AppPodBasicParam ¶
type AppPodDetail ¶
type AppPodDetail struct { models.CaasApplication `json:",inline"` Pod AppPod `json:"pod"` }
type AppRes ¶
type AppRes struct { Cluster string EnvID int64 ProjectID int64 Client kubernetes.Interface Appmodel *dao.AppModel }
func (*AppRes) GetAppDetail ¶
func (*AppRes) GetAppEvent ¶
func (*AppRes) GetAppListByPagination ¶
func (ar *AppRes) GetAppListByPagination(filterQuery *query.FilterQuery, projectID int64, cluster string) (*query.QueryResult, error)
GetAppListByPagination ..
func (*AppRes) GetAppPodLog ¶
func (*AppRes) GetAppPodStatus ¶
func (*AppRes) GetAppServiceDetail ¶
func (ar *AppRes) GetAppServiceDetail(namespace, appDeploymentName, nodeIP string) ([]*ServiceDetail, error)
func (*AppRes) GetDeployRuntime ¶
func (*AppRes) InstallApp ¶
func (ar *AppRes) InstallApp( namespace, tname string, template Template, eparam *ExtensionParam) error
func (*AppRes) ReconfigureApp ¶
func (ar *AppRes) ReconfigureApp(app models.CaasApplication, template AppTemplate) (*AppDetail, error)
func (*AppRes) RollingUpdateApp ¶
func (ar *AppRes) RollingUpdateApp(namespace, appname string, param []ContainerParam) error
func (*AppRes) SetDeployStatus ¶
func (*AppRes) UninstallApp ¶
func (ar *AppRes) UninstallApp(app models.CaasApplication) error
type AppResourceItem ¶
type AppTemplate ¶
type AppTemplate interface { GenerateAppObject(cluster, namespace, tplname string, projectID int64) (*models.CaasApplication, error) UpdateAppObject(app *models.CaasApplication) error GenerateKubeObject(cluster, namespace string) (map[string]interface{}, error) GetAppName() string GetAppKind() string String() (string, error) Image(param []ContainerParam) AppTemplate DefaultLabel() AppTemplate Replicas(replicas int) AppTemplate }
single app template interface simpleapp and nativeapp template support this interface
func CreateAppTemplateByApp ¶
func CreateAppTemplateByApp(app models.CaasApplication) (AppTemplate, error)
func CreateNativeAppTemplate ¶
func CreateNativeAppTemplate(app models.CaasApplication) (AppTemplate, error)
context is file context of native template,
type ContainerItem ¶
type ContainerParam ¶
type DeployConfig ¶
type DeployWorker ¶
type DeployWorker struct { Name string // contains filtered or unexported fields }
func NewDeployWorker ¶
func NewDeployWorker(name, namespace, kind string, ar *AppRes, eparam *ExtensionParam, tpl AppTemplate) *DeployWorker
type DeploymentRes ¶
type DeploymentRes struct { Namespace string // contains filtered or unexported fields }
func (*DeploymentRes) AppIsExisted ¶
func (kr *DeploymentRes) AppIsExisted(appname string) (bool, error)
AppIsExisted ..
func (*DeploymentRes) Create ¶
func (kr *DeploymentRes) Create(obj interface{}) error
func (*DeploymentRes) Delete ¶
func (kr *DeploymentRes) Delete(appname string) error
func (*DeploymentRes) DeletePods ¶
func (kr *DeploymentRes) DeletePods(options *metav1.ListOptions, appname string) error
DeletePods ..
func (*DeploymentRes) GetOwnerForPod ¶
func (kr *DeploymentRes) GetOwnerForPod(pod apiv1.Pod, ref *metav1.OwnerReference) interface{}
func (*DeploymentRes) Restart ¶
func (kr *DeploymentRes) Restart(appname string) error
func (*DeploymentRes) Status ¶
func (kr *DeploymentRes) Status(appname string) (*AppStatus, error)
Status ..
func (*DeploymentRes) Update ¶
func (kr *DeploymentRes) Update(app models.CaasApplication, obj interface{}) (int, error)
type EventItem ¶
type EventItem struct { EventUid string `orm:"column(event_uid);size(36)" json:"event_uid"` ActionType string `orm:"column(action_type);size(10)" json:"action_type"` EventType string `orm:"column(event_type);size(10)" json:"event_type"` Cluster string `orm:"column(cluster);size(20)" json:"cluster"` Namespace string `orm:"column(namespace);size(100)" json:"namespace"` SourceComponent string `orm:"column(source_component);size(50)" json:"source_component"` SourceHost string `orm:"column(source_host);size(60)" json:"source_host"` ObjectKind string `orm:"column(object_kind);size(64)" json:"object_kind"` ObjectName string `orm:"column(object_name);size(100)" json:"object_name"` ObjectUid string `orm:"column(object_uid);size(36)" json:"object_uid"` FieldPath string `orm:"column(field_path);size(200)" json:"field_path"` Reason string `orm:"column(reason);size(100)" json:"reason"` Message string `orm:"column(message);type(text)" json:"message"` FirstTimestamp time.Time `orm:"column(first_time)" json:"first_time"` LastTimestamp time.Time `orm:"column(last_time);index" json:"last_time"` }
func GetEventList ¶
func GetEventList(client kubernetes.Interface, cluster, namespace, appName string) ([]*EventItem, error)
type ExtensionParam ¶
type ExtensionParam struct { Force bool //when user deploy its app and the app is existed in other namespace, the old app will be deleted Patcher PatcherFunction }
type KubeAppInterface ¶
type KubeAppInterface interface { Create(obj interface{}) error Update(app models.CaasApplication, obj interface{}) (int, error) Status(appname string) (*AppStatus, error) Delete(appname string) error DeletePods(selector *metav1.ListOptions, appname string) error AppIsExisted(appname string) (bool, error) Scale(appname string, replicas int) error Restart(appname string) error GetOwnerForPod(pod apiv1.Pod, ref *metav1.OwnerReference) interface{} }
func NewDeploymentRes ¶
func NewDeploymentRes(client kubernetes.Interface, namespace string) KubeAppInterface
func NewStatefulRes ¶
func NewStatefulRes(client kubernetes.Interface, namespace string) KubeAppInterface
type KubeAppRes ¶
type KubeAppRes struct { DomainSuffix string Namespace string // contains filtered or unexported fields }
func NewKubeAppRes ¶
func NewKubeAppRes(client kubernetes.Interface, cluster, namespace, kind string) *KubeAppRes
func (*KubeAppRes) CheckAppIsExisted ¶
func (kr *KubeAppRes) CheckAppIsExisted(appname string) (bool, error)
func (*KubeAppRes) CreateAppResource ¶
func (kr *KubeAppRes) CreateAppResource(template AppTemplate) error
func (*KubeAppRes) CreateService ¶
func (kr *KubeAppRes) CreateService(svcList []*apiv1.Service) error
func (*KubeAppRes) DeleteAppResource ¶
func (kr *KubeAppRes) DeleteAppResource(template AppTemplate) error
func (*KubeAppRes) DeleteApplication ¶
func (kr *KubeAppRes) DeleteApplication(appname string) error
func (*KubeAppRes) Restart ¶
func (kr *KubeAppRes) Restart(appname string) error
func (*KubeAppRes) SetAppStatus ¶
func (kr *KubeAppRes) SetAppStatus(app *models.CaasApplication)
func (*KubeAppRes) UpdateAppResource ¶
func (kr *KubeAppRes) UpdateAppResource(app *models.CaasApplication, new, old AppTemplate, all bool) error
type KubeAppValidator ¶
type KubeAppValidator struct {
// contains filtered or unexported fields
}
func NewKubeAppValidator ¶
func NewKubeAppValidator(client kubernetes.Interface, namespace string) *KubeAppValidator
func (*KubeAppValidator) Validator ¶
func (validator *KubeAppValidator) Validator(obj interface{}) error
type KubeSvcValidator ¶
type KubeSvcValidator struct {
// contains filtered or unexported fields
}
func NewKubeSvcValidator ¶
func NewKubeSvcValidator(cluster, namespace, appname string) *KubeSvcValidator
func (*KubeSvcValidator) Validator ¶
func (validator *KubeSvcValidator) Validator(obj interface{}) error
type NamespaceListFunction ¶
type NamespaceListFunction func() []string
type NativeAppTemplate ¶
type NativeAppTemplate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Deployment *appsv1.Deployment `json:"deployment,omitempty"` Services []*apiv1.Service `json:"services,omitempty"` Ingresses []*extensions.Ingress `json:"ingresses,omitempty"` Config DeployConfig `json:"config"` }
native app template and api
func (*NativeAppTemplate) DefaultLabel ¶
func (tp *NativeAppTemplate) DefaultLabel() AppTemplate
func (*NativeAppTemplate) GenerateAppObject ¶
func (tp *NativeAppTemplate) GenerateAppObject(cluster, namespace, tplname string, projectID int64) (*models.CaasApplication, error)
TODO: refactor
func (*NativeAppTemplate) GenerateKubeObject ¶
func (tp *NativeAppTemplate) GenerateKubeObject(cluster, namespace string) (map[string]interface{}, error)
func (*NativeAppTemplate) GetAppKind ¶
func (tp *NativeAppTemplate) GetAppKind() string
func (*NativeAppTemplate) GetAppName ¶
func (tp *NativeAppTemplate) GetAppName() string
func (*NativeAppTemplate) Image ¶
func (tp *NativeAppTemplate) Image(param []ContainerParam) AppTemplate
func (*NativeAppTemplate) Replicas ¶
func (tp *NativeAppTemplate) Replicas(replicas int) AppTemplate
func (*NativeAppTemplate) String ¶
func (tp *NativeAppTemplate) String() (string, error)
func (*NativeAppTemplate) UpdateAppObject ¶
func (tp *NativeAppTemplate) UpdateAppObject(app *models.CaasApplication) error
type NativeTemplate ¶
type NativeTemplate struct { Template string `json:"template"` Config DeployConfig `json:"config"` }
native template and api
func NewNativeTemplate ¶
func NewNativeTemplate() *NativeTemplate
func (*NativeTemplate) CreateNoAppResource ¶
func (t *NativeTemplate) CreateNoAppResource(client kubernetes.Interface, cluster, namespace string, objs []ResObject)
func (*NativeTemplate) Default ¶
func (t *NativeTemplate) Default(envID int64) Template
set default value for template config
func (*NativeTemplate) Deploy ¶
func (t *NativeTemplate) Deploy(projectID, envID int64, cluster, namespace, tname string, eparam *ExtensionParam) error
func (*NativeTemplate) GenNativeAppTemplate ¶
func (t *NativeTemplate) GenNativeAppTemplate(namespace, appname string) ([]*NativeAppTemplate, []ResObject, error)
func (*NativeTemplate) GetAppResourceNames ¶
func (t *NativeTemplate) GetAppResourceNames() ([]AppResourceItem, error)
GetAppResourceNames .. TODO: current support deployment/statefulset daemonset parse
func (*NativeTemplate) GetContainerImages ¶
func (t *NativeTemplate) GetContainerImages() ([]*ContainerItem, error)
func (*NativeTemplate) GetExample ¶
func (t *NativeTemplate) GetExample() []byte
func (*NativeTemplate) Validate ¶
func (t *NativeTemplate) Validate() error
type ObjectValidator ¶
type ObjectValidator interface {
Validator(obj interface{}) error
}
type PatcherFunction ¶
type PatcherFunction func(app models.CaasApplication)
type Pod ¶
type Pod struct { Name string `json:"name"` Namespace string `json:"namespace"` Version string `json:"version"` NodeIP string `json:"node_ip"` PodIP string `json:"pod_ip"` Status string `json:"status"` Message string `json:"message"` RestartCount int32 `json:"restart_count"` StartTime string `json:"start_time"` Labels map[string]string `json:"labels"` Containers []*PodContainer `json:"containers"` }
type PodContainer ¶
type RollBackFunc ¶
type RollBackFunc func() error
type RollingUpdateApp ¶
type ServiceDetail ¶
type ServiceDetail struct { Name string `json:"name"` Type string `json:"type"` ClusterIP string `json:"cluster_ip"` AddressList []serviceAddress `json:"address_list"` PodsvcAddrList []podSvcAddress `json:"podsvc_addr_list"` }
func GetAppServices ¶
func GetAppServices(client kubernetes.Interface, cluster, namespace, appDeploymentName, nodeIP string) ([]*ServiceDetail, error)
type StatefulRes ¶
type StatefulRes struct { Namespace string // contains filtered or unexported fields }
func (*StatefulRes) AppIsExisted ¶
func (kr *StatefulRes) AppIsExisted(appname string) (bool, error)
AppIsExisted ..
func (*StatefulRes) Create ¶
func (kr *StatefulRes) Create(obj interface{}) error
func (*StatefulRes) Delete ¶
func (kr *StatefulRes) Delete(appname string) error
func (*StatefulRes) DeletePods ¶
func (kr *StatefulRes) DeletePods(options *metav1.ListOptions, appname string) error
func (*StatefulRes) GetOwnerForPod ¶
func (kr *StatefulRes) GetOwnerForPod(pod apiv1.Pod, ref *metav1.OwnerReference) interface{}
func (*StatefulRes) Restart ¶
func (kr *StatefulRes) Restart(appname string) error
func (*StatefulRes) Update ¶
func (kr *StatefulRes) Update(app models.CaasApplication, obj interface{}) (int, error)
type Template ¶
type Template interface { Default(envID int64) Template Validate() error GetExample() []byte Deploy(projectid, envID int64, cluster, namespace, tname string, eparam *ExtensionParam) error }
template interface, nativetemplate support this interface
func NewTemplate ¶
func NewTemplate() Template
type TemplateInfo ¶
type TemplateInfo struct { models.CaasTemplate CreateAt string `json:"create_at"` UpdateAt string `json:"update_at"` DeleteAt string `json:"delete_at"` }
type TemplateRes ¶
type TemplateRes struct {
// contains filtered or unexported fields
}
func NewTemplateRes ¶
func NewTemplateRes(get NamespaceListFunction) *TemplateRes
func (*TemplateRes) CreateTemplate ¶
func (tr *TemplateRes) CreateTemplate(template models.CaasTemplate) (*models.CaasTemplate, error)
func (*TemplateRes) DeleteTemplate ¶
func (tr *TemplateRes) DeleteTemplate(namespace, name string) error
func (*TemplateRes) GetTemplateByID ¶
func (tr *TemplateRes) GetTemplateByID(id int64) (*models.CaasTemplate, int, error)
func (*TemplateRes) GetTemplateByName ¶
func (tr *TemplateRes) GetTemplateByName(namespace, name string) (*models.CaasTemplate, int, error)
func (*TemplateRes) UpdateTemplate ¶
func (tr *TemplateRes) UpdateTemplate(template models.CaasTemplate) (*models.CaasTemplate, error)
type VersionWeight ¶
type VersionWeight struct { Stage string `json:"stage"` Version string `json:"version"` Weight intstr.IntOrString `json:"weight"` }
type WorkerResult ¶
Click to show internal directories.
Click to hide internal directories.