Skip to content

Commit

Permalink
Merge pull request #597 from kthcloud/dev
Browse files Browse the repository at this point in the history
Maintenance update
  • Loading branch information
saffronjam authored May 17, 2024
2 parents edaddd1 + 034e8bc commit b10e95e
Show file tree
Hide file tree
Showing 289 changed files with 899 additions and 148,848 deletions.
22 changes: 11 additions & 11 deletions cmd/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package cmd

import (
"context"
"go-deploy/pkg/workers/cleaner"
"go-deploy/pkg/workers/confirm"
"go-deploy/pkg/workers/job_execute"
"go-deploy/pkg/workers/logger"
metricsWorker "go-deploy/pkg/workers/metrics_update"
"go-deploy/pkg/workers/repair"
"go-deploy/pkg/workers/snapshot"
"go-deploy/pkg/workers/status_update"
"go-deploy/pkg/workers/synchronize"
)
Expand Down Expand Up @@ -134,16 +134,6 @@ func GetFlags() FlagDefinitionList {
repair.Setup(ctx)
},
},
{
Name: "snapshotter",
ValueType: "bool",
FlagType: "worker",
Description: "Start snapshotter",
DefaultValue: false,
Run: func(ctx context.Context, _ context.CancelFunc) {
snapshot.Setup(ctx)
},
},
{
Name: "metrics-updater",
ValueType: "bool",
Expand All @@ -164,6 +154,16 @@ func GetFlags() FlagDefinitionList {
logger.Setup(ctx)
},
},
{
Name: "cleaner",
ValueType: "bool",
FlagType: "worker",
Description: "Start cleaner",
DefaultValue: false,
Run: func(ctx context.Context, cancel context.CancelFunc) {
cleaner.Setup(ctx)
},
},
{
Name: "mode",
ValueType: "string",
Expand Down
1 change: 1 addition & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func Create(opts *Options) *App {
{Name: "Synchronize VM ports", Task: intializer.SynchronizeVmPorts},
{Name: "Run migrations", Task: migrator.Migrate},
{Name: "Reset running jobs", Task: func() error { return job_repo.New().ResetRunning() }},
{Name: "Ensure system deployments exists", Task: intializer.EnsureSystemDeploymentsExists},
}

for idx, task := range initTasks {
Expand Down
39 changes: 24 additions & 15 deletions config.local.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
externalUrl: deploy.localhost:30291
externalUrl: http://localhost:8080
port: 8080
mode: dev

Expand All @@ -20,6 +20,7 @@ timer:
vmDeletionConfirm: 5s
smDeletionConfirm: 5s
customDomainConfirm: 30m
staleResourceCleanup: 1h

zones:
- name: local
Expand All @@ -37,22 +38,22 @@ zones:
- deployment
- vm
domains:
parentDeployment: app.deploy.localhost:30291
parentSm: storage.deploy.localhost:30291
parentVm: vm.deploy.localhost:30291
parentVmApp: vm-app.deploy.localhost:30291
parentDeployment: app.deploy.localhost:32275
parentSm: storage.deploy.localhost:32275
parentVm: vm.deploy.localhost
parentVmApp: vm-app.deploy.localhost:32275
storage:
nfsServer: 10.96.200.2
paths:
parentDeployment: /nfs/deployments
portRange:
start: 30083
end: 30108
start: 31401
end: 31426

registry:
url: localhost:30722
placeholderImage: localhost:30722/library/go-deploy-placeholder
vmHttpProxyImage: localhost:30722/library/go-deploy-placeholder
url: localhost:31276
placeholderImage: localhost:31276/library/go-deploy-placeholder
vmHttpProxyImage: localhost:31276/library/go-deploy-placeholder

gpu:
privilegedGpus:
Expand All @@ -62,11 +63,18 @@ gpu:
deployment:
defaultZone: local
port: 8080
lifetime: 2160h # 90d
prefix: deploy-
fallback:
disabled:
name: deploy-fallback

wildcardCertSecretNamespace: cert-manager
wildcardCertSecretName: go-deploy-wildcard-secret
customDomainTxtRecordSubdomain: _kthcloud

ingressClass: nginx

resources:
autoScale:
cpuThreshold: 50
Expand All @@ -81,6 +89,7 @@ deployment:

vm:
defaultZone: local
lifetime: 2160h # 90d
adminSshPublicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC3ktpoOPJP6v79i3IyY2+vd5julRDLBrMLpCAe8d4UDH09BN9PLYRAeYbox1UcHH3G+qWuf6iIY5/oxhsZlEmCbJE1wr3rVHvutuP17mcXcdVdJlQ7QOsTqI9rUTFm8XUB83CGIC36rxada3q7ndr/RhpwUtVghYK8AT57NjUjR5PI6TayKBIqlxgzamPJPcklCWoFhMzMm/8C15J1FJTejBeLuLeC6y+jtlxUGO7WDsLRS68uzpGGiS9exDkABrnb7jSU8o6rzQpIJnipIoM75530MV3Lp7sxNEgp8psaETdyPorfPv7u1nCcQV9B3RhH3SLGqzcepwt9zXixxcniVokAYvHLzpxcRg6bSoqWvJHM97fe8hDwa36Jck6hdfSGDxVon49E1qfG4FB4JYwwX2ehnuc3zW/bP+VuwFC+Fr/9zJMXiSGKSnIQKrMWqWbUse3r7kzUCLJ3PACCjGRR74LmhPODzPv3Zc5sz5cGFzOR2bNgUEUB1NK0Cw7GaO8= emil@home
image: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img

Expand Down Expand Up @@ -132,19 +141,19 @@ roles:
gpuLeaseDuration: 168

keycloak:
url: http://keycloak.deploy.localhost:31133
url: http://keycloak.deploy.localhost:31125
realm: master
adminGroup: admin
storageClient:
clientId: go-deploy-storage
clientSecret: I6qfVJPv2NBkpStihOYO6SOS8mh8VKSU
clientSecret: CHy186Qo2tLScpN5s5tarVjb24Phizgm

mongodb:
url: mongodb://admin:admin@localhost:31961
url: mongodb://admin:admin@localhost:31536
name: deploy

redis:
url: localhost:31871
url: localhost:30702
password:

sys-api:
Expand All @@ -155,7 +164,7 @@ sys-api:
useMock: true

harbor:
url: http://harbor.deploy.localhost:30722
url: http://harbor.deploy.localhost:31276
user: admin
password: Harbor12345
webhookSecret: secret
5 changes: 4 additions & 1 deletion dto/v1/body/deployment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package body

import "time"
import (
"time"
)

type DeploymentRead struct {
ID string `json:"id"`
Expand All @@ -13,6 +15,7 @@ type DeploymentRead struct {
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
RepairedAt *time.Time `json:"repairedAt,omitempty"`
RestartedAt *time.Time `json:"restartedAt,omitempty"`
AccessedAt time.Time `json:"accessedAt"`

CpuCores float64 `json:"cpuCores"`
RAM float64 `json:"ram"`
Expand Down
28 changes: 0 additions & 28 deletions dto/v1/body/gpu.go

This file was deleted.

62 changes: 51 additions & 11 deletions dto/v1/body/resource_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,30 @@ package body
import "time"

type ResourceMigrationRead struct {
ID string `json:"id"`
ID string `json:"id"`
// ResourceID is the ID of the resource that is being migrated.
// This can be a VM ID, deployment ID, etc. depending on the type of the migration.
ResourceID string `json:"resourceId"`
UserID string `json:"userId"`
// UserID is the ID of the user who initiated the migration.
UserID string `json:"userId"`

Type string `json:"type"`
// Type is the type of the resource migration.
//
// Possible values:
// - updateOwner
Type string `json:"type"`
// ResourceType is the type of the resource that is being migrated.
//
// Possible values:
// - vm
// - deployment
ResourceType string `json:"resourceType"`
Status string `json:"status"`
// Status is the status of the resource migration.
// When this field is set to 'accepted', the migration will take place and then automatically be deleted.
Status string `json:"status"`

// UpdateOwner is the set of parameters that are required for the updateOwner migration type.
// It is empty if the migration type is not updateOwner.
UpdateOwner *struct {
OwnerID string `json:"ownerId"`
} `json:"updateOwner,omitempty"`
Expand All @@ -20,32 +36,56 @@ type ResourceMigrationRead struct {
}

type ResourceMigrationCreate struct {
Type string `json:"type" binding:"required"`
ResourceID string `json:"resourceID" binding:"required,uuid4"`
Status *string `json:"status"`
// Type is the type of the resource migration.
//
// Possible values:
// - updateOwner
Type string `json:"type" binding:"required,oneof=updateOwner"`
// ResourceID is the ID of the resource that is being migrated.
// This can be a VM ID, deployment ID, etc. depending on the type of the migration.
ResourceID string `json:"resourceId" binding:"required,uuid4"`
// Status is the status of the resource migration.
// It is used by privileged admins to directly accept or reject a migration.
// The field is ignored by non-admins.
//
// Possible values:
// - accepted
// - pending
Status *string `json:"status"`

// UpdateOwner is the set of parameters that are required for the updateOwner migration type.
// It is ignored if the migration type is not updateOwner.
UpdateOwner *struct {
OwnerID string `json:"ownerId" binding:"required,uuid4"`
} `json:"updateOwner,omitempty"`
}

type ResourceMigrationUpdate struct {
Status string `json:"status" binding:"required"`
Code *string `json:"code,omitempty"`
// Status is the status of the resource migration.
// It is used to accept a migration by setting the status to 'accepted'.
// If the acceptor is not an admin, a Code must be provided.
//
// Possible values:
// - accepted
// - pending
Status string `json:"status" binding:"required"`
// Code is a token required when accepting a migration if the acceptor is not an admin.
// It is sent to the acceptor using the notification API
Code *string `json:"code,omitempty"`
}

type ResourceMigrationCreated struct {
ResourceMigrationRead `json:",inline" tstype:",extends"`

// JobID is the ID of the job that was created for the resource migration.
// Only if the migration was created with status 'accepted' a job will be created.
// It will only be set if the migration was created with status 'accepted'.
JobID *string `json:"jobId,omitempty"`
}

type ResourceMigrationUpdated struct {
ResourceMigrationRead `json:",inline" tstype:",extends"`

// JobID is the ID of the job that was created for the resource migration.
// Only if the migration was updated with status 'accepted' a job will be created.
// It will only be set if the migration was updated with status 'accepted'.
JobID *string `json:"jobId,omitempty"`
}
7 changes: 3 additions & 4 deletions dto/v1/body/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ type Quota struct {
}

type Usage struct {
CpuCores float64 `json:"cpuCores"`
RAM float64 `json:"ram"`
DiskSize float64 `json:"diskSize"`
Snapshots int `json:"snapshots"`
CpuCores float64 `json:"cpuCores"`
RAM float64 `json:"ram"`
DiskSize int `json:"diskSize"`
}
Loading

0 comments on commit b10e95e

Please sign in to comment.