mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
refactor(k8s): namespace core logic (#12142)
Co-authored-by: testA113 <aliharriss1995@gmail.com> Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io> Co-authored-by: James Carppe <85850129+jamescarppe@users.noreply.github.com> Co-authored-by: Ali <83188384+testA113@users.noreply.github.com>
This commit is contained in:
parent
da010f3d08
commit
ea228c3d6d
276 changed files with 9241 additions and 3361 deletions
|
@ -1,11 +1,77 @@
|
|||
package kubernetes
|
||||
|
||||
type (
|
||||
K8sApplication struct {
|
||||
UID string `json:",omitempty"`
|
||||
Name string `json:""`
|
||||
Namespace string `json:",omitempty"`
|
||||
Kind string `json:",omitempty"`
|
||||
Labels map[string]string `json:",omitempty"`
|
||||
}
|
||||
import (
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
type K8sApplication struct {
|
||||
ID string `json:"Id"`
|
||||
Name string `json:"Name"`
|
||||
Image string `json:"Image"`
|
||||
Containers []interface{} `json:"Containers,omitempty"`
|
||||
Services []corev1.Service `json:"Services"`
|
||||
CreationDate time.Time `json:"CreationDate"`
|
||||
ApplicationOwner string `json:"ApplicationOwner,omitempty"`
|
||||
StackName string `json:"StackName,omitempty"`
|
||||
ResourcePool string `json:"ResourcePool"`
|
||||
ApplicationType string `json:"ApplicationType"`
|
||||
Metadata *Metadata `json:"Metadata,omitempty"`
|
||||
Status string `json:"Status"`
|
||||
TotalPodsCount int `json:"TotalPodsCount"`
|
||||
RunningPodsCount int `json:"RunningPodsCount"`
|
||||
DeploymentType string `json:"DeploymentType"`
|
||||
Pods []Pod `json:"Pods,omitempty"`
|
||||
Configurations []Configuration `json:"Configurations,omitempty"`
|
||||
LoadBalancerIPAddress string `json:"LoadBalancerIPAddress,omitempty"`
|
||||
PublishedPorts []PublishedPort `json:"PublishedPorts,omitempty"`
|
||||
Namespace string `json:"Namespace,omitempty"`
|
||||
UID string `json:"Uid,omitempty"`
|
||||
StackID string `json:"StackId,omitempty"`
|
||||
ServiceID string `json:"ServiceId,omitempty"`
|
||||
ServiceName string `json:"ServiceName,omitempty"`
|
||||
ServiceType string `json:"ServiceType,omitempty"`
|
||||
Kind string `json:"Kind,omitempty"`
|
||||
MatchLabels map[string]string `json:"MatchLabels,omitempty"`
|
||||
Labels map[string]string `json:"Labels,omitempty"`
|
||||
Resource K8sApplicationResource `json:"Resource,omitempty"`
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
Labels map[string]string `json:"labels"`
|
||||
}
|
||||
|
||||
type Pod struct {
|
||||
Status string `json:"Status"`
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
Data map[string]interface{} `json:"Data,omitempty"`
|
||||
Kind string `json:"Kind"`
|
||||
ConfigurationOwner string `json:"ConfigurationOwner"`
|
||||
}
|
||||
|
||||
type PublishedPort struct {
|
||||
IngressRules []IngressRule `json:"IngressRules"`
|
||||
Port int `json:"Port"`
|
||||
}
|
||||
|
||||
type IngressRule struct {
|
||||
Host string `json:"Host"`
|
||||
IP string `json:"IP"`
|
||||
Path string `json:"Path"`
|
||||
TLS []TLSInfo `json:"TLS"`
|
||||
}
|
||||
|
||||
type TLSInfo struct {
|
||||
Hosts []string `json:"hosts"`
|
||||
}
|
||||
|
||||
// Existing types
|
||||
type K8sApplicationResource struct {
|
||||
CPURequest int64 `json:"CpuRequest"`
|
||||
CPULimit int64 `json:"CpuLimit"`
|
||||
MemoryRequest int64 `json:"MemoryRequest"`
|
||||
MemoryLimit int64 `json:"MemoryLimit"`
|
||||
}
|
||||
|
|
16
api/http/models/kubernetes/cluster_role_bindings.go
Normal file
16
api/http/models/kubernetes/cluster_role_bindings.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sClusterRoleBinding struct {
|
||||
Name string `json:"name"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
Subjects []rbacv1.Subject `json:"subjects"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
}
|
||||
)
|
8
api/http/models/kubernetes/cluster_roles.go
Normal file
8
api/http/models/kubernetes/cluster_roles.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package kubernetes
|
||||
|
||||
import "time"
|
||||
|
||||
type K8sClusterRole struct {
|
||||
Name string `json:"name"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package kubernetes
|
||||
|
||||
type (
|
||||
K8sConfigMapOrSecret struct {
|
||||
UID string `json:"UID"`
|
||||
Name string `json:"Name"`
|
||||
Namespace string `json:"Namespace"`
|
||||
CreationDate string `json:"CreationDate"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
Data map[string]string `json:"Data"`
|
||||
Applications []string `json:"Applications"`
|
||||
IsSecret bool `json:"IsSecret"`
|
||||
|
||||
// SecretType will be an empty string for config maps.
|
||||
SecretType string `json:"SecretType"`
|
||||
}
|
||||
)
|
32
api/http/models/kubernetes/configuration.go
Normal file
32
api/http/models/kubernetes/configuration.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package kubernetes
|
||||
|
||||
type (
|
||||
K8sConfigMap struct {
|
||||
K8sConfiguration
|
||||
}
|
||||
|
||||
K8sSecret struct {
|
||||
K8sConfiguration
|
||||
SecretType string `json:"SecretType"`
|
||||
}
|
||||
|
||||
K8sConfiguration struct {
|
||||
UID string `json:"UID"`
|
||||
Name string `json:"Name"`
|
||||
Namespace string `json:"Namespace"`
|
||||
CreationDate string `json:"CreationDate"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
Data map[string]string `json:"Data"`
|
||||
IsUsed bool `json:"IsUsed"`
|
||||
Labels map[string]string `json:"Labels"`
|
||||
ConfigurationOwnerResources []K8sConfigurationOwnerResource `json:"ConfigurationOwners"`
|
||||
ConfigurationOwner string `json:"ConfigurationOwner"`
|
||||
ConfigurationOwnerId string `json:"ConfigurationOwnerId"`
|
||||
}
|
||||
|
||||
K8sConfigurationOwnerResource struct {
|
||||
Id string `json:"Id"`
|
||||
Name string `json:"Name"`
|
||||
ResourceKind string `json:"ResourceKind"`
|
||||
}
|
||||
)
|
|
@ -44,6 +44,7 @@ type (
|
|||
Port int `json:"Port"`
|
||||
Path string `json:"Path"`
|
||||
PathType string `json:"PathType"`
|
||||
HasService bool `json:"HasService"`
|
||||
}
|
||||
|
||||
// K8sIngressDeleteRequests is a mapping of namespace names to a slice of
|
||||
|
|
17
api/http/models/kubernetes/role_bindings.go
Normal file
17
api/http/models/kubernetes/role_bindings.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sRoleBinding struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
Subjects []rbacv1.Subject `json:"subjects"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
}
|
||||
)
|
9
api/http/models/kubernetes/roles.go
Normal file
9
api/http/models/kubernetes/roles.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package kubernetes
|
||||
|
||||
import "time"
|
||||
|
||||
type K8sRole struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
}
|
9
api/http/models/kubernetes/service_accounts.go
Normal file
9
api/http/models/kubernetes/service_accounts.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package kubernetes
|
||||
|
||||
import "time"
|
||||
|
||||
type K8sServiceAccount struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
}
|
|
@ -7,16 +7,16 @@ import (
|
|||
|
||||
type (
|
||||
K8sServiceInfo struct {
|
||||
Name string
|
||||
UID string
|
||||
Type string
|
||||
Namespace string
|
||||
Annotations map[string]string
|
||||
CreationTimestamp string
|
||||
Labels map[string]string
|
||||
AllocateLoadBalancerNodePorts *bool `json:",omitempty"`
|
||||
Ports []K8sServicePort
|
||||
Selector map[string]string
|
||||
Name string `json:",omitempty"`
|
||||
UID string `json:",omitempty"`
|
||||
Type string `json:",omitempty"`
|
||||
Namespace string `json:",omitempty"`
|
||||
Annotations map[string]string `json:",omitempty"`
|
||||
CreationDate string `json:",omitempty"`
|
||||
Labels map[string]string `json:",omitempty"`
|
||||
AllocateLoadBalancerNodePorts *bool `json:",omitempty"`
|
||||
Ports []K8sServicePort `json:",omitempty"`
|
||||
Selector map[string]string `json:",omitempty"`
|
||||
IngressStatus []K8sServiceIngress `json:",omitempty"`
|
||||
|
||||
// serviceList screen
|
||||
|
|
49
api/http/models/kubernetes/volumes.go
Normal file
49
api/http/models/kubernetes/volumes.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sVolumeInfo struct {
|
||||
PersistentVolume K8sPersistentVolume `json:"persistentVolume"`
|
||||
PersistentVolumeClaim K8sPersistentVolumeClaim `json:"persistentVolumeClaim"`
|
||||
StorageClass K8sStorageClass `json:"storageClass"`
|
||||
}
|
||||
|
||||
K8sPersistentVolume struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
|
||||
Capacity corev1.ResourceList `json:"capacity"`
|
||||
ClaimRef *corev1.ObjectReference `json:"claimRef"`
|
||||
StorageClassName string `json:"storageClassName,omitempty"`
|
||||
PersistentVolumeReclaimPolicy corev1.PersistentVolumeReclaimPolicy `json:"persistentVolumeReclaimPolicy"`
|
||||
VolumeMode *corev1.PersistentVolumeMode `json:"volumeMode"`
|
||||
CSI *corev1.CSIPersistentVolumeSource `json:"csi,omitempty"`
|
||||
}
|
||||
|
||||
K8sPersistentVolumeClaim struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
Storage int64 `json:"storage"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
|
||||
VolumeName string `json:"volumeName"`
|
||||
ResourcesRequests *corev1.ResourceList `json:"resourcesRequests"`
|
||||
StorageClass *string `json:"storageClass"`
|
||||
VolumeMode *corev1.PersistentVolumeMode `json:"volumeMode"`
|
||||
OwningApplications []K8sApplication `json:"owningApplications,omitempty"`
|
||||
Phase corev1.PersistentVolumeClaimPhase `json:"phase"`
|
||||
}
|
||||
|
||||
K8sStorageClass struct {
|
||||
Name string `json:"name"`
|
||||
Provisioner string `json:"provisioner"`
|
||||
ReclaimPolicy *corev1.PersistentVolumeReclaimPolicy `json:"reclaimPolicy"`
|
||||
AllowVolumeExpansion *bool `json:"allowVolumeExpansion"`
|
||||
}
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue