mirror of
https://github.com/autistic-symposium/backend-and-orchestration-toolkit.git
synced 2025-06-07 22:42:59 -04:00
merge files from the blockchain infra repo (#59)
This commit is contained in:
parent
23f56ef195
commit
2a6449bb85
346 changed files with 29097 additions and 132 deletions
8
code/kubernetes/node-server-example/Dockerfile
Executable file
8
code/kubernetes/node-server-example/Dockerfile
Executable file
|
@ -0,0 +1,8 @@
|
|||
FROM node:4.4
|
||||
MAINTAINER "Mia Stein"
|
||||
|
||||
EXPOSE 1337
|
||||
|
||||
COPY server.js .
|
||||
|
||||
CMD node server.js
|
15
code/kubernetes/node-server-example/Makefile
Executable file
15
code/kubernetes/node-server-example/Makefile
Executable file
|
@ -0,0 +1,15 @@
|
|||
.DELETE_ON_ERROR:
|
||||
|
||||
build:
|
||||
docker build -t node_app_test .
|
||||
|
||||
run:
|
||||
docker run -d -p 1337:1337 node_app_test
|
||||
|
||||
curl:
|
||||
curl localhost:1337
|
||||
|
||||
status:
|
||||
docker ps
|
||||
|
||||
.PHONY: build run curl status
|
92
code/kubernetes/node-server-example/README.md
Executable file
92
code/kubernetes/node-server-example/README.md
Executable file
|
@ -0,0 +1,92 @@
|
|||
## deploying a node.js K8s cluster with kubectl
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
* build the image:
|
||||
|
||||
```
|
||||
make build:
|
||||
```
|
||||
|
||||
* run the container:
|
||||
|
||||
```
|
||||
make run
|
||||
```
|
||||
|
||||
* check whether the server worked:
|
||||
|
||||
```
|
||||
make curl
|
||||
```
|
||||
|
||||
* check container's status:
|
||||
|
||||
```
|
||||
make status
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
### useful commands
|
||||
|
||||
<br>
|
||||
|
||||
* exec inside the container:
|
||||
|
||||
```
|
||||
docker exec -i -t <container name from status> /bin/bash
|
||||
```
|
||||
|
||||
* check images in disk:
|
||||
|
||||
```
|
||||
docker images
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
----
|
||||
|
||||
### pushing the registry to kubernetes
|
||||
|
||||
<br>
|
||||
|
||||
* in a real production system, we’ll want to build images in one place, then run these images in the Kubernetes cluster
|
||||
* the system that images for distribution is called a **container registry**
|
||||
* using a `yaml` Kubernetes files (for example, the one inside `node_server_example/`), you can now deploy the image with:
|
||||
|
||||
```
|
||||
kubectl create -f node_example_kube_config.yaml
|
||||
```
|
||||
|
||||
* after that, you are able to create the service with:
|
||||
|
||||
```
|
||||
kubectl expose deployment node-app-test
|
||||
```
|
||||
|
||||
* also, check out the service status with:
|
||||
|
||||
```
|
||||
kubectl get services
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
### cleanning up
|
||||
|
||||
<br>
|
||||
|
||||
* removing the service and the deployment when you are done:
|
||||
|
||||
```
|
||||
kubectl delete service node-app-test
|
||||
kubectl delete deployment node-app-test
|
||||
```
|
||||
|
18
code/kubernetes/node-server-example/node_example_kube_config.yaml
Executable file
18
code/kubernetes/node-server-example/node_example_kube_config.yaml
Executable file
|
@ -0,0 +1,18 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: node_app_test
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
run: node_app_test
|
||||
spec:
|
||||
containers:
|
||||
- name: node_app_test
|
||||
image: node_app_test:1.0
|
||||
ports:
|
||||
- containerPort: 1337
|
||||
imagePullSecrets:
|
||||
- name: <encrypted password for your container registry>
|
11
code/kubernetes/node-server-example/server.js
Executable file
11
code/kubernetes/node-server-example/server.js
Executable file
|
@ -0,0 +1,11 @@
|
|||
var os = require("os");
|
||||
var hostname = os.hostname();
|
||||
var http = require('http');
|
||||
var handleRequest = function(request, response) {
|
||||
console.log('Received request for URL: ' + request.url);
|
||||
response.writeHead(200);
|
||||
response.end("Hello from container " + hostname + "!\n\n");
|
||||
};
|
||||
var www = http.createServer(handleRequest);
|
||||
www.listen(1337);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue