Commit 67cc3d8b authored by Alberto Pascual's avatar Alberto Pascual
Browse files

k8s added to crossbar for deployment

parent 0b82e121
......@@ -54,6 +54,7 @@ import pytest
import requests
import json
import os
class AppSession(ApplicationSession):
......@@ -67,8 +68,7 @@ class AppSession(ApplicationSession):
url = "http://ewetasker.cluster.gsi.dit.upm.es/api/events"
try:
host = "172.19.0.1"
es = Elasticsearch(hosts=[{'host': host, 'port': 9200}])
es = Elasticsearch(hosts=[{'host': os.environ['ES_ENDPOINT'], 'port': os.environ['ES_ENDPOINT_PORT']}])
connected = es.ping()
log.info("Correctly connected to elasticsearch: {connected}", connected = connected)
except Error as e:
......
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ewetasker-es
spec:
replicas: 1
template:
metadata:
labels:
role: ewetasker-es
app: test
spec:
containers:
- name: ewetasker-es
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0
imagePullPolicy: Always
resources:
limits:
memory: "2048Mi"
cpu: "1000m"
env:
- name: ES_JAVA_OPTS
value: -Xms1g -Xmx1g
command: ["bin/elasticsearch"]
args: [
'-Ecluster.name=sefarad',
'-Expack.security.enabled=false',
'-Ehttp.cors.enabled=true',
'-Ehttp.cors.allow-origin=*'
]
ports:
- name: elasticsearch
containerPort: 9200
- name: elasticsearch-2
containerPort: 9300
volumeMounts:
- mountPath: /usr/share/elasticsearch/data
name: es-data
subPath: es-data
volumes:
- name: es-data
persistentVolumeClaim:
claimName: ewetasker-pvc
---
apiVersion: v1
kind: Service
metadata:
name: ewetasker-es
spec:
type: ClusterIP
ports:
- port: 9200
protocol: TCP
selector:
role: ewetasker-es
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ewetasker-es
annotations:
# Only proxy GET requests (used in clients)
ingress.kubernetes.io/configuration-snippet: |
set $reject 0;
if ($request_filename !~ _search) {
set $reject 1;
}
if ($request_method = "HEAD") {
set $reject 0;
}
if ($reject = 1) {
return 403;
break;
}
spec:
rules:
- host: ewetasker-elasticsearch.cluster.gsi.dit.upm.es
http:
paths:
- path: /
backend:
serviceName: ewetasker-es
servicePort: 9200
---
apiVersion: v1
kind: ConfigMap
metadata:
name: crossbar
data:
ES_ENDPOINT: "ewetasker-es"
ES_ENDPOINT_PORT: "9200"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: crossbar
spec:
replicas: 1
template:
metadata:
labels:
role: crossbar
app: crossbar
spec:
containers:
- name: crossbar
image: registry.cluster.gsi.dit.upm.es/ewetasker/ewe-crossbar:0.0.1
imagePullPolicy: Always
resources:
limits:
memory: "512Mi"
cpu: "200m"
ports:
- name: crossbar-web
containerPort: 8081
ports:
- name: crossbar-http
containerPort: 8082
ports:
- name: crossbar-mqtt
containerPort: 1883
envFrom:
- configMapRef:
name: crossbar
\ No newline at end of file
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: crossbar
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: ewecrossbar.cluster.gsi.dit.upm.es
http:
paths:
- path: /
backend:
serviceName: crossbar
servicePort: 8082
- host: mqtt.ewecrossbar.cluster.gsi.dit.upm.es
http:
paths:
- path: /
backend:
serviceName: crossbar
servicePort: 1883
---
apiVersion: v1
kind: Service
metadata:
name: crossbar
spec:
type: ClusterIP
ports:
- name: crossbar-http
port: 8082
protocol: TCP
- name: crossbar-mqtt
port: 1883
protocol: TCP
selector:
role: crossbar
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment