Skip to content

Commit 4729a73

Browse files
author
LorenzoTettamanti
committed
[#94]: added CLI install command (beta)
1 parent 8ea8c7c commit 4729a73

1 file changed

Lines changed: 84 additions & 7 deletions

File tree

cli/src/install.rs

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,97 @@
1+
use std::process::Command;
2+
13
pub fn install_cortexflow() {
24
println!("Preparing cortexflow installation");
3-
println!("🛸 Copying kubernetes manifests as temporary files");
5+
46
/* copying the files */
7+
println!("🛸 Copying kubernetes manifests as temporary files");
8+
copy_installation_files();
59

610
println!("🛸 creating cortexflow namespace");
711
/* create the namespace */
8-
println!("🛸 installing cert manager");
12+
Command::new("kubectl")
13+
.args(["create", "namespace", "cortexflow"])
14+
.output()
15+
.expect("Failed to create cortexflow namespace");
16+
917
/* install cert manager */
10-
println!("🛸 installing cortexflow components");
18+
println!("🛸 installing cert manager");
19+
println!("\n");
20+
Command::new("kubectl").args([
21+
"apply",
22+
"-f",
23+
"https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml",
24+
]);
25+
Command::new("sleep").args(["110"]);
26+
println!("\n");
27+
1128
/* install the components */
29+
println!("🛸 installing cortexflow components");
30+
install_components();
31+
println!("\n");
32+
33+
println!("setupping cert manager");
34+
setup_cert_manager();
35+
println!("🛸 Removing temporary files");
36+
/* remove all the installation files */
37+
rm_installation_files();
38+
println!("🛸 installation completed");
39+
}
40+
41+
fn install_components() {
42+
Command::new("kubectl").args(["apply", "-f", "configmap.yaml", "-n", "cortexflow"]);
43+
Command::new("kubectl").args(["apply", "-f", "configmap-role.yaml", "-n", "default"]);
44+
Command::new("kubectl").args(["apply", "-f", "rolebinding.yaml", "-n", "kube-system"]);
45+
Command::new("kubectl").args(["apply", "-f", "cortexflow-rolebinding.yaml"]);
46+
Command::new("kubectl").args(["apply", "-f", "certificate-manager.yaml"]);
47+
}
48+
fn copy_installation_files() {
49+
Command::new("cp")
50+
.args(["../../core/src/testing/configmap.yaml", "configmap.yaml"])
51+
.output()
52+
.expect("cannot import configmap file");
53+
Command::new("cp")
54+
.args(["../../core/src/testing/configmap-role.yaml", "configmap-role.yaml"])
55+
.output()
56+
.expect("cannot import configmap-role file");
57+
Command::new("cp")
58+
.args(["../../core/src/testing/rolebinding.yaml", "rolebinding.yaml"])
59+
.output()
60+
.expect("cannot import rolebinding file");
61+
Command::new("cp")
62+
.args(["../../core/src/testing/cortexflow-rolebinding.yaml", "cortexflow-rolebinding.yaml"])
63+
.output()
64+
.expect("cannot import rolebinding file");
65+
Command::new("cp")
66+
.args(["../../core/src/testing/certificate-manager.yaml", "certificate-manager.yaml"])
67+
.output()
68+
.expect("cannot import certificate-manager file");
69+
}
70+
fn rm_installation_files() {
71+
Command::new("rm")
72+
.args(["-rf", "configmap.yaml"])
73+
.output()
74+
.expect("cannot remove configmap file");
75+
Command::new("rm")
76+
.args(["-rf", "configmap-role.yaml"])
77+
.output()
78+
.expect("cannot remove configmap-role file");
79+
Command::new("rm")
80+
.args(["-rf", "rolebinding.yaml"])
81+
.output()
82+
.expect("cannot remove rolebinding file");
83+
Command::new("rm")
84+
.args(["-rf", "cortexflow-rolebinding.yaml"])
85+
.output()
86+
.expect("cannot remove rolebinding file");
87+
Command::new("rm")
88+
.args(["-rf", "certificate-manager.yaml"])
89+
.output()
90+
.expect("cannot remove certificate-manager file");
91+
}
92+
fn setup_cert_manager() {
1293
println!("🛸 creating the issuer");
1394
println!("🛸 caBundle certificate");
1495
println!("🛸 tls.key code");
1596
println!("🛸 tls.cert code");
16-
/* return the codes and automatically isntall the proxy injector */
17-
println!("🛸 Removing temporary files");
18-
/* remove all the installation files */
19-
println!("🛸 installation completed");
2097
}

0 commit comments

Comments
 (0)