Compare commits
10 Commits
720e6914fb
...
fbc48792bf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbc48792bf | ||
|
|
44c75b2f5c | ||
|
|
98481d56eb | ||
|
|
08d17a33ea | ||
|
|
b82db8e0b1 | ||
|
|
06b7aaa548 | ||
|
|
36a36a232f | ||
|
|
821ead675f | ||
|
|
d3df2b60f0 | ||
|
|
930d3282e5 |
Binary file not shown.
Submodule application updated: bfd802911d...1fd625e22d
@@ -61,8 +61,8 @@ var (
|
||||
|
||||
func InitializeClient() {
|
||||
once.Do(func() {
|
||||
argocdServer := "192.168.2.172:32200"
|
||||
argocdToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjphcGlLZXkiLCJuYmYiOjE3NDM4NTAwNzIsImlhdCI6MTc0Mzg1MDA3MiwianRpIjoiNWZhNmQ5MDgtMzljNi00ZWQ4LWE5YzgtMzI4YzMzYjkyNzk4In0.ZvhJk4L5vBQldtJyReKYXCQCWF8j8gHLZlY8PninSFA"
|
||||
argocdServer := "130.185.77.247:30966"
|
||||
argocdToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjphcGlLZXkiLCJuYmYiOjE3NjAwMjE1NjAsImlhdCI6MTc2MDAyMTU2MCwianRpIjoiZTdjMzMyNWQtZDU0Yy00M2Q0LWIzOGYtYjc3NGQ4OTcxZGZmIn0.35lU-UOwl3XxjvqEfnEXIhaVoug90-J2WWj5x0OihC0"
|
||||
|
||||
config := apiclient.ClientOptions{
|
||||
ServerAddr: argocdServer,
|
||||
@@ -105,10 +105,10 @@ func CreateApp(objectID string, clustername string, ControlPlane string, Platfor
|
||||
app := ApplicationValues{
|
||||
Name: uniqueClusterName,
|
||||
Namespace: namespace,
|
||||
Path: "vcluster-0.21.1",
|
||||
Cluster: "bugx",
|
||||
Path: "vcluster-0.28.0",
|
||||
Cluster: "in-cluster",
|
||||
Server: "https://kubernetes.default.svc",
|
||||
RepoURL: "http://192.168.2.20:8015/root/application.git",
|
||||
RepoURL: "http://130.185.77.247:31300/gitea_admin/application.git",
|
||||
UserID: userID,
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ func updateConfig(objectID string, configStrings string, namespace string) {
|
||||
"$set": bson.M{
|
||||
"cluster_config": configStrings,
|
||||
"namespace": namespace,
|
||||
"EndPoine": "https://" + namespace + ".bugx.ir",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -365,6 +366,7 @@ func ListUserClusters(userID string) (error, []Clusters) {
|
||||
Name: app.Name,
|
||||
Status: string(app.Status.Health.Status),
|
||||
ClusterID: strings.Split(string(app.ObjectMeta.UID), "-")[0],
|
||||
EndPoint: "https://" + app.Spec.Destination.Namespace + ".bugx.ir",
|
||||
}
|
||||
clusters = append(clusters, newCluster)
|
||||
}
|
||||
|
||||
7
db/db.go
7
db/db.go
@@ -9,12 +9,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Client *mongo.Client
|
||||
UserCollection, Vclusters_details, Host_cluster_details *mongo.Collection
|
||||
Client *mongo.Client
|
||||
UserCollection, Vclusters_details, Host_cluster_details, Worker_nodes_plan *mongo.Collection
|
||||
)
|
||||
|
||||
func InitDB() {
|
||||
clientOptions := options.Client().ApplyURI("mongodb://root:example@localhost:27017/")
|
||||
clientOptions := options.Client().ApplyURI("mongodb://root:secret123@130.185.77.247:32669/")
|
||||
client, err := mongo.Connect(context.TODO(), clientOptions)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -23,4 +23,5 @@ func InitDB() {
|
||||
UserCollection = client.Database("vcluster").Collection("users")
|
||||
Vclusters_details = client.Database("vcluster").Collection("vclusters_details")
|
||||
Host_cluster_details = client.Database("vcluster").Collection("hostdetail")
|
||||
Worker_nodes_plan = client.Database("vcluster").Collection("worker_nodes_plans")
|
||||
}
|
||||
|
||||
2664
handler/handler.go
2664
handler/handler.go
File diff suppressed because it is too large
Load Diff
49
main.go
49
main.go
@@ -128,10 +128,18 @@ func main() {
|
||||
router.HandleFunc("/createcluster", handler.CreateClusterHandler)
|
||||
router.HandleFunc("/deletecluster", handler.Deletecluster)
|
||||
router.HandleFunc("/clusters", handler.ListUserClusters)
|
||||
router.HandleFunc("/cluster_stats", handler.ClusterStats)
|
||||
router.HandleFunc("/cluster_resource_usage", handler.Cluster_resource_usage)
|
||||
router.HandleFunc("/cluster_health", handler.Cluster_health)
|
||||
router.HandleFunc("/cluster_uptime", handler.Cluster_uptime)
|
||||
router.HandleFunc("/cluster_performance", handler.Cluster_performance)
|
||||
router.HandleFunc("/cluster_events", handler.Cluster_events)
|
||||
router.HandleFunc("/connect", handler.Connect)
|
||||
// router.HandleFunc("/cluster_nodes", handler.Cluster_nodes)
|
||||
router.HandleFunc("/cluster_namespaces", handler.Cluster_namespaces)
|
||||
router.HandleFunc("/cluster_services", handler.Cluster_services)
|
||||
router.HandleFunc("/cluster_configmap", handler.Cluster_configmap)
|
||||
router.HandleFunc("/cluster_secret", handler.Cluster_secret)
|
||||
router.HandleFunc("/cluster_deployments", handler.Cluster_deployments)
|
||||
router.HandleFunc("/cluster_pods", handler.Cluster_pods)
|
||||
router.HandleFunc("/cluster_statefulset", handler.Cluster_statefulset)
|
||||
@@ -139,19 +147,56 @@ func main() {
|
||||
|
||||
router.HandleFunc("/cluster_jobs", handler.Cluster_jobs)
|
||||
router.HandleFunc("/cluster_replicasets", handler.Cluster_replicasets)
|
||||
router.HandleFunc("/replicaset_delete", handler.Replicaset_delete)
|
||||
router.HandleFunc("/cluster_replicationcontrollers", handler.Cluster_replicationcontrollers)
|
||||
|
||||
router.HandleFunc("/deployment_manifest", handler.Deployment_manifest)
|
||||
router.HandleFunc("/daemonsets_manifest", handler.DaemonSet_manifest)
|
||||
router.HandleFunc("/statefulset_manifest", handler.StatefulSet_manifest)
|
||||
router.HandleFunc("/replicationcontroller_manifest", handler.Replicationcontroller_manifest)
|
||||
router.HandleFunc("/deployment_rollout", handler.Deployment_rollout)
|
||||
router.HandleFunc("/daemonsets_rollout", handler.DaemonSet_rollout)
|
||||
router.HandleFunc("/deployment_scale", handler.Deployment_scale)
|
||||
router.HandleFunc("/replicaset_scale", handler.ReplicaSet_scale)
|
||||
router.HandleFunc("/statefulset_scale", handler.StatefulSet_scale)
|
||||
router.HandleFunc("/replicationcontroller_scale", handler.Replicationcontroller_scale)
|
||||
router.HandleFunc("/statefulset_rollout", handler.StatefulSet_rollout)
|
||||
router.HandleFunc("/pod_logs", handler.Pod_logs)
|
||||
router.HandleFunc("/pod_manifest", handler.Pod_manifest)
|
||||
router.HandleFunc("/replicaset_manifest", handler.Replicaset_manifest)
|
||||
router.HandleFunc("/jobs_manifest", handler.Jobs_manifest)
|
||||
router.HandleFunc("/cronjobs_manifest", handler.CronJobs_manifest)
|
||||
router.HandleFunc("/configmap_manifest", handler.ConfigMap_manifest)
|
||||
router.HandleFunc("/secret_manifest", handler.Secret_manifest)
|
||||
router.HandleFunc("/service_manifest", handler.Service_manifest)
|
||||
router.HandleFunc("/cronjobs_trigger", handler.Cronjobs_trigger)
|
||||
router.HandleFunc("/cronjobs_suspend", handler.Cronjobs_suspend)
|
||||
router.HandleFunc("/jobs_logs", handler.Jobs_logs)
|
||||
router.HandleFunc("/pod_create", handler.Pod_fromYaml)
|
||||
router.HandleFunc("/deployment_create", handler.Deployment_fromYaml)
|
||||
router.HandleFunc("/daemonsets_create", handler.DaemonSet_fromYaml)
|
||||
router.HandleFunc("/jobs_create", handler.Job_fromYaml)
|
||||
router.HandleFunc("/statefulset_create", handler.StatefulSet_fromYaml)
|
||||
router.HandleFunc("/configmap_create", handler.ConfigMap_fromYaml)
|
||||
router.HandleFunc("/secret_create", handler.Secret_fromYaml)
|
||||
router.HandleFunc("/service_create", handler.Service_fromYaml)
|
||||
router.HandleFunc("/pod_exec", handler.Pod_exec)
|
||||
router.HandleFunc("/pod_delete", handler.Pod_delete)
|
||||
router.HandleFunc("/service_delete", handler.Service_delete)
|
||||
router.HandleFunc("/configmap_delete", handler.Configmap_delete)
|
||||
router.HandleFunc("/secret_delete", handler.Secret_delete)
|
||||
router.HandleFunc("/deployment_delete", handler.Deployment_delete)
|
||||
router.HandleFunc("/statefulSet_delete", handler.StatefulSet_delete)
|
||||
router.HandleFunc("/daemonsets_delete", handler.Daemonsets_delete)
|
||||
router.HandleFunc("/jobsName_delete", handler.JobsName_delete)
|
||||
router.HandleFunc("/replicaset_delete", handler.Replicaset_delete)
|
||||
router.HandleFunc("/replicationcontroller_delete", handler.Replicationcontroller_delete)
|
||||
router.HandleFunc("/cronjob_delete", handler.Cronjob_delete)
|
||||
router.HandleFunc("/cronjobs_delete", handler.Cronjob_delete)
|
||||
router.HandleFunc("/cronjobs_create", handler.CronJob_fromYaml)
|
||||
router.HandleFunc("/cluster_cronjobs", handler.Cluster_cronjobs)
|
||||
router.HandleFunc("/replicationcontroller_create", handler.ReplicationController_fromYaml)
|
||||
router.HandleFunc("/replicationcontroller_migrate", handler.Replicationcontroller_migrate)
|
||||
router.HandleFunc("/helm_install", handler.Helm_install)
|
||||
router.HandleFunc("/worker_nodes_plan", handler.Worker_nodes_plan)
|
||||
//handler.RegsiterClusterRoute(router)
|
||||
// Enable CORS
|
||||
// c := cors.New(cors.Options{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
@@ -14,24 +16,45 @@ type Cluster struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
ControlPlane string `json:"controlPlane"`
|
||||
PlatformVersion string `json:"platformversion`
|
||||
PlatformVersion string `json:"platformversion"`
|
||||
Cpu string `json:"cpu"`
|
||||
Memory string `json:"memory"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UserID primitive.ObjectID `json:"userId"`
|
||||
Cluster_config string `json:"clusterconfig"`
|
||||
EndPoint string `json:"endPoint"`
|
||||
}
|
||||
|
||||
type Header struct {
|
||||
Authorization string `bson:"token"`
|
||||
}
|
||||
|
||||
type Namespace struct {
|
||||
Name string `json:name`
|
||||
Status string `json:status`
|
||||
Age string `json:age`
|
||||
}
|
||||
|
||||
type PodLog struct {
|
||||
Podname string `json:name`
|
||||
Namespace string `json:namespace`
|
||||
Clustername string `json:clustername`
|
||||
Manifest string `json:clustername`
|
||||
Replicasetname string `json:replicasetname`
|
||||
Statefulset string `json:Statefulset`
|
||||
Daemonsetsname string `json:Daemonsetsname`
|
||||
}
|
||||
|
||||
type Pod struct {
|
||||
Name string `json:name`
|
||||
Namespace string `json:name`
|
||||
Namespace string `json:namespace`
|
||||
Status string `json:status`
|
||||
Restart int32 `json:restart`
|
||||
Age string `json:age`
|
||||
Ready string `json:ready`
|
||||
Restarts int32 `json:restars`
|
||||
Ip string `json:ip`
|
||||
Node string `json:node`
|
||||
Image string `json:iamge`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
@@ -45,12 +68,17 @@ type Service struct {
|
||||
}
|
||||
|
||||
type Deployment struct {
|
||||
Name string `json:name`
|
||||
Namespace string `json:namespace`
|
||||
Available string `json:available`
|
||||
Replicas int32 `json:replicas`
|
||||
Message string `json:message`
|
||||
Reason string `json:reason`
|
||||
Name string `json:name`
|
||||
Namespace string `json:namespace`
|
||||
Available string `json:available`
|
||||
Replicas int32 `json:replicas`
|
||||
Message string `json:message`
|
||||
Reason string `json:reason`
|
||||
Ready string `json:ready`
|
||||
UpdateToDate int32 `json:uptodate`
|
||||
Age string `json:age`
|
||||
Image string `json:iamge`
|
||||
Strategy string `json:iamge`
|
||||
}
|
||||
|
||||
type Daemonset struct {
|
||||
@@ -75,6 +103,16 @@ type Jobs struct {
|
||||
Age string `json:age`
|
||||
}
|
||||
|
||||
type CronJob struct {
|
||||
Name string `json:name`
|
||||
Namespace string `json:namespace`
|
||||
Schedule string `json:schedule`
|
||||
Suspend bool `json:suspend`
|
||||
Active int `json:active`
|
||||
LastScheduleTime string `json:lastScheduleTime`
|
||||
Age string `json:age`
|
||||
}
|
||||
|
||||
type Replicaset struct {
|
||||
Name string `json:name`
|
||||
Desired int32 `json:desired`
|
||||
@@ -99,3 +137,121 @@ type StatefulSet struct {
|
||||
Ready string `json:Ready`
|
||||
Age string `json:age`
|
||||
}
|
||||
|
||||
type WorkerNodesPlans struct {
|
||||
Plan string `json:plan`
|
||||
Cpu string `json:cpu`
|
||||
Memory string `json:memory`
|
||||
Storage string `;sjon:storage`
|
||||
}
|
||||
|
||||
type ClusterStats struct {
|
||||
ResourceUsage ResourceUsage `json:"resourceUsage"`
|
||||
Performance Performance `json:"performance"`
|
||||
Health Health `json:"health"`
|
||||
Uptime Uptime `json:"uptime"`
|
||||
Name string `json:"name"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Alerts string `json:"alerts"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
}
|
||||
|
||||
type ResourceUsage struct {
|
||||
CPU Usage `json:"cpu"`
|
||||
Memory Usage `json:"memory"`
|
||||
Storage Usage `json:"storage"`
|
||||
Network Usage `json:"network"`
|
||||
}
|
||||
|
||||
type Usage struct {
|
||||
Used float64 `json:"used"`
|
||||
Total float64 `json:"total"`
|
||||
Unit string `json:"unit"`
|
||||
}
|
||||
|
||||
type Performance struct {
|
||||
PodStartupTime string `json:"podStartupTime"`
|
||||
APILatency string `json:"apiLatency"`
|
||||
EtcdLatency string `json:"etcdLatency"`
|
||||
SchedulerLatency string `json:"schedulerLatency"`
|
||||
}
|
||||
|
||||
type Health struct {
|
||||
NodesHealthy int `json:"nodesHealthy"`
|
||||
NodesTotal int `json:"nodesTotal"`
|
||||
PodsRunning int `json:"podsRunning"`
|
||||
PodsTotal int `json:"podsTotal"`
|
||||
Alerts int `json:"alerts"`
|
||||
Warnings int `json:"warnings"`
|
||||
Status string `json:"healthy"`
|
||||
}
|
||||
|
||||
type Uptime struct {
|
||||
ClusterUptime string `json:"clusterUptime"`
|
||||
LastMaintenance string `json:"lastMaintenance"`
|
||||
NextMaintenance string `json:"nextMaintenance"`
|
||||
}
|
||||
|
||||
type ReplicasetScaleReq struct {
|
||||
Clustername string `json:"Clustername"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Replicasetname string `json:"Replicasetname"`
|
||||
Replicas int32 `json:"Replicas"`
|
||||
}
|
||||
|
||||
type ReplicasetRolloutReq struct {
|
||||
Clustername string `json:"Clustername"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Replicasetname string `json:"Replicasetname"`
|
||||
Action string `json:"Action"` // "restart" | "status"
|
||||
}
|
||||
|
||||
type DeploymentScaleReq struct {
|
||||
Clustername string `json:"Clustername"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Deployment string `json:"Deployment"`
|
||||
Replicas int32 `json:"Replicas"`
|
||||
}
|
||||
|
||||
type DeploymentRolloutReq struct {
|
||||
Clustername string `json:"Clustername"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Deployment string `json:"Deployment"`
|
||||
Action string `json:"Action"` // "restart" | "status"
|
||||
}
|
||||
|
||||
type DeamonSetsRolloutReq struct {
|
||||
Clustername string `json:"Clustername"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Daemonsetsname string `json:"Daemonsetsname"`
|
||||
Action string `json:"Action"` // "restart" | "status"
|
||||
}
|
||||
|
||||
type StatefulsetRolloutReq struct {
|
||||
Clustername string `json:"Clustername"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Statefulset string `json:"Statefulset"`
|
||||
Action string `json:"Action"` // "restart" | "status"
|
||||
Replicas int32 `json:"Replicas"`
|
||||
}
|
||||
|
||||
type DeploymentRolloutStatus struct {
|
||||
Deployment string `json:"deployment"`
|
||||
Namespace string `json:"namespace"`
|
||||
ObservedGeneration int64 `json:"observedGeneration"`
|
||||
Replicas int32 `json:"replicas"`
|
||||
UpdatedReplicas int32 `json:"updatedReplicas"`
|
||||
ReadyReplicas int32 `json:"readyReplicas"`
|
||||
AvailableReplicas int32 `json:"availableReplicas"`
|
||||
UnavailableReplicas int32 `json:"unavailableReplicas"`
|
||||
ConditionProgressing string `json:"conditionProgressing,omitempty"`
|
||||
ConditionAvailable string `json:"conditionAvailable,omitempty"`
|
||||
}
|
||||
|
||||
type DeploymentRolloutResp struct {
|
||||
Clustername string `json:"cluster"`
|
||||
Message string `json:"message"`
|
||||
Status *DeploymentRolloutStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user