Skip to content

Commit 0dcf653

Browse files
armanjindalChristoph Pröschelljupcovangelski
authored
[#3397] Airy CLI Installation with Terraform (#3404)
* [#3360] Bug with external Go dependency build * Also add disable proto globally file to this PR and fix gazelle import order * [#3397] Change CLI for AWS to use Terraform * Decouple status from kubernetes * Update output message and aws docs * Update aws docs * Clarify aws docs Co-authored-by: Christoph Pröschel <[email protected]> Co-authored-by: ljupcovangelski <[email protected]>
1 parent 8d2dc67 commit 0dcf653

File tree

23 files changed

+471
-735
lines changed

23 files changed

+471
-735
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ package-lock.json
3030
*.tfstate.*
3131
.terraform.tfstate.lock.info
3232
.terraform.lock.hcl
33+
/terraform
3334

3435
# Kubernetes
3536
.kubeconfig

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ exports_files(
181181
# gazelle:proto disable_global
182182
# gazelle:build_file_name BUILD
183183
# gazelle:prefix
184+
# gazelle:exclude infrastructure/terraform
184185
gazelle(name = "gazelle")
185186

186187
nogo(

cli/go.mod

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ require (
2828
)
2929

3030
require (
31-
cloud.google.com/go v0.100.2 // indirect
32-
cloud.google.com/go/compute v1.6.1 // indirect
31+
cloud.google.com/go v0.102.0 // indirect
32+
cloud.google.com/go/compute v1.7.0 // indirect
33+
cloud.google.com/go/iam v0.3.0 // indirect
34+
cloud.google.com/go/storage v1.22.1 // indirect
3335
github.com/Masterminds/goutils v1.1.1 // indirect
3436
github.com/Masterminds/semver v1.5.0 // indirect
3537
github.com/PuerkitoBio/purell v1.1.1 // indirect
@@ -44,6 +46,7 @@ require (
4446
github.com/aws/aws-sdk-go-v2/service/sso v1.11.5 // indirect
4547
github.com/aws/aws-sdk-go-v2/service/sts v1.16.6 // indirect
4648
github.com/aws/smithy-go v1.11.2 // indirect
49+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
4750
github.com/davecgh/go-spew v1.1.1 // indirect
4851
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
4952
github.com/fsnotify/fsnotify v1.5.4 // indirect
@@ -52,21 +55,29 @@ require (
5255
github.com/go-openapi/jsonreference v0.20.0 // indirect
5356
github.com/go-openapi/swag v0.21.1 // indirect
5457
github.com/gogo/protobuf v1.3.2 // indirect
58+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5559
github.com/golang/protobuf v1.5.2 // indirect
5660
github.com/google/gnostic v0.6.9 // indirect
5761
github.com/google/gofuzz v1.2.0 // indirect
5862
github.com/google/uuid v1.3.0 // indirect
63+
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
64+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
65+
github.com/hashicorp/go-getter v1.6.2 // indirect
66+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
67+
github.com/hashicorp/go-version v1.1.0 // indirect
5968
github.com/hashicorp/hcl v1.0.0 // indirect
6069
github.com/huandu/xstrings v1.3.2 // indirect
6170
github.com/imdario/mergo v0.3.13 // indirect
6271
github.com/inconshreveable/mousetrap v1.0.0 // indirect
6372
github.com/jmespath/go-jmespath v0.4.0 // indirect
6473
github.com/josharian/intern v1.0.0 // indirect
6574
github.com/json-iterator/go v1.1.12 // indirect
75+
github.com/klauspost/compress v1.11.2 // indirect
6676
github.com/kr/text v0.2.0 // indirect
6777
github.com/magiconair/properties v1.8.6 // indirect
6878
github.com/mailru/easyjson v0.7.7 // indirect
6979
github.com/mitchellh/copystructure v1.2.0 // indirect
80+
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
7081
github.com/mitchellh/mapstructure v1.5.0 // indirect
7182
github.com/mitchellh/reflectwalk v1.0.2 // indirect
7283
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -81,6 +92,7 @@ require (
8192
github.com/spf13/jwalterweatherman v1.1.0 // indirect
8293
github.com/spf13/pflag v1.0.5 // indirect
8394
github.com/subosito/gotenv v1.3.0 // indirect
95+
github.com/ulikunitz/xz v0.5.8 // indirect
8496
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
8597
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
8698
golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect
@@ -89,7 +101,19 @@ require (
89101
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
90102
golang.org/x/text v0.3.7 // indirect
91103
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
104+
go.opencensus.io v0.23.0 // indirect
105+
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
106+
golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect
107+
golang.org/x/oauth2 v0.0.0-20220630143837-2104d58473e0 // indirect
108+
golang.org/x/sys v0.0.0-20220624220833-87e55d714810 // indirect
109+
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
110+
golang.org/x/text v0.3.7 // indirect
111+
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
112+
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
113+
google.golang.org/api v0.86.0 // indirect
92114
google.golang.org/appengine v1.6.7 // indirect
115+
google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f // indirect
116+
google.golang.org/grpc v1.47.0 // indirect
93117
google.golang.org/protobuf v1.28.0 // indirect
94118
gopkg.in/inf.v0 v0.9.1 // indirect
95119
gopkg.in/ini.v1 v1.66.4 // indirect

cli/go.sum

Lines changed: 83 additions & 0 deletions
Large diffs are not rendered by default.

cli/pkg/cmd/create/create.go

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,21 @@ func create(cmd *cobra.Command, args []string) {
6565
overrides.Version = version
6666
overrides.Namespace = namespace
6767
overrides.TrackingDisabled = disableTracking
68+
if err := provider.CheckEnvironment(); err != nil {
69+
console.Exit("please set up the required environment for the installation", err)
70+
}
71+
6872
dir, err := workspace.Create(workspacePath, overrides)
6973
if err != nil {
7074
console.Exit("could not initialize Airy workspace directory", err)
7175
}
7276
fmt.Println("📁 Initialized Airy workspace directory at", dir.GetPath("."))
77+
78+
installDir, err := provider.PreInstallation(dir.GetPath("."))
79+
if err != nil {
80+
console.Exit("could not set up files for install in Airy workspace directory", err)
81+
}
82+
fmt.Println("📁 Set up installation directory in the Airy workspace at", installDir)
7383
if initOnly {
7484
os.Exit(0)
7585
}
@@ -78,69 +88,69 @@ func create(cmd *cobra.Command, args []string) {
7888
fmt.Fprintln(w)
7989
fmt.Fprintln(w, providerName, "provider output:")
8090
fmt.Fprintln(w)
81-
context, err := provider.Provision(providerConfig, dir)
91+
context, err := provider.Provision(providerConfig, workspace.ConfigDir{Path: installDir})
8292
fmt.Fprintln(w)
8393
if err != nil {
84-
console.Exit("could not provision cluster: ", err)
85-
}
86-
87-
fmt.Println("✅ Cluster provisioned")
88-
89-
clientset, err := context.GetClientSet()
90-
if err != nil {
91-
console.Exit("could not get clientset: ", err)
94+
console.Exit("could not install Airy: ", err)
9295
}
96+
if providerName == "minikube" { // TEMP fix to keep minikube working
97+
clientset, err := context.GetClientSet()
98+
if err != nil {
99+
console.Exit("could not get clientset: ", err)
100+
}
93101

94-
if err = context.Store(); err != nil {
95-
console.Exit("could not store the kube context: ", err)
96-
}
102+
if err = context.Store(); err != nil {
103+
console.Exit("could not store the kube context: ", err)
104+
}
97105

98-
helm := helm.New(clientset, version, namespace, dir.GetAiryYaml())
99-
if err := helm.Setup(); err != nil {
100-
console.Exit("setting up Helm failed with err: ", err)
101-
}
106+
helm := helm.New(clientset, version, namespace, dir.GetAiryYaml())
107+
if err := helm.Setup(); err != nil {
108+
console.Exit("setting up Helm failed with err: ", err)
109+
}
102110

103-
fmt.Println("🚀 Starting airy with default components")
111+
fmt.Println("🚀 Starting core with default components")
104112

105-
if err := helm.InstallCharts(); err != nil {
106-
console.Exit("installing Helm charts failed with err: ", err)
107-
}
113+
if err := helm.InstallCharts(); err != nil {
114+
console.Exit("installing Helm charts failed with err: ", err)
115+
}
108116

109-
if err = provider.PostInstallation(providerConfig, namespace, dir); err != nil {
110-
console.Exit("failed to run post installation hook: ", err)
111-
}
117+
if err = provider.PostInstallation(providerConfig, namespace, dir); err != nil {
118+
console.Exit("failed to run post installation hook: ", err)
119+
}
112120

113-
fmt.Println("🎉 Your Airy Core is ready")
121+
fmt.Println("🎉 Your Airy Core is ready")
114122

115-
coreConfig, err := k8s.GetCmData("core-config", namespace, clientset)
116-
if err != nil {
117-
console.Exit("failed to get hosts from installation")
118-
}
123+
coreConfig, err := k8s.GetCmData("core-config", namespace, clientset)
124+
if err != nil {
125+
console.Exit("failed to get hosts from installation")
126+
}
119127

120-
fmt.Println("\t 👩‍🍳 Available hosts:")
121-
for hostName, host := range coreConfig {
122-
switch hostName {
123-
case "HOST":
124-
fmt.Printf("\t\t %s:\t %s", "Host", host)
125-
fmt.Println()
126-
case "API_HOST":
127-
fmt.Printf("\t\t %s:\t %s", "API", host)
128-
fmt.Println()
129-
case "NGROK":
130-
fmt.Printf("\t\t %s:\t %s", "NGROK", host)
131-
fmt.Println()
128+
fmt.Println("\t 👩‍🍳 Available hosts:")
129+
for hostName, host := range coreConfig {
130+
switch hostName {
131+
case "HOST":
132+
fmt.Printf("\t\t %s:\t %s", "Host", host)
133+
fmt.Println()
134+
case "API_HOST":
135+
fmt.Printf("\t\t %s:\t %s", "API", host)
136+
fmt.Println()
137+
case "NGROK":
138+
fmt.Printf("\t\t %s:\t %s", "NGROK", host)
139+
fmt.Println()
140+
}
132141
}
133-
}
134142

135-
fmt.Println()
143+
fmt.Println("✅ Airy Installed")
144+
fmt.Println()
136145

137-
viper.Set("provider", provider)
138-
viper.Set("namespace", namespace)
139-
viper.WriteConfig()
146+
viper.Set("provider", provider)
147+
viper.Set("namespace", namespace)
148+
viper.WriteConfig()
140149

141-
airyAnalytics.Track(analytics.Track{
142-
UserId: coreConfig["CORE_ID"],
143-
Event: "installation_succesful"})
144-
fmt.Printf("📚 For more information about the %s provider visit https://airy.co/docs/core/getting-started/installation/%s", providerName, providerName)
145-
fmt.Println()
150+
airyAnalytics.Track(analytics.Track{
151+
UserId: coreConfig["CORE_ID"],
152+
Event: "installation_succesful"})
153+
fmt.Printf("📚 For more information about the %s provider visit https://airy.co/docs/core/getting-started/installation/%s", providerName, providerName)
154+
fmt.Println()
155+
}
146156
}

cli/pkg/cmd/status/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ go_library(
88
visibility = ["//visibility:public"],
99
deps = [
1010
"//cli/pkg/console",
11-
"//cli/pkg/kube",
1211
"//lib/go/httpclient",
1312
"@com_github_spf13_cobra//:cobra",
1413
"@com_github_spf13_viper//:viper",

cli/pkg/cmd/status/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var StatusCmd = &cobra.Command{
2121

2222
func status(cmd *cobra.Command, args []string) {
2323
c := httpclient.NewClient(viper.GetString("apihost"), viper.GetString("authToken"))
24+
2425
res, err := c.Config()
2526

2627
if err != nil {

cli/pkg/providers/aws/BUILD

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ go_library(
1717
"//cli/pkg/kube",
1818
"//cli/pkg/workspace",
1919
"//cli/pkg/workspace/template",
20-
"@com_github_aws_aws_sdk_go//aws",
21-
"@com_github_aws_aws_sdk_go_v2_config//:config",
22-
"@com_github_aws_aws_sdk_go_v2_service_ec2//:ec2",
23-
"@com_github_aws_aws_sdk_go_v2_service_ec2//types",
24-
"@com_github_aws_aws_sdk_go_v2_service_eks//:eks",
25-
"@com_github_aws_aws_sdk_go_v2_service_eks//types",
26-
"@com_github_aws_aws_sdk_go_v2_service_iam//:iam",
27-
"@com_github_aws_aws_sdk_go_v2_service_iam//types",
28-
"@com_github_twinproduction_go_color//:go-color",
20+
"@com_github_hashicorp_go_getter//:go-getter",
2921
"@in_gopkg_segmentio_analytics_go_v3//:analytics-go_v3",
3022
],
3123
)

0 commit comments

Comments
 (0)