forked from akuity/kargo-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCookbook.py
69 lines (43 loc) · 1.98 KB
/
Cookbook.py
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
REPO_URL = "https://github.com/wavemm/kargo-demo"
def kubectl(cmd: str) -> str:
return f"kubectl --context kind-kargo-quickstart {cmd}"
def kargo_create_project(recipe):
return [
f"export GITOPS_REPO_URL={REPO_URL}",
"export GITHUB_USERNAME=abo-abo",
"export GITHUB_PAT=$(gpg -q --for-your-eyes-only --no-tty -d ~/.password-store/com/github.com/kargo-research.gpg)",
"export DOCKER_USERNAME=okrehel",
"export DOCKER_PASSWORD=$(gpg -q --for-your-eyes-only --no-tty -d ~/.password-store/com/hub.docker.com/okrehel.gpg)",
"cd ops",
"kargo login https://localhost:31444 --admin --password admin --insecure-skip-tls-verify",
"envsubst < project.yaml | kargo apply -f -",
]
def create_regcred(recipe):
return kubectl(
"-n kargo-demo-migrate create secret generic regcred --from-file=.dockerconfigjson=$HOME/.docker/config.json --type=kubernetes.io/dockerconfigjson"
)
def setup(recipe):
return [
"kind delete cluster -n kargo-quickstart",
"cd ops",
"./setup-kind-cluster.sh",
kubectl("apply -f argocd-kargo-demo.yaml"),
]
def curl_migrate(recipe):
return "curl localhost:30081"
def curl_canary(recipe):
return "curl localhost:30082"
def curl_prod(recipe):
return "curl localhost:30083"
def get_freight(recipe):
return "kargo get freight --project kargo-demo"
def get_promotions(recipe):
return "kargo get promotions --project kargo-demo"
def get_stages(recipe):
return "kargo get stages --project kargo-demo"
def get_analysisruns(recipe):
return kubectl("get analysisruns --all-namespaces --sort-by=.metadata.creationTimestamp --no-headers | tac")
def get_last_analysisrun(recipe):
return kubectl("get analysisrun --all-namespaces --sort-by=.metadata.creationTimestamp -o jsonpath=\"{.items[-1]}\" | jq")
def get_last_migrate_logs(recipe, name="7273edf0-eef2-4b21-bb7c-6847e0a37444.test.1-7kq5k"):
return kubectl(f"-n kargo-demo logs {name}")