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

katana-cli [WIP] #79

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b711559
fadd unc for infra curl
rizul2108 Nov 4, 2023
d1fa863
error msg change
rizul2108 Nov 4, 2023
e61b12d
function move to older file
rizul2108 Nov 7, 2023
b4b700b
add 2 func cli
rizul2108 Nov 8, 2023
2b8e7e0
update cmds for more abstraction
rizul2108 Nov 9, 2023
2dccc09
error handling
rizul2108 Nov 27, 2023
02cc99a
basic structure
rizul2108 Nov 30, 2023
6461b28
minor fixes
rizul2108 Nov 30, 2023
2501fb8
add createTeams func
rizul2108 Dec 1, 2023
a78736b
minor fixes
rizul2108 Dec 1, 2023
f53e00e
changes in createTeams func
rizul2108 Dec 2, 2023
ae6116f
wip changes
rizul2108 Dec 5, 2023
8098282
fixes
rizul2108 Dec 18, 2023
c064cd8
gogsetup error fix
rizul2108 Dec 20, 2023
af72587
Fix setup command and add MongoDB setup
rizul2108 Dec 20, 2023
9083ff3
add GlobalKubeClient and GlobalKubeConfig
rizul2108 Dec 21, 2023
b5490d1
minor fixes
rizul2108 Dec 21, 2023
784ffdb
fixes
rizul2108 Dec 21, 2023
b3cb683
code cleanup
rizul2108 Dec 21, 2023
2378139
Add OpenSSL version check
rizul2108 Dec 21, 2023
fde86f7
minor fixes for chall handling funcs
rizul2108 Dec 22, 2023
4fcc1e0
Add wireguard.yml
Bisht13 Aug 10, 2023
42cdcfb
update submodule ref
P3rcy-8685 Aug 30, 2023
0004d6c
update submodule ref
P3rcy-8685 Aug 30, 2023
4d53a45
update wireguard yml
P3rcy-8685 Aug 30, 2023
edcaf4b
remove cmd for certs and dynamic lb ip for wireguard
ashpect Aug 30, 2023
5891103
Get route for pre-existing challenges
ashpect Aug 31, 2023
c00b07e
[wip] remove cmd for certs
ashpect Sep 1, 2023
11380cb
Write firewall rules in image
ashpect Sep 1, 2023
b405d2b
add sample challenges
ashpect Sep 1, 2023
fee938b
Wireguard finishup
ashpect Sep 1, 2023
9dea00b
update
ashpect Oct 17, 2023
9015f14
fix
ashpect Oct 17, 2023
d7b822a
update crypto.go
ashpect Dec 20, 2023
404cc52
some bug fixes and minor updates
P3rcy-8685 Dec 21, 2023
eefbf23
func add for infra curl
rizul2108 Nov 4, 2023
60eba50
error handling
rizul2108 Nov 27, 2023
ce73eab
minor fixes
rizul2108 Dec 1, 2023
3b896e7
wip changes
rizul2108 Dec 5, 2023
f5c8e25
fixes
rizul2108 Dec 18, 2023
3a02293
add GlobalKubeClient and GlobalKubeConfig
rizul2108 Dec 21, 2023
7971487
code cleanup
rizul2108 Dec 21, 2023
7c05023
Add OpenSSL version check
rizul2108 Dec 21, 2023
35ad757
fixes for rebase
rizul2108 Dec 22, 2023
828f99a
Merge branch 'develop' into katana-cli
rizul2108 Dec 22, 2023
1b66b95
minor fixes
rizul2108 Dec 22, 2023
15bc421
func deployChallenge fixes
rizul2108 Dec 22, 2023
f62d8ea
fixes for deleteChal
rizul2108 Dec 22, 2023
2e1b1cb
minor fixes
rizul2108 Dec 23, 2023
7549335
minor fixes in challHandling funcs
rizul2108 Dec 23, 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
67 changes: 67 additions & 0 deletions cmd/infraset.go
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{}
Copy link
Contributor

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.

Copy link
Member Author

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

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()
},
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ var rootCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(runCmd)
rootCmd.AddCommand(infraCmd)
}
6 changes: 3 additions & 3 deletions config.sample.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kubeconfig = ""
kubeconfig = "/home/rizul/.kube/config"
kubehost = "0.0.0.0"
rizul2108 marked this conversation as resolved.
Show resolved Hide resolved
backendurl = "http://10.25.1.15:15528"
backendurl = "http://10.25.1.15:15529"
kubenamespace = "default"
timeout = 20 # in seconds

Expand All @@ -19,7 +19,7 @@ templated_manifests = [

[services.api]
host = "0.0.0.0"
port = 15528
port = 15529

[teamvm]
teampodname = "katana-team-master-pod"
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ require (
github.com/stretchr/testify v1.8.4
github.com/xdg-go/pbkdf2 v1.0.0
go.mongodb.org/mongo-driver v1.12.1
golang.org/x/crypto v0.12.0
golang.org/x/crypto v0.13.0
k8s.io/api v0.28.1
k8s.io/apimachinery v0.28.1
k8s.io/client-go v0.28.1
k8s.io/kubectl v0.28.1
)

require (
Expand Down Expand Up @@ -106,14 +107,14 @@ require (
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.12.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand All @@ -125,7 +126,6 @@ require (
k8s.io/component-base v0.28.1 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230811205723-7ac0aad8c58d // indirect
k8s.io/kubectl v0.28.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
Expand Down
35 changes: 15 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEM
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -224,8 +225,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
Expand All @@ -241,6 +241,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down Expand Up @@ -291,8 +292,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand All @@ -318,8 +319,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU=
golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk=
Expand Down Expand Up @@ -350,16 +351,16 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand All @@ -369,8 +370,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand All @@ -383,8 +384,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -430,18 +431,12 @@ gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.28.0-alpha.3 h1:dl9ku8PmbvD7VFdgYzA34SRGsg5hpmDeqZUC670kVjw=
k8s.io/api v0.28.0-alpha.3/go.mod h1:8xUcnnu+0XlJiU0p9mwS7tRpUB1ce+XZrCYsEHeUQRw=
k8s.io/api v0.28.1 h1:i+0O8k2NPBCPYaMB+uCkseEbawEt/eFaiRqUx8aB108=
k8s.io/api v0.28.1/go.mod h1:uBYwID+66wiL28Kn2tBjBYQdEU0Xk0z5qF8bIBqk/Dg=
k8s.io/apimachinery v0.28.0-alpha.3 h1:poqReta738jpeYUyvxXxYbOk6hj5vc1EcKxyo0zhklk=
k8s.io/apimachinery v0.28.0-alpha.3/go.mod h1:tAiIbF8KB8+Ri2DfUWwZGwNOThIwM0fhXLnOymriu+4=
k8s.io/apimachinery v0.28.1 h1:EJD40og3GizBSV3mkIoXQBsws32okPOy+MkRyzh6nPY=
k8s.io/apimachinery v0.28.1/go.mod h1:X0xh/chESs2hP9koe+SdIAcXWcQ+RM5hy0ZynB+yEvw=
k8s.io/cli-runtime v0.28.1 h1:7Njc4eD5kaO4tYdSYVJJEs54koYD/vT6gxOq8dEVf9g=
k8s.io/cli-runtime v0.28.1/go.mod h1:yIThSWkAVLqeRs74CMkq6lNFW42GyJmvMtcNn01SZho=
k8s.io/client-go v0.28.0-alpha.3 h1:CPcmGXW3lRogryie7htr93ZIitk6H+zrzPns3TpuFyY=
k8s.io/client-go v0.28.0-alpha.3/go.mod h1:1KTCIXQZjy18QNeXI6zDkq1w2E4UP6gjl1fp5QRF3mo=
k8s.io/client-go v0.28.1 h1:pRhMzB8HyLfVwpngWKE8hDcXRqifh1ga2Z/PU9SXVK8=
k8s.io/client-go v0.28.1/go.mod h1:pEZA3FqOsVkCc07pFVzK076R+P/eXqsgx5zuuRWukNE=
k8s.io/component-base v0.28.1 h1:LA4AujMlK2mr0tZbQDZkjWbdhTV5bRyEyAFe0TJxlWg=
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/templates/storage-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Contributor

Choose a reason for hiding this comment

The 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 ?

Copy link
Member Author

Choose a reason for hiding this comment

The 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
so he asked to add this code for first deleting the directories.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paradox Right change ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

volumeMounts:
- mountPath: "/mnt"
name: setup-volume
Expand Down
61 changes: 58 additions & 3 deletions services/infrasetservice/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"time"

"github.com/gofiber/fiber/v2"
Expand All @@ -25,6 +26,61 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//moved it from helper.go to controller.go bcoz it was
//giving error after making it's first letter capital
rizul2108 marked this conversation as resolved.
Show resolved Hide resolved

func BuildKatanaServices() {
fmt.Print("build")
katanaDir, err := utils.GetKatanaRootPath()
if err != nil {
log.Fatal(err)
}

katanaServicesDir := katanaDir + "/katana-services"

services, err := os.ReadDir(katanaServicesDir)
if err != nil {
log.Fatal(err)
}

for _, service := range services {
if service.Name() == ".github" {
continue
}
if service.IsDir() {
log.Println("Building " + service.Name())
imageName := strings.ToLower(service.Name())
utils.BuildDockerImage(imageName, katanaServicesDir+"/"+service.Name())
}
}
}

func GenerateCertsforHarbor() {
path, _ := os.Getwd()
path = path + "/lib/harbor/certs"

// Delete the directory if it already exists
if _, err := os.Stat(path); os.IsExist(err) {
errDir := os.RemoveAll(path)
if errDir != nil {
log.Fatal(err)
}
}

if _, err := os.Stat(path); os.IsNotExist(err) {
errDir := os.Mkdir(path, 0755)
if errDir != nil {
log.Fatal(err)
}
}

// Generate the certificates
if err := utils.GenerateCerts("harbor.katana.local", path); err != nil {
log.Fatal(err)
}

}

func InfraSet(c *fiber.Ctx) error {

config, err := utils.GetKubeConfig()
Expand All @@ -37,7 +93,7 @@ func InfraSet(c *fiber.Ctx) error {
log.Fatal(err)
}

generateCertsforHarbor()
GenerateCertsforHarbor()

if err = deployment.DeployCluster(config, kubeclient); err != nil {
log.Fatal(err)
Expand All @@ -47,8 +103,7 @@ func InfraSet(c *fiber.Ctx) error {
if err != nil {
log.Fatal(err)
}

buildKatanaServices()
BuildKatanaServices()

return c.SendString("Infrastructure setup completed")
}
Expand Down
Loading
Loading