Skip to content

Commit 1c7463c

Browse files
hola-soy-milkLauraLangdon
andauthoredAug 22, 2022
Add local deployment docs (#158)
* Add local deployment docs * Restructure to be 'with Minikube' * Adopt lovely feedback * add words to dictionary * add more words to dictionary * Update website/docs/compute/local-deployment/minikube.md Co-authored-by: Laura Langdon <[email protected]> * Update website/docs/compute/local-deployment/minikube.md Co-authored-by: Laura Langdon <[email protected]> * Update website/docs/compute/local-deployment/minikube.md Co-authored-by: Laura Langdon <[email protected]> * Update website/docs/compute/local-deployment/minikube.md Co-authored-by: Laura Langdon <[email protected]> * Update website/docs/compute/local-deployment/minikube.md Co-authored-by: Laura Langdon <[email protected]> * Update website/docs/compute/local-deployment/minikube.md Co-authored-by: Laura Langdon <[email protected]> * Apply feedback * Rename subcategory to Other Deployments * Lowercase minikube * Remove trailing comma Co-authored-by: Laura Langdon <[email protected]> Co-authored-by: Laura Langdon <[email protected]>
1 parent cf552ee commit 1c7463c

File tree

3 files changed

+241
-0
lines changed

3 files changed

+241
-0
lines changed
 

‎spelling.dic

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ ErrMsgNotWanted
110110
ErrorResponse
111111
ErrorString
112112
ErrWaitTimeout
113+
eu
113114
ExecString
114115
execUri
115116
expensiveRunnable
@@ -119,6 +120,7 @@ facto
119120
fas
120121
fdd
121122
Fermyon
123+
ffae
122124
FFI
123125
filesystem
124126
filesystems
@@ -261,6 +263,7 @@ MethodPost
261263
microsoft
262264
middleware
263265
Middleware
266+
minikube
264267
mkdir
265268
mlc
266269
mozilla
@@ -292,6 +295,8 @@ NewRunnable
292295
NewRunner
293296
NewWCResponse
294297
NeXT
298+
Ngrok
299+
ngrok
295300
nodejs
296301
NodeUUID
297302
no-op
@@ -320,6 +325,8 @@ PoolSize
320325
postgresql
321326
pre
322327
Pre
328+
prefilled
329+
Prefilled
323330
prev
324331
PreWarm
325332
Println
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
# Deploy with minikube
2+
3+
It’s possible to deploy a Compute environment to a local environment using a local Kubernetes cluster.
4+
5+
## Requirements
6+
7+
- [Docker](https://www.docker.com/)
8+
- [minikube](https://minikube.sigs.k8s.io/docs/start/)
9+
- [ngrok](https://ngrok.com/download)
10+
- [Subo](https://github.com/suborbital/subo#installing)
11+
12+
## Steps
13+
14+
### 1. Create a folder for the environment
15+
16+
This is a temporary place where we’ll create and configure our Compute environment:
17+
18+
```bash
19+
mkdir my-compute
20+
21+
cd my-compute
22+
```
23+
24+
### 2. Start up our Kubernetes cluster
25+
26+
Kubernetes clusters usually live on the cloud. However, with minikube, we can create a local one to use:
27+
28+
```bash
29+
minikube start
30+
```
31+
32+
### 3. Expose our cluster to the internet with ngrok
33+
34+
This command will forward all requests to a randomly-generated URL to `http://localhost:80`
35+
36+
```bash
37+
ngrok http http://localhost
38+
```
39+
40+
:::tip
41+
Jot down that URL generated by ngrok! It’ll look something like [https://84925795ffae.eu.ngrok.io](https://84925795ffae.eu.ngrok.io/)
42+
:::
43+
44+
### 4. Generate your Compute manifests
45+
46+
Next we’ll be using Subo to generate our Kubernetes manifest files!
47+
48+
```bash
49+
subo compute deploy core --dryrun
50+
```
51+
52+
You will be asked for a domain. Please make sure to enter your domain from ngrok.
53+
54+
This will generate some Kubernetes manifest files, which will now live in the `.suborbital/` folder:
55+
56+
- `scc-atmo-deployment.yaml`
57+
- `scc-autoscale.yaml`
58+
- `scc-controlplane-deployment.yaml`
59+
60+
### 5. Disable TLS checks in the Compute environment
61+
62+
Open up `.suborbital/scc-controlplane-deployment.yaml` in your editor of choice, and make the following changes.
63+
64+
We are disabling the built-in TLS certificate provisioning, as ngrok already takes care of this for us.
65+
66+
Under the Builder Container:
67+
68+
```yaml
69+
- name: builder
70+
image: suborbital/scc-builder:v0.3.1
71+
command: ["builder"]
72+
73+
ports:
74+
- containerPort: 8080
75+
- containerPort: 8443
76+
77+
env:
78+
- name: SCC_DOMAIN
79+
value: "<YOUR_NGROK_DOMAIN>"
80+
81+
- name: SCC_TLS_PORT
82+
value: "8443"
83+
84+
- name: SCC_LOG_LEVEL
85+
value: "info"
86+
87+
- name: SCC_CONTROL_PLANE
88+
value: "scc-controlplane-service:8081"
89+
90+
volumeMounts:
91+
- mountPath: "/home/scn"
92+
name: controlplane-storage
93+
```
94+
95+
Delete the following line:
96+
97+
`delete containerPort: 8443`
98+
99+
Delete the following key-value pair:
100+
101+
```yaml
102+
- name: SCC_DOMAIN
103+
value: "<YOUR_NGROK_DOMAIN>"
104+
```
105+
106+
Replacing the following key-value pair:
107+
108+
```yaml
109+
- name: SCC_TLS_PORT
110+
value: "8443"
111+
```
112+
113+
With the following:
114+
115+
```yaml
116+
name: SCC_HTTP_PORT
117+
value: "8080"
118+
```
119+
120+
Under the `scc-builder-service`:
121+
122+
```yaml
123+
apiVersion: v1
124+
kind: Service
125+
metadata:
126+
namespace: suborbital
127+
name: scc-builder-service
128+
spec:
129+
selector:
130+
app: scc-controlplane
131+
ports:
132+
- protocol: TCP
133+
name: challenge
134+
port: 80
135+
targetPort: 8080
136+
- protocol: TCP
137+
name: https
138+
port: 443
139+
targetPort: 8443
140+
type: LoadBalancer
141+
```
142+
143+
Our builder service no longer needs to expose HTTPS ports as ngrok will forward both HTTP and HTTPS traffic to port 80.
144+
145+
Remove the following lines:
146+
147+
```yaml
148+
- protocol: TCP
149+
name: https
150+
port: 443
151+
targetPort: 8443
152+
```
153+
154+
### 6. Deploy to your cluster
155+
156+
Run the following Subo command to deploy Compute to your cluster:
157+
158+
```bash
159+
subo compute deploy core
160+
```
161+
162+
### 7. Setup minikube tunneling
163+
164+
Let’s tell minikube to forward requests to port 80 to our cluster!
165+
166+
```bash
167+
minikube tunnel
168+
```
169+
170+
### 8. Create an editor token
171+
172+
In order to test our editor, we’re going to come up with a function name, and create a token so we can access it!
173+
174+
This can only be done as an [API call](https://docs.suborbital.dev/compute/integrate-the-function-editor/code-editor) from within your cluster. Since we’re currently not running an app in our cluster, we’ll just make the call from within!
175+
176+
First, we’ll need the name of our control plane pod:
177+
178+
```bash
179+
kubectl get pod -n suborbital
180+
```
181+
182+
Your output will look something like this:
183+
184+
```bash
185+
NAME READY STATUS RESTARTS AGE
186+
scc-atmo-deployment-7bfb9d76c6-sv5dr 1/1 Running 0 27s
187+
scc-controlplane-deployment-5699f779f7-xmkhr 2/2 Running 0 27s
188+
```
189+
190+
Let’s take that full name of our `scc-controlplane-deployment` pod and start a bash session inside it:
191+
192+
```bash
193+
kubectl exec -n suborbital -it scc-controlplane-deployment-<REST OF POD CODENAME> -- bash
194+
```
195+
196+
Would you look at that, we’re inside our cluster now!
197+
198+
Let’s install `curl`:
199+
200+
```bash
201+
apt update; apt install curl
202+
```
203+
204+
With `curl` installed, we can now get our editor token for testing:
205+
206+
```bash
207+
curl [http://local.suborbital.network:8081/api/v1/token/<IDENT>/default/](http://local.suborbital.network:8081/api/v1/token/com.acmeco.gr9fas97234b/default/httpget)<FUNCTION_NAME>
208+
```
209+
210+
In which:
211+
212+
- `IDENT`: Customer identity, for example: `com.example.12345`
213+
- `FUNCTION_NAME` : A name for your function
214+
215+
This will give you a JSON response with a token. Let’s copy it!
216+
217+
### 9. Try out the function editor
218+
219+
The function editor is available through [building a specific URL](https://docs.suborbital.dev/compute/integrate-the-function-editor/code-editor). We can do that now that we have all the ingredients. In your browser, try opening up the following URL:
220+
221+
```bash
222+
[https://editor.suborbital.network/?builder=https://<NGROK_DOMAIN>&token=<EDITOR_TOKEN>&ident=<IDENT>&fn=](https://editor.suborbital.network/?builder=https://4515-62-178-0-213.eu.ngrok.io&token=StIsWXsIAPJsjVlxcgItgvWS&ident=com.acmeco.gr9fas97234b&fn=ramono)<FUNCTION_NAME>&template=<LANGUAGE_TEMPLATE>
223+
```
224+
225+
In which:
226+
227+
- `NGROK_DOMAIN`: The domain generated by `ngrok` in step 3
228+
- `EDITOR_TOKEN`: The token generated by the control plane API in step 8
229+
- `IDENT`: Customer identity, for example: `com.example.12345`
230+
- `FUNCTION_NAME` : A name for your function
231+
- `LANGUAGE_TEMPLATE`: [A template to be prefilled](https://docs.suborbital.dev/compute/integrate-the-function-editor/code-editor#configuration) when opening the editor for a new function, defaulting to `AssemblyScript`.

‎website/sidebars.js

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ module.exports = {
3131
'compute/deployment/cloud-deployment/configure-storage',
3232
'compute/deployment/cloud-deployment/configure-webhooks',
3333
'compute/deployment/cloud-deployment/install-compute-in-your-cloud-environment'
34+
],
35+
'Other Deployments': [
36+
'compute/deployment/other-deployments/minikube'
3437
]
3538
},
3639
]

0 commit comments

Comments
 (0)
Please sign in to comment.