mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-26 07:18:34 +08:00
【修改】k8s 配置
This commit is contained in:
6
apps/devops/entity/k8s/configmap.go
Normal file
6
apps/devops/entity/k8s/configmap.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package k8s
|
||||
|
||||
type ConfigMapData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
6
apps/devops/entity/k8s/daemonset.go
Normal file
6
apps/devops/entity/k8s/daemonset.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package k8s
|
||||
|
||||
type DaemonSetData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
30
apps/devops/entity/k8s/deployment.go
Normal file
30
apps/devops/entity/k8s/deployment.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package k8s
|
||||
|
||||
type RemoveDeploymentData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
DeploymentName string `json:"deploymentName" binding:"required"`
|
||||
}
|
||||
|
||||
type ScaleDeployment struct {
|
||||
ScaleNumber *int32 `json:"scaleNumber" binding:"required"`
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
DeploymentName string `json:"deploymentName" binding:"required"`
|
||||
}
|
||||
|
||||
type RestartDeployment struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
DeploymentName string `json:"deploymentName" binding:"required"`
|
||||
}
|
||||
|
||||
type RemoveDeploymentToServiceData struct {
|
||||
IsDeleteService bool `json:"isDeleteService" binding:"required"`
|
||||
ServiceName string `json:"serviceName" binding:"required"`
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
DeploymentName string `json:"deploymentName" binding:"required"`
|
||||
}
|
||||
|
||||
type RollbackDeployment struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
DeploymentName string `json:"deploymentName" binding:"required"`
|
||||
ReVersion *int64 `json:"reVersion" binding:"required"`
|
||||
}
|
||||
13
apps/devops/entity/k8s/job.go
Normal file
13
apps/devops/entity/k8s/job.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package k8s
|
||||
|
||||
type JobData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
|
||||
type ScaleJob struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
// Job并行运行的Pod数量
|
||||
Number *int32 `json:"number" binding:"required"`
|
||||
}
|
||||
34
apps/devops/entity/k8s/k8s_cluster.go
Normal file
34
apps/devops/entity/k8s/k8s_cluster.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package k8s
|
||||
|
||||
type K8SCluster struct {
|
||||
ClusterName string `json:"clusterName" gorm:"comment:集群名称" form:"clusterName" binding:"required"`
|
||||
KubeConfig string `json:"kubeConfig" gorm:"comment:集群凭证;type:varchar(12800)" binding:"required"`
|
||||
ClusterVersion string `json:"clusterVersion" gorm:"comment:集群版本"`
|
||||
NodeNumber int `json:"nodeNumber" gorm:"comment:节点数"`
|
||||
}
|
||||
|
||||
type PaginationQ struct {
|
||||
Size int `form:"size" json:"size"`
|
||||
Page int `form:"page" json:"page"`
|
||||
Total int64 `json:"total"`
|
||||
Keyword string `form:"keyword" json:"keyword"`
|
||||
}
|
||||
|
||||
type ClusterIds struct {
|
||||
Data interface{} `json:"clusterIds"`
|
||||
}
|
||||
|
||||
type ClusterNodesStatus struct {
|
||||
NodeCount int `json:"node_count"`
|
||||
Ready int `json:"ready"`
|
||||
UnReady int `json:"unready"`
|
||||
Namespace int `json:"namespace"`
|
||||
Deployment int `json:"deployment"`
|
||||
Pod int `json:"pod"`
|
||||
CpuUsage float64 `json:"cpu_usage" desc:"cpu使用率"`
|
||||
CpuCore float64 `json:"cpu_core"`
|
||||
CpuCapacityCore float64 `json:"cpu_capacity_core"`
|
||||
MemoryUsage float64 `json:"memory_usage" desc:"内存使用率"`
|
||||
MemoryUsed float64 `json:"memory_used"`
|
||||
MemoryTotal float64 `json:"memory_total"`
|
||||
}
|
||||
112
apps/devops/entity/k8s/node.go
Normal file
112
apps/devops/entity/k8s/node.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package k8s
|
||||
|
||||
import "time"
|
||||
|
||||
// ListMeta describes list of objects, i.e. holds information about pagination options set for the list.
|
||||
type ListMeta struct {
|
||||
// Total number of items on the list. Used for pagination.
|
||||
TotalItems int `json:"totalItems"`
|
||||
}
|
||||
|
||||
// ObjectMeta is metadata about an instance of a resource.
|
||||
type ObjectMeta struct {
|
||||
// Name is unique within a namespace. Name is primarily intended for creation
|
||||
// idempotence and configuration definition.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Namespace defines the space within which name must be unique. An empty namespace is
|
||||
// equivalent to the "default" namespace, but "default" is the canonical representation.
|
||||
// Not all objects are required to be scoped to a namespace - the value of this field for
|
||||
// those objects will be empty.
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
|
||||
// Labels are key value pairs that may be used to scope and select individual resources.
|
||||
// Label keys are of the form:
|
||||
// label-key ::= prefixed-name | name
|
||||
// prefixed-name ::= prefix '/' name
|
||||
// prefix ::= DNS_SUBDOMAIN
|
||||
// name ::= DNS_LABEL
|
||||
// The prefix is optional. If the prefix is not specified, the key is assumed to be private
|
||||
// to the user. Other system components that wish to use labels must specify a prefix.
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
// Annotations are unstructured key value data stored with a resource that may be set by
|
||||
// external tooling. They are not queryable and should be preserved when modifying
|
||||
// objects. Annotation keys have the same formatting restrictions as Label keys. See the
|
||||
// comments on Labels for details.
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
|
||||
// CreationTimestamp is a timestamp representing the server time when this object was
|
||||
// created. It is not guaranteed to be set in happens-before order across separate operations.
|
||||
// Clients may not set this value. It is represented in RFC3339 form and is in UTC.
|
||||
CreationTimestamp Time `json:"creationTimestamp,omitempty"`
|
||||
}
|
||||
|
||||
// TypeMeta describes an individual object in an API response or request with strings representing
|
||||
// the type of the object.
|
||||
type TypeMeta struct {
|
||||
// Kind is a string value representing the REST resource this object represents.
|
||||
// Servers may infer this from the endpoint the client submits requests to.
|
||||
// In smalllettercase.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
|
||||
Kind ResourceKind `json:"kind,omitempty"`
|
||||
}
|
||||
|
||||
// NodeAllocatedResources describes node allocated resources.
|
||||
type NodeAllocatedResources struct {
|
||||
// CPURequests is number of allocated milicores.
|
||||
CPURequests int64 `json:"cpuRequests"`
|
||||
|
||||
// CPURequestsFraction is a fraction of CPU, that is allocated.
|
||||
CPURequestsFraction float64 `json:"cpuRequestsFraction"`
|
||||
|
||||
// CPULimits is defined CPU limit.
|
||||
CPULimits int64 `json:"cpuLimits"`
|
||||
|
||||
// CPULimitsFraction is a fraction of defined CPU limit, can be over 100%, i.e.
|
||||
// overcommitted.
|
||||
CPULimitsFraction float64 `json:"cpuLimitsFraction"`
|
||||
|
||||
// CPUCapacity is specified node CPU capacity in milicores.
|
||||
CPUCapacity int64 `json:"cpuCapacity"`
|
||||
|
||||
// MemoryRequests is a fraction of memory, that is allocated.
|
||||
MemoryRequests int64 `json:"memoryRequests"`
|
||||
|
||||
// MemoryRequestsFraction is a fraction of memory, that is allocated.
|
||||
MemoryRequestsFraction float64 `json:"memoryRequestsFraction"`
|
||||
|
||||
// MemoryLimits is defined memory limit.
|
||||
MemoryLimits int64 `json:"memoryLimits"`
|
||||
|
||||
// MemoryLimitsFraction is a fraction of defined memory limit, can be over 100%, i.e.
|
||||
// overcommitted.
|
||||
MemoryLimitsFraction float64 `json:"memoryLimitsFraction"`
|
||||
|
||||
// MemoryCapacity is specified node memory capacity in bytes.
|
||||
MemoryCapacity int64 `json:"memoryCapacity"`
|
||||
|
||||
// AllocatedPods in number of currently allocated pods on the node.
|
||||
AllocatedPods int `json:"allocatedPods"`
|
||||
|
||||
// PodCapacity is maximum number of pods, that can be allocated on the node.
|
||||
PodCapacity int64 `json:"podCapacity"`
|
||||
|
||||
// PodFraction is a fraction of pods, that can be allocated on given node.
|
||||
PodFraction float64 `json:"podFraction"`
|
||||
}
|
||||
|
||||
type Time struct {
|
||||
time.Time `protobuf:"-"`
|
||||
}
|
||||
|
||||
// ResourceKind is an unique name for each resource. It can used for API discovery and generic
|
||||
// code that does things based on the kind. For example, there may be a generic "deleter"
|
||||
// that based on resource kind, name and namespace deletes it.
|
||||
type ResourceKind string
|
||||
|
||||
type Unschedulable bool
|
||||
|
||||
type NodeIP string
|
||||
|
||||
type UID string
|
||||
6
apps/devops/entity/k8s/pod.go
Normal file
6
apps/devops/entity/k8s/pod.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package k8s
|
||||
|
||||
type RemovePodsData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
PodName string `json:"podName" binding:"required"`
|
||||
}
|
||||
6
apps/devops/entity/k8s/secrets.go
Normal file
6
apps/devops/entity/k8s/secrets.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package k8s
|
||||
|
||||
type SecretsData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
6
apps/devops/entity/k8s/service.go
Normal file
6
apps/devops/entity/k8s/service.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package k8s
|
||||
|
||||
type ServiceData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
12
apps/devops/entity/k8s/statefulset.go
Normal file
12
apps/devops/entity/k8s/statefulset.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package k8s
|
||||
|
||||
type StatefulSetData struct {
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
|
||||
type ScaleStatefulSet struct {
|
||||
ScaleNumber *int32 `json:"scaleNumber" binding:"required"`
|
||||
Namespace string `json:"namespace" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
66
apps/devops/entity/k8s/types.go
Normal file
66
apps/devops/entity/k8s/types.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
)
|
||||
|
||||
// NewObjectMeta returns internal endpoint name for the given service properties, e.g.,
|
||||
// NewObjectMeta creates a new instance of ObjectMeta struct based on K8s object meta.
|
||||
func NewObjectMeta(k8SObjectMeta metaV1.ObjectMeta) ObjectMeta {
|
||||
return ObjectMeta{
|
||||
Name: k8SObjectMeta.Name,
|
||||
Namespace: k8SObjectMeta.Namespace,
|
||||
Labels: k8SObjectMeta.Labels,
|
||||
CreationTimestamp: Time(k8SObjectMeta.CreationTimestamp),
|
||||
Annotations: k8SObjectMeta.Annotations,
|
||||
}
|
||||
}
|
||||
|
||||
// NewTypeMeta creates new type mete for the resource kind.
|
||||
func NewTypeMeta(kind ResourceKind) TypeMeta {
|
||||
return TypeMeta{
|
||||
Kind: kind,
|
||||
}
|
||||
}
|
||||
|
||||
// ListEverything is a list options used to list all resources without any filtering.
|
||||
var ListEverything = metaV1.ListOptions{
|
||||
LabelSelector: labels.Everything().String(),
|
||||
FieldSelector: fields.Everything().String(),
|
||||
}
|
||||
|
||||
// List of all resource kinds supported by the UI.
|
||||
const (
|
||||
ResourceKindConfigMap = "configmap"
|
||||
ResourceKindDaemonSet = "daemonset"
|
||||
ResourceKindDeployment = "deployment"
|
||||
ResourceKindEvent = "event"
|
||||
ResourceKindHorizontalPodAutoscaler = "horizontalpodautoscaler"
|
||||
ResourceKindIngress = "ingress"
|
||||
ResourceKindServiceAccount = "serviceaccount"
|
||||
ResourceKindJob = "job"
|
||||
ResourceKindCronJob = "cronjob"
|
||||
ResourceKindLimitRange = "limitrange"
|
||||
ResourceKindNamespace = "namespace"
|
||||
ResourceKindNode = "node"
|
||||
ResourceKindPersistentVolumeClaim = "persistentvolumeclaim"
|
||||
ResourceKindPersistentVolume = "persistentvolume"
|
||||
ResourceKindCustomResourceDefinition = "customresourcedefinition"
|
||||
ResourceKindPod = "pod"
|
||||
ResourceKindReplicaSet = "replicaset"
|
||||
ResourceKindReplicationController = "replicationcontroller"
|
||||
ResourceKindResourceQuota = "resourcequota"
|
||||
ResourceKindSecret = "secret"
|
||||
ResourceKindService = "service"
|
||||
ResourceKindStatefulSet = "statefulset"
|
||||
ResourceKindStorageClass = "storageclass"
|
||||
ResourceKindClusterRole = "clusterrole"
|
||||
ResourceKindClusterRoleBinding = "clusterrolebinding"
|
||||
ResourceKindRole = "role"
|
||||
ResourceKindRoleBinding = "rolebinding"
|
||||
ResourceKindPlugin = "plugin"
|
||||
ResourceKindEndpoint = "endpoint"
|
||||
ResourceKindNetworkPolicy = "networkpolicy"
|
||||
)
|
||||
Reference in New Issue
Block a user