-
Notifications
You must be signed in to change notification settings - Fork 1
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
katana-cli [WIP] #79
base: develop
Are you sure you want to change the base?
katana-cli [WIP] #79
Changes from 2 commits
b711559
d1fa863
e61b12d
b4b700b
2b8e7e0
2dccc09
02cc99a
6461b28
2501fb8
a78736b
f53e00e
ae6116f
8098282
c064cd8
af72587
9083ff3
b5490d1
784ffdb
b3cb683
2378139
fde86f7
4fcc1e0
42cdcfb
0004d6c
4d53a45
edcaf4b
5891103
c00b07e
11380cb
b405d2b
fee938b
9dea00b
9015f14
d7b822a
404cc52
eefbf23
60eba50
ce73eab
3b896e7
f5c8e25
3a02293
7971487
7c05023
35ad757
828f99a
1b66b95
15bc421
f62d8ea
2e1b1cb
7549335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"html/template" | ||
"log" | ||
"path/filepath" | ||
|
||
g "github.com/sdslabs/katana/configs" | ||
"github.com/sdslabs/katana/lib/deployment" | ||
"github.com/sdslabs/katana/lib/harbor" | ||
utils "github.com/sdslabs/katana/lib/utils" | ||
infraSetService "github.com/sdslabs/katana/services/infrasetservice" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var infraCmd = &cobra.Command{ | ||
|
||
Use: "infra", | ||
Short: "Run the infraset setup command", | ||
Long: `Runs the katana API server on port 3000`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
g.LoadConfiguration() | ||
config, err := utils.GetKubeConfig() | ||
|
||
if err != nil { | ||
log.Println("There was error in setting up Kubernentes Config") | ||
} | ||
|
||
kubeclient, err := utils.GetKubeClient() | ||
|
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
infraSetService.GenerateCertsforHarbor() | ||
|
||
clusterConfig := g.ClusterConfig | ||
deploymentConfig := utils.DeploymentConfig() | ||
nodes, _ := utils.GetNodes(kubeclient) | ||
|
||
deploymentConfig.NodeAffinityValue = nodes[0].Name | ||
|
||
for _, m := range clusterConfig.TemplatedManifests { | ||
|
||
manifest := &bytes.Buffer{} | ||
log.Printf("Applying: %s\n", m) | ||
tmpl, err := template.ParseFiles(filepath.Join(clusterConfig.TemplatedManifestDir, m)) | ||
if err != nil { | ||
fmt.Print("err1") | ||
} | ||
|
||
if err = tmpl.Execute(manifest, deploymentConfig); err != nil { | ||
fmt.Print("err2") | ||
} | ||
|
||
if err = deployment.ApplyManifest(config, kubeclient, manifest.Bytes(), g.KatanaConfig.KubeNameSpace); err != nil { | ||
fmt.Print("err3") | ||
} | ||
} | ||
err = harbor.SetupHarbor() | ||
if err != nil { | ||
fmt.Print("err4") | ||
} | ||
infraSetService.BuildKatanaServices() | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,5 @@ var rootCmd = &cobra.Command{ | |
|
||
func init() { | ||
rootCmd.AddCommand(runCmd) | ||
rootCmd.AddCommand(infraCmd) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ spec: | |
containers: | ||
- name: create-data-dirs | ||
image: busybox | ||
command: ["sh", "-c", "mkdir /mnt/gogs /mnt/mysql /mnt/mongo /mnt/kashira /mnt/kissaki && sleep infinity"] | ||
command: ["sh", "-c", "rm -rf /mnt/gogs /mnt/mysql /mnt/mongo /mnt/kashira /mnt/kissaki && mkdir /mnt/gogs /mnt/mysql /mnt/mongo /mnt/kashira /mnt/kissaki && sleep infinity"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you need to delete dirs in container? Is it cause it picking it up from volumes, but that won't be required while setup as new volume would be created ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I discussed it with paradox he said that sometimes it get stuck in loop of a function because of pre-existing directories There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Paradox Right change ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
volumeMounts: | ||
- mountPath: "/mnt" | ||
name: setup-volume | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try writing most of functions not directly in cmd func, use it to call the required details. so we can reuse them. Like here for applying , use the deployment.deploycluster if its compatible.
See imgpkg code for inspiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay will check it once again