feat: add k8s cluster resource management module
- Add K8s module with kubeconfig storage in cluster_config table - Implement resource list APIs for 8 kinds: namespace, deployment, statefulset, service, configmap, pod, pv, pvc - Add K8sResourceList page with sidebar navigation and resource tables - Support YAML upload/input dialog for resource creation via dynamic client - Add kubeconfig settings drawer - Increase main content width from lg to xl for better table display - Add navigation link for cluster resources in top bar 🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/middleware"
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/model"
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/module/k8s"
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/module/registry"
|
||||
"gitea.loveuer.com/loveuer/cluster/pkg/store"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
@@ -36,6 +37,11 @@ func Init(ctx context.Context, address string, db *gorm.DB, store store.Store) (
|
||||
log.Printf("Warning: failed to migrate RegistryConfig: %v", err)
|
||||
}
|
||||
|
||||
// Initialize k8s module
|
||||
if err := k8s.Init(ctx, db, store); err != nil {
|
||||
log.Printf("Warning: failed to initialize k8s module: %v", err)
|
||||
}
|
||||
|
||||
// oci image apis
|
||||
{
|
||||
app.All("/v2/*", registry.Registry(ctx, db, store))
|
||||
@@ -53,6 +59,25 @@ func Init(ctx context.Context, address string, db *gorm.DB, store store.Store) (
|
||||
registryAPI.Post("/config", registry.RegistryConfigSet(ctx, db, store))
|
||||
}
|
||||
|
||||
// k8s cluster apis
|
||||
{
|
||||
k8sAPI := app.Group("/api/v1/k8s")
|
||||
// cluster config
|
||||
k8sAPI.Get("/config", k8s.ClusterConfigGet(ctx, db, store))
|
||||
k8sAPI.Post("/config", k8s.ClusterConfigSet(ctx, db, store))
|
||||
// resource operations
|
||||
k8sAPI.Post("/resource/apply", k8s.K8sResourceApply(ctx, db, store))
|
||||
// resource list
|
||||
k8sAPI.Get("/namespace/list", k8s.K8sNamespaceList(ctx, db, store))
|
||||
k8sAPI.Get("/deployment/list", k8s.K8sDeploymentList(ctx, db, store))
|
||||
k8sAPI.Get("/statefulset/list", k8s.K8sStatefulSetList(ctx, db, store))
|
||||
k8sAPI.Get("/configmap/list", k8s.K8sConfigMapList(ctx, db, store))
|
||||
k8sAPI.Get("/pod/list", k8s.K8sPodList(ctx, db, store))
|
||||
k8sAPI.Get("/pv/list", k8s.K8sPVList(ctx, db, store))
|
||||
k8sAPI.Get("/pvc/list", k8s.K8sPVCList(ctx, db, store))
|
||||
k8sAPI.Get("/service/list", k8s.K8sServiceList(ctx, db, store))
|
||||
}
|
||||
|
||||
ln, err = net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
return fn, fmt.Errorf("failed to listen on %s: %w", address, err)
|
||||
|
||||
Reference in New Issue
Block a user