Installation¶
docker-compose¶
You can easily install the KosmoS Platform via docker-compose.
download from github¶
The simplest way to get the full KosmoS Platform via docker-compose is to check out the latest version from github .
download files¶
git clone https://github.com/kosmos-lab/kosmos-platform.git
download the latest zip from github and extract it.
wget https://github.com/kosmos-lab/kosmos-platform/archive/refs/heads/main.zip
unzip main.zip
setup¶
Please change the paramaters of the docker-compose.yml to your likings. You should at least change the user accounts.
start the containers¶
docker-compose up -d
Start only KosmoS Platform without download¶
If you dont want to checkout the project and do not want to use HomeAssistant you can create your own docker-compose.yml.
Create and setup docker-compose.yml¶
version: '3.4'
services:
kosmos-home-assistant:
container_name: kosmos-home-assistant
image: homeassistant/home-assistant:stable
volumes:
- ./ha-config:/config #the config folder, also contains the kosmos custom component, this NEEDS the checkout or github download containing the giving folder
environment:
- TZ=Europe/Berlin
- PUID=1000
- PGID=1000
restart: unless-stopped
ports:
- "8123:8123"
kosmos-platform:
container_name: kosmos-platform
restart: unless-stopped
image: ghcr.io/kosmos-lab/kosmos-platform
volumes:
- ./config:/app/config #the config folder
- ./db:/app/db # the folder of the database
- ./plugins:/app/plugins # the plugins folder, drop kosmos plugin zips in here
- ./rules:/app/rules/rules # the rules created with KREE will be saved here
- ./oz/ui.json:/app/web/oz/assets/ui.json # the custom Wizard-of-Oz UI config will be saved in this file
environment:
- SETUPHA=1 # automatically setup home assistant, this implies the home assisstant instance is completely fresh
- KOSMOS_HOST=kosmos-platform # the internal host for the platform
- HA_HOST=kosmos-home-assistant # the host of the home assisstant instance to connect to
- HA_USER=kosmos # the username we add to home asssisstant
- HA_PASS=pass # the password to use for the added home assisstant user
# the users to setup in the kosmos platform, here we create 3 users with simple passwords
- USERS=[{"username":"admin","level":100,"password":"verysecret"},{"username":"user","level":1,"password":"pass"},{"username":"user2","level":1,"password":"pass"}]
- PUID=1000 # the userid to run the process
- PGID=1000 # the groupid to run the process
depends_on:
- kosmos-home-assistant
ports:
- "18080:18080"
- "1883:1883"
version: '3.4'
services:
kosmos-platform:
container_name: kosmos-platform # the name of the container
restart: unless-stopped # automatically start on boot, and restart if container dies
image: ghcr.io/kosmos-lab/kosmos-platform # the kosmos platform image
volumes:
- ./config:/app/config #the config folder
- ./db:/app/db # the folder of the database
- ./plugins:/app/plugins # the plugins folder, drop kosmos plugin zips in here
- ./rules:/app/rules/rules # the rules created with KREE will be saved here
- ./oz/ui.json:/app/web/oz/assets/ui.json # the custom Wizard-of-Oz UI config will be saved in this file
environment:
# the users to setup, here we create 3 users with simple passwords
- USERS=[{"username":"admin","level":100,"password":"verysecret"},{"username":"user","level":1,"password":"pass"},{"username":"user2","level":1,"password":"pass"}]
- PUID=1000 # the userid to run the process
- PGID=1000 # the groupid to run the process
ports:
- "18080:18080" # this is the default port of the webserver
- "1883:1883" # this is the MQTT port
Please change the file to your liking (especially the user configuration). Important: if you want to change the HTTP port to another port please change both instances of 18080 here and also change the port in the configuration file (see config)
prepare needed files and folders¶
Before you start it please make sure the folder structure exists.
# create the empty directories, if needed
mkdir -p rules config db oz
# create an empty ui.json for the wizard of oz.
echo "[]" > oz/ui.json
start the container¶
Afterwards you can start it with:
docker-compose up -d
native without docker¶
download from github¶
git clone https://github.com/kosmos-lab/kosmos-platform.git
download the latest zip from github and extract it.
wget https://github.com/kosmos-lab/kosmos-platform/archive/refs/heads/main.zip
unzip main.zip
install java >= 11 (jdk14 recommended)¶
To start the kosmos platform java 11 or newer is needed. Refer to java.com, oracle.com or your distribution on how to install jre or jdk on your system.
prepare needed files and folders¶
Before you start it please make sure the folder structure exists.
# create the empty directories, if needed
mkdir -p rules config db oz
# create an empty ui.json for the wizard of oz.
echo "[]" > oz/ui.json
(optional) enable execution of KREE scripts¶
To be able to have a working KREE instance it is needed to have python3/python3-pip installed, and download the requirements for KREE.
python3 -m pip install -r rules/requirements.txt
python -m pip install -r rules/requirements.txt
start the application¶
java -jar target/kosmos.jar
java -jar target/kosmos.jar -c config/config.json
java -jar target/kosmos.jar -c myconfig.json
kubernetes example¶
This is an example for a kubernetes deployment, the kubernetes deployment does not setup home assistant automatically. Kubernetes is a rather complex issue and this is only to have a starting point if needed. We recommend using the docker-compose deployment.
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.kompose.service: kosmos-platform
name: kosmos-platform
namespace: kosmos
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: kosmos-platform
strategy:
type: Recreate
template:
metadata:
labels:
io.kompose.service: kosmos-platform
spec:
containers:
- env:
- name: PGID
value: "1000"
- name: PUID
value: "1000"
- name: SETUPHA
value: "0"
- name: USE_ROS2
value: "0"
- name: USERS
value: '[{"username":"ha","password":"<update>","level":1},{"username":"admin","level":100,"password":"<update>"}]'
- name: OWM_KEY
value: "<update>"
image: ghcr.io/kosmos-lab/kosmos-platform:0.8.7a
imagePullPolicy: Always
name: kosmos-platform
ports:
- containerPort: 18080
- containerPort: 1883
resources: {}
volumeMounts:
- mountPath: /app/config
name: kosmos-platform-config
- mountPath: /app/db
name: kosmos-platform-db
- mountPath: /app/plugins
name: kosmos-platform-plugins
- mountPath: /app/rules/rules
name: kosmos-platform-rules
- mountPath: /app/web/oz/assets/ui.json
name: kosmos-platform-uijson
restartPolicy: Always
volumes:
- hostPath:
path: /gv0/kosmos/config
name: kosmos-platform-config
- hostPath:
path: /gv0/kosmos/db
name: kosmos-platform-db
- hostPath:
path: /gv0/kosmos/plugins
name: kosmos-platform-plugins
- hostPath:
path: /gv0/kosmos/rules
name: kosmos-platform-rules
- hostPath:
path: /gv0/kosmos/oz/ui.json
name: kosmos-platform-uijson
status: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: kosmos-platform
name: kosmos-platform
namespace: kosmos
spec:
type: LoadBalancer
ports:
- name: "18080"
port: 18080
targetPort: 18080
- name: "1883"
port: 1883
targetPort: 1883
selector:
io.kompose.service: kosmos-platform
status:
loadBalancer: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kosmos
namespace: kosmos
spec:
rules:
- host: "kosmos.<update>"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kosmos-platform
port:
number: 18080