Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy store app #164

Merged
merged 31 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b633377
deploy store app
anil-intelops Aug 13, 2023
3dd88d4
deploy store app
anil-intelops Aug 13, 2023
0675f77
create app config table is added to init job
anil-intelops Aug 13, 2023
bd7d9a7
create app config table is added to init job
anil-intelops Aug 13, 2023
dd1b6fc
minor changes
anil-intelops Aug 13, 2023
fc9d4e3
minor changes
anil-intelops Aug 16, 2023
db15bc5
minor changes
anil-intelops Aug 16, 2023
5e17f18
minor changes
anil-intelops Aug 16, 2023
a52bdbe
conflict resolved
anil-intelops Aug 16, 2023
b5d8294
Merge branch 'feature/store_app_deploy' of https://github.com/kube-ta…
anil-intelops Aug 16, 2023
dca9476
conflict resolved
anil-intelops Aug 16, 2023
574b8ad
minor changes
anil-intelops Aug 16, 2023
135c676
minor changes
anil-intelops Aug 16, 2023
7881c11
minor changes
anil-intelops Aug 16, 2023
108cc2b
app store config is added
anil-intelops Aug 19, 2023
f4c9d1c
updated the proto buffer files
anil-intelops Aug 19, 2023
5b9cd90
conflict resolved
anil-intelops Aug 19, 2023
7837138
minor changes
anil-intelops Aug 19, 2023
4e33b5c
ory clinet is added to agent handler
anil-intelops Aug 19, 2023
888f5c4
Update Dockerfile
anil-intelops Aug 19, 2023
742f015
Update Dockerfile
anil-intelops Aug 19, 2023
0c72bb8
minor changes
anil-intelops Aug 19, 2023
20c01cc
minor changes
anil-intelops Aug 19, 2023
43095c0
minor changes
anil-intelops Aug 19, 2023
f45fb75
Merge branch 'main' of https://github.com/kube-tarian/kad into featur…
anil-intelops Aug 19, 2023
f8af1cb
conflict resolved
anil-intelops Aug 19, 2023
b917918
Merge branch 'main' of https://github.com/kube-tarian/kad into featur…
anil-intelops Aug 19, 2023
908e612
minor changes
anil-intelops Aug 19, 2023
dab0a04
minor changes
anil-intelops Aug 19, 2023
198b5e6
minor changes
anil-intelops Aug 19, 2023
96ac3ac
Merge branch 'main' into feature/store_app_deploy
vramk23 Aug 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions capten/agent/pkg/agent/agent_climon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/kube-tarian/kad/capten/agent/pkg/agentpb"
"github.com/kube-tarian/kad/capten/agent/pkg/model"
"github.com/kube-tarian/kad/capten/agent/pkg/workers"
)

Expand Down Expand Up @@ -36,3 +37,32 @@ func (a *Agent) ClimonAppDelete(ctx context.Context, request *agentpb.ClimonDele

return prepareJobResponse(run, worker.GetWorkflowName()), err
}

func (a *Agent) InstallApp(ctx context.Context, request *agentpb.InstallAppRequest) (*agentpb.JobResponse, error) {
a.log.Infof("Recieved App Install event %+v", request)
worker := workers.NewClimon(a.tc, a.log)

config := &model.AppConfig{
ReleaseName: request.AppConfig.ReleaseName,
AppName: request.AppConfig.AppName,
Version: request.AppConfig.Version,
Category: request.AppConfig.Category,
Description: request.AppConfig.Description,
ChartName: request.AppConfig.ChartName,
RepoName: request.AppConfig.RepoName,
RepoURL: request.AppConfig.RepoURL,
Namespace: request.AppConfig.Namespace,
CreateNamespace: request.AppConfig.CreateNamespace,
PrivilegedNamespace: request.AppConfig.PrivilegedNamespace,
Icon: string(request.AppConfig.Icon),
LaunchURL: request.AppConfig.LaunchURL,
// LaunchRedirectURL: request.AppConfig.LaunchRedirectURL,
ClusterName: "inbuilt",
}
run, err := worker.SendInstallAppEvent(ctx, "install", config)
if err != nil {
return &agentpb.JobResponse{}, err
}

return prepareJobResponse(run, worker.GetWorkflowName()), err
}
397 changes: 234 additions & 163 deletions capten/agent/pkg/agentpb/agent.pb.go

Large diffs are not rendered by default.

39 changes: 38 additions & 1 deletion capten/agent/pkg/agentpb/agent_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions capten/agent/pkg/model/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@ type Request struct {
Timeout int `json:"timeout" required:"true"`
Version string `json:"version" required:"true"`
}

type AppConfig struct {
ClusterName string `json:"ClusterName,omitempty"`
AppName string `json:"AppName,omitempty"`
Version string `json:"Version,omitempty"`
Category string `json:"Category,omitempty"`
Description string `json:"Description,omitempty"`
ChartName string `json:"ChartName,omitempty"`
RepoName string `json:"RepoName,omitempty"`
ReleaseName string `json:"ReleaseName,omitempty"`
RepoURL string `json:"RepoURL,omitempty"`
Namespace string `json:"Namespace,omitempty"`
CreateNamespace bool `json:"CreateNamespace"`
PrivilegedNamespace bool `json:"PrivilegedNamespace"`
Icon string `json:"Icon,omitempty"`
LaunchURL string `json:"LaunchURL,omitempty"`
LaunchRedirectURL string `json:"LaunchRedirectURL,omitempty"`
}
32 changes: 32 additions & 0 deletions capten/agent/pkg/workers/climon.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,35 @@ func (c *Climon) getWorkflowInformation(run client.WorkflowRun) error {
c.log.Debugf("Result info: %+v", result)
return nil
}

func (c *Climon) SendInstallAppEvent(ctx context.Context, action string, payload *model.AppConfig) (client.WorkflowRun, error) {
options := client.StartWorkflowOptions{
ID: "helm-deploy-workflow",
TaskQueue: ClimonHelmTaskQueue,
}

payloadJSON, err := json.Marshal(payload)
if err != nil {
return nil, err
}

we, err := c.client.TemporalClient.ExecuteWorkflow(context.Background(), options, DeployWorkflowName, action, json.RawMessage(payloadJSON))
if err != nil {
log.Println("error starting workflow", err)
return nil, err
}

c.log.Infof("Started workflow, ID: %v, WorkflowName: %v RunID: %v", we.GetID(), DeploymentWorkerWorkflowName, we.GetRunID())

// Wait for 5mins till workflow finishes
var result model.ResponsePayload
err = we.Get(ctx, &result)
if err != nil {
c.log.Errorf("Result for workflow ID: %v, workflowName: %v, runID: %v", we.GetID(), DeploymentWorkerWorkflowName, we.GetRunID())
c.log.Errorf("Workflow result failed, %v", err)
return we, err
}
c.log.Infof("workflow finished success, %+v", result.ToString())

return we, nil
}
1 change: 1 addition & 0 deletions dockerfiles/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN CGO_ENABLED=0 go build -o ./build/server cmd/server/main.go

FROM alpine:3.16
RUN apk add --no-cache libc6-compat
COPY --from=builder ./storeconfig storeconfig
COPY --from=builder ./build/server server

USER 65532:65532
Expand Down
9 changes: 8 additions & 1 deletion proto/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ service Agent {

rpc GetClusterAppConfig (GetClusterAppConfigRequest) returns (GetClusterAppConfigResponse) {}
rpc GetClusterAppValues (GetClusterAppValuesRequest) returns (GetClusterAppValuesResponse) {}

rpc InstallApp (InstallAppRequest) returns (JobResponse) {}

}

enum StatusCode {
Expand Down Expand Up @@ -245,5 +248,9 @@ message AppLaunchConfig {
string description = 3;
bytes icon = 4;
string launchURL = 5;
string launchUIDescription = 6;
string launchRedirectURL = 6;
}

message InstallAppRequest{
AppConfig appConfig =1;
}
24 changes: 24 additions & 0 deletions proto/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ service Server {
rpc DeleteStoreApp (DeleteStoreAppRequest) returns (DeleteStoreAppResponse){}
rpc GetStoreApp (GetStoreAppRequest) returns (GetStoreAppResponse) {}
rpc GetStoreApps (GetStoreAppsRequest) returns (GetStoreAppsResponse) {}
rpc GetStoreAppValues(GetStoreAppValuesRequest) returns (GetStoreAppValuesResponse) {}
rpc DeployStoreApp(DeployStoreAppRequest) returns (DeployStoreAppResponse) {}

}

enum StatusCode {
Expand Down Expand Up @@ -209,6 +212,26 @@ message GetStoreAppsResponse {
repeated StoreAppConfig appConfigs = 3;
}

message GetStoreAppValuesRequest {
string appName = 1;
string version = 2;
}

message GetStoreAppValuesResponse{
StatusCode status = 1;
string statusMessage = 2;
StoreAppConfig appConfig = 3;
}

message DeployStoreAppRequest{
StoreAppConfig appConfig = 1;
}

message DeployStoreAppResponse{
StatusCode status = 1;
string statusMessage = 2;
}

message StoreAppConfig {
string releaseName = 1;
string appName = 2;
Expand All @@ -230,3 +253,4 @@ message StoreAppValues {
string overrideValues = 1;
string launchUIValues = 2;
}

Binary file added server/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions server/pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

const (
organizationIDAttribute = "organizationid"
clusterIDAttribute = "clusterid"
)

type Server struct {
Expand Down
Loading
Loading