Compare commits

..

2 Commits

Author SHA1 Message Date
alban
e60d280be2 [fix] remove routes 2020-05-18 16:27:50 +02:00
alban
b05c246d8f [fix] system goes in system 2020-05-18 16:27:33 +02:00
7 changed files with 132 additions and 79 deletions

View File

@ -1,78 +0,0 @@
module.exports = {
main: (req, res) => {
console.log("request /")
res.render('index', { title: 'Hey', message: 'Hello there!' })
res.end('wut')
//
// res.type('html')
// res.send(`<html>
//<head>
//<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
//<title>Welcome to Alex's express.js example</title>
//</head>
//<body>
// <h3>Hi, thanks for using my Express.js lab 👏</h3>
//
// <p>If you found it useful, <a href="https://github.com/alexellis/">view my other GitHub projects</a> today 👑</p>
//
// <p>Results from <quote>GET <a href="/links">/links</a></quote>:</p>
//
// <div id="links">
// </div>
//
// <p>Copyright <a href="https://www.alexellis.io/">Alex Ellis 2020 &reg;</a></p>
// <script>
// $(document).ready(function(){
// $.get("/links", function(data, status){
// var res = "<ul>";
// var links = data;
// for(var i=0; i < links.length; i++) {
// res += "<li><a href=" + links[i].url + ">" + links[i].name + "</a></li>"
// }
// $("#links").html(res)
// });
// });
// </script>
// </body>
//</html>
//`);
},
links: (req, res) => {
res.type("json")
res.send(
[
{
"name": "github",
"url": "https://github.com/alexellis"
},
{
"name": "twitter",
"url": "https://twitter.com/alexellisuk"
},
{
"name": "blog",
"url": "https://blog.alexellis.io"
},
{
"name": "sponsors",
"url": "https://github.com/users/alexellis/sponsorship"
},
])
},
health: (req, res) => {
// Do an ES request
client.ping({
// ping usually has a 3000ms timeout
requestTimeout: 1000
}, function (error) {
if (error) {
console.trace('elasticsearch cluster is down!');
} else {
console.log('All is well');
}
});
res.send("OK");
}
}

View File

@ -26,7 +26,7 @@ services:
app: app:
env_file: .env env_file: .env
build: . build: ../
image: albancrommer/changelog-server:latest image: albancrommer/changelog-server:latest
ports: ports:
- "3000:3000" - "3000:3000"

View File

@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: changelog-server
labels:
app: changelog-server
spec:
selector:
matchLabels:
app: changelog-server
# strategy:
# type: RollingUpdate
# rollingUpdate:
# maxSurge: 1
# maxUnavailable: 1
replicas: 1
template:
metadata:
labels:
app: changelog-server
spec:
initContainers:
- name: set-vm-sync-limit
image: busybox
imagePullPolicy: IfNotPresent
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
volumes:
- name: changelog-server-esdata
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
containers:
- name: app
image: albancrommer/changelog-server:latest
ports:
- containerPort: 80
protocol: TCP
- name: es
image: blacktop/elasticsearch:7.7
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9200
protocol: TCP
volumeMounts:
# - name: elastic-config
# mountPath: /etc/elasticsearch/elasticsearch.yaml
# subPath: elasticsearch.yaml
- name : changelog-server-esdata
mountPath: /usr/share/elasticsearch/data
env:
- name: node.name
value: "es01"
- name: cluster.name
value: "es-docker-cluster"
- name: bootstrap.memory_lock
value: "true"
- name: ES_JAVA_OPTS
value: "-Xms512m -Xmx512m"

10
system/k8s/elastic.yaml Normal file
View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
labels:
product: k8s-elastic
name: elastic-config
data:
elasticsearch.yaml: |
discovery.type: single-node

13
system/k8s/service.yaml Normal file
View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: changelog-server
spec:
type: ClusterIP
ports:
- name: www
port: 80
targetPort: 80
protocol: TCP
selector:
app: changelog-server

43
system/k8s/volumes.yaml Normal file
View File

@ -0,0 +1,43 @@
#apiVersion: v1
#kind: PersistentVolume
#metadata:
# name: changelog-server
#spec:
# capacity:
# storage: 2Mi
# volumeMode: Filesystem
# accessModes:
# - ReadWriteOnce
# persistentVolumeReclaimPolicy: Retain
#---
#
#apiVersion: v1
#kind: PersistentVolume
#metadata:
# name: changelog-server
#spec:
# capacity:
# storage: 5Gi
# volumeMode: Filesystem
# accessModes:
# - ReadWriteOnce
# persistentVolumeReclaimPolicy: Retain
# HostPath :
# path: /changelog-server-es01data
#
#
apiVersion: v1
kind: PersistentVolume
metadata:
name: changelog-server-esdata
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/changelog-server-esdata"