-
Notifications
You must be signed in to change notification settings - Fork 0
/
cheatsheet
94 lines (80 loc) · 2.04 KB
/
cheatsheet
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
## Grant RBAC for tiller
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
## Install OpenFaaS on Kubernetes
kubectl create ns openfaas
kubectl create ns openfaas-fn
admin : 5957536818df9ff5ba1ca7a24e4bc9648e9df9b0
helm upgrade --install --debug --namespace openfaas --reset-values --set async=false --set functionNamespace=openfaas-fn openfaas openfaas/
## Access to a shell in DB
kubectl exec -it db-9dfb7b458-wk94k -- /bin/bash
## Populate DB
curl -X POST --data-binary @- --dump - http://root:openfaasgraphqlblog@localhost:8529/_api/database << EOF
{
"name" : "faasblog"
}
EOF
curl -X POST --data-binary @- --dump - http://root:openfaasgraphqlblog@localhost:8529/_db/faasblog/_api/collection <<EOF
{
"name" : "posts"
}
EOF
curl -X POST --data-binary @- --dump - http://root:openfaasgraphqlblog@localhost:8529/_db/faasblog/_api/collection <<EOF
{
"name" : "comments"
}
EOF
curl -X POST --data-binary @- --dump - http://root:openfaasgraphqlblog@localhost:8529/_db/faasblog/_api/collection <<EOF
{
"name" : "authors"
}
EOF
# Build, push, deploy
faas-cli build -f faasblog.yml && faas-cli push -f faasblog.yml && faas-cli deploy -f faasblog.yml
# Stress test application for autoscale on Prometheus
ab -k -c 20 -n 10000 http://104.46.88.86:8080/function/faasblog
# GraphQL commands
mutation {
createAuthor(name: "Jane") {
id
name
}
}
mutation {
createPost(title: "Some Sample Post", bodyContent: "This is a sample post", author: "1252") {
id
title
bodyContent
author {
name
}
comments {
id
}
}
}
mutation {
createComment(content: "This is a comment", author: "1252", post: "1265") {
id
content
author {
name
}
}
}
query {
posts(authorId: "1252") {
id
title
bodyContent
author {
name
}
comments {
content
author {
name
}
}
}
}