Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] K8s changes #300

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ after_success:
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD;
docker tag openhab-cloud $TRAVIS_REPO_SLUG:$TRAVIS_TAG;
docker push $TRAVIS_REPO_SLUG:$TRAVIS_TAG;
fi
fi
7 changes: 4 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if (system.isGcmConfigured()) {
}

module.exports.config = config;
module.exports.system = system;

// Setup all homepage
var flash = require('connect-flash'),
Expand Down Expand Up @@ -102,9 +103,9 @@ var mongoose = require('mongoose');
var cachegoose = require('cachegoose');
cachegoose(mongoose, {
engine: 'redis',
port: config.redis.port,
host: config.redis.host,
password: config.redis.password,
port: system.getRedisPort(),
host: system.getRedisHost(),
password: system.getRedisPassword(),
});
var cacheTTL = config.cacheTTL || 600;

Expand Down
13 changes: 3 additions & 10 deletions deployment/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,10 @@ Another prerequisite is the **Kubectl** tool to interact with the Kubernetes clu
In order to deploy openHAB-cloud to Kubernetes, there are some steps required which will be done by the script in the repository. After having the Kubernetes cluster up and running and the kubectl command line tool in the PATH, the deployment can be done by running the following commands and script:

cd openhab-cloud/deployment/kubernetes
chmod +x openshift-deploy.sh
./openshift-deploy.sh

The script will create a new Kubernetes namespace called ``openhab-cloud``. It will also spin up all needed resources by one of the openHAB-cloud Kubernetes templates:
chmod +x kubernetes-deploy.sh
./kubernetes-deploy.sh

openhabcloud_ephermal_k8_template.yml

or

openhabcloud_k8_template.yml

The script will create a new Kubernetes namespace called ``openhab-cloud`` with resources defined in ohc.yaml

You can deploy openHAB-cloud with persistent storage (persistent volume claims) by using the template with storage resource definitions.

Expand Down
58 changes: 58 additions & 0 deletions deployment/kubernetes/config-k8s.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"system": {
"host": "your host name",
"port": "443",
"protocol": "https",
"logger": {
"type": "console"
},
"subDomainCookies": true,
"muteNotifications": true
},
"express": {
"key": "Unique key here"
},
"apn": {
"gateway": "gateway.push.apple.com",
"cert": "certs/aps/aps_production_cert.pem",
"key": "certs/aps/aps_production_key.pem",
"passphrase": "passphrase"
},
"gcm": {
"jid": "[email protected]",
"password": "passphrase"
},
"ifttt": {
"iftttChannelKey": "",
"iftttTestToken": ""
},
"mail": {
"host": "",
"port": 465,
"user": "",
"pass": ""
},
"mongodb": {
"hosts": [
"mongodb"
],
"db": "openhab"
},
"redis": {
"host": "redis",
"port": "6379",
"password": "secret"
},
"mailer": {
"host": "",
"port": 465,
"secureConnection": true,
"user": "",
"password": "",
"from": ""
},
"legal": {
"terms": "terms.html",
"policy": ""
}
}
86 changes: 86 additions & 0 deletions deployment/kubernetes/envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
address: 0.0.0.0
port_value: 9901
static_resources:
listeners:
- name: listener_http
address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- use_proxy_proto: true
filters:
- name: envoy.http_connection_manager
config:
access_log:
- name: envoy.file_access_log
config:
path: "/dev/stdout"
upgrade_configs:
upgrade_type: "websocket"
stat_prefix: ingress_http
route_config:
name: local_route_http
virtual_hosts:
- name: local_service_http
domains: ["*"]
routes:
- match: { prefix: "/" }
redirect: { https_redirect: true }
http_filters:
- name: envoy.router
- name: listener_https
address:
socket_address:
address: 0.0.0.0
port_value: 81
filter_chains:
- use_proxy_proto: true
filters:
- name: envoy.http_connection_manager
config:
access_log:
- name: envoy.file_access_log
config:
path: "/dev/stdout"
upgrade_configs:
upgrade_type: "websocket"
stat_prefix: ingress_http
route_config:
name: local_route_https
virtual_hosts:
- name: local_service_https
domains: ["*"]
routes:
- match:
prefix: "/socket.io"
route:
cluster: proxy_app_cluster
timeout: 60s
hash_policy:
header:
header_name: "uuid"
- match:
prefix: "/"
route:
cluster: web_app_cluster
timeout: 60s
http_filters:
- name: envoy.router
clusters:
- name: web_app_cluster
connect_timeout: 0.25s
type: STRICT_DNS
dns_lookup_family: V4_ONLY
lb_policy: LEAST_REQUEST
hosts: [{ socket_address: { address: web-app, port_value: 3000 }}]
- name: proxy_app_cluster
connect_timeout: 0.25s
type: STRICT_DNS
dns_lookup_family: V4_ONLY
lb_policy: RING_HASH
hosts: [{ socket_address: { address: proxy-app, port_value: 3000 }}]
5 changes: 3 additions & 2 deletions deployment/kubernetes/kubernetes-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ kubectl create serviceaccount $KUBERNETES_ACCOUNT --namespace $KUBERNETES_NAMESP
### Create openHAB-cloud from template

echo Creating openHAB-cloud from template ...

kubectl create -f openhabcloud_ephemeral_k8_template.yml --namespace $KUBERNETES_NAMESPACE
kubectl create configmap envoy-config --from-file=envoy.yaml
kubectl create secret generic ohc-config --from-file=config.json="config-k8s.json"
kubectl create -f ohc.yaml --namespace $KUBERNETES_NAMESPACE

echo Creating openHAB-cloud from template ... done!

Expand Down
Empty file modified deployment/kubernetes/kubernetes-undeploy.sh
100644 → 100755
Empty file.
Loading