-
Notifications
You must be signed in to change notification settings - Fork 1
/
oh-social.ps1
77 lines (67 loc) · 2.22 KB
/
oh-social.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
. "./utils.ps1"
switch (choose "(p)rod (s)tage?" "p","s") {
"p" {
$PROPS_FILE = ".\config\oh-social-prod.props";
$SECRETS_FILE = ".\secrets\oh-social-prod.secrets.yaml";
$STATUS_URL = "https://rates.overhide.io/status.json";
}
"s" {
$PROPS_FILE = ".\config\oh-social-stage.props";
$SECRETS_FILE = ".\secrets\oh-social-stage.secrets.yaml";
$STATUS_URL = "https://stage.rates.overhide.io/status.json";
}
}
$conf = load "./config/k8.props";
$conf = load $PROPS_FILE $conf;
$conf.'K8_IMAGE' = $conf.K8_IMAGE -f $conf.'PROJECT_ID';
Write-Host "CONFIG: `n$($conf.GetEnumerator() | sort name | Format-Table | Out-String)"
$local_img = "oh-social:latest";
$repo_img = $conf.'K8_IMAGE' + ":" + $conf.'K8_VERSION';
switch (choose "`n`n do (i)mages `n do (s)ettings `n (d)eployment `n (e)xec in `n (r)edeploy `n (f)ollow logs for deployment `n s(t)atus `n`n Choose one..." "i","s","d","e","r","f","t") {
"i" {
EX "docker images ${repo_img}";
go `
"Do you see old '${repo_img}' image above you want to delete before tagging?" `
"docker rmi ${repo_img}";
EX "docker images ${local_img}";
go `
"Do you see local image above? Do you want to tag it for repo?" `
"docker tag ${local_img} ${repo_img}";
go `
"Push out image?" `
"docker push ${repo_img}";
}
"s" {
gogo `
"Create configmap $($conf.'K8_CONFIGMAP_NAME')" `
"kubectl get configmap $($conf.'K8_CONFIGMAP_NAME') -o yaml", `
"kubectl delete configmap $($conf.'K8_CONFIGMAP_NAME')", `
"kubectl create configmap $($conf.'K8_CONFIGMAP_NAME') --from-env-file=${PROPS_FILE}";
go `
"You have the secrets installed?" `
"kubectl get secrets $($conf.'K8_SECRETS') -o yaml"
}
"d" {
go `
"Apply oh-social?" `
(genKubectlApply "k8s/oh-social.yaml" $conf);
go `
"Show logs?" `
"kubectl logs -l app=$($conf.'K8_NAME')";
}
"e" {
kubectl exec -it $(getKubectlEntity "pods" "($($conf.'K8_NAME')[^ ]+)") -- /bin/sh
}
"r" {
$conf.'K8_DIRTY' = "$(Get-Date -Format o)";
go `
"Redeploy oh-social?" `
(genKubectlApply "k8s/oh-social.yaml" $conf);
}
"f" {
EX("kubectl logs deployment/$($conf.'K8_NAME') --since=1h -f");
}
"t" {
curl $STATUS_URL;
}
}