Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

First k8s

Michal Rutka49fac201130a
diff --git a/swarm/README.md b/swarm/README.md
index 9068404fa..c0ddd2775 100644
--- a/swarm/README.md
+++ b/swarm/README.md
@@ -23,6 +23,10 @@ see [Google graveyard](https://killedbygoogle.com/)
```docker service logs <service_name> [--follow]```
+Deploy on Kubernetes (works only on builtin Kubernetes in Docker Desktop)
+
+```docker stack deploy --orchestrator kubernetes --compose-file swarm/kube-docker-compose.yml demo```
+
### Swarm advantages:
- no manual deployments
diff --git a/swarm/kube-docker-compose.yml b/swarm/kube-docker-compose.yml
new file mode 100644
index 000000000..82b1bee73
--- /dev/null
+++ b/swarm/kube-docker-compose.yml
@@ -0,0 +1,245 @@
+# OpenRemote v3
+#
+# By default running this profile installs the stack in swarm on https://localhost using a
+# self-signed SSL certificate, with username 'admin' and password 'secret'.
+#
+# Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.
+#
+# Start a demo stack in the project root directory with:
+#
+# dosker swarm init
+# docker pull openremote/deployment
+# docker-compose -p demo up -d --no-build deployment
+# docker stack deploy --compose-file docker-compose-swarm.yml demo
+#
+# Stop the stack:
+#
+# docker stack rm demo
+#
+# For full documentation, see profile/deploy.yml
+#
+# For swarm (production) use version 3, for developement use version 2
+version: '3.7'
+
+# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
+volumes:
+ proxy-data:
+ postgresql-data:
+
+services:
+
+ proxy:
+
+ image: openremote/proxy:${DATE_TAG:-latest}
+ environment:
+ TZ: Europe/Amsterdam
+ DOMAINNAME: ${DOMAINNAME:-localhost}
+ LE_EMAIL: ${LE_EMAIL:[email protected]}
+
+ # Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt
+ # when testing (this is important, you are limited to 5 duplicate certificates per week!)
+ # LE_EXTRA_ARGS: '--staging --logs-dir=/etc/letsencrypt'
+
+ # Traffic should be forwarded to this service (defaults to manager:8080)
+ # PROXY_BACKEND_HOST: manager
+ # PROXY_BACKEND_PORT: 8080
+
+ # The proxy supports up to 10 custom redirects from hostname to any path on the
+ # backend service. This can be used to give consoles a vanity domain name.
+ # PROXY_HOST_REDIRECT_1_NAME: www.my-console-master.tld
+ # PROXY_HOST_REDIRECT_1_TARGET: /console/master
+ # PROXY_HOST_REDIRECT_2_NAME: www.my-console-tenant-a.tld
+ # PROXY_HOST_REDIRECT_2_TARGET: /console/building
+ # PROXY_HOST_REDIRECT_3_NAME: ...
+
+ # Customize proxy log, defaults to 'notice', requests are logged at 'info'.
+ # Available levels are: emerg, alert, crit, err, warning, notice, info, debug
+ # PROXY_LOGLEVEL: 'notice'
+
+ # Run proxy, obtain and automatically renew SSL certificates if DOMAINNAME is not localhost. Use
+ # the command 'help' to get a list of all options.
+ command: run
+
+ # Expose a public web service mapped to ports on the host.
+ ports:
+ - "80:80"
+ - "443:443"
+
+ volumes:
+ - proxy-data:/deployment
+ # Override the haproxy.cfg with custom file
+ # -${MY_PROXY_CONFIG_FILE}:/etc/haproxy/haproxy.cfg
+
+ deploy:
+ replicas: 1
+
+ # This configuration uses the manager's deployment-specific data such as map tiles,
+ # console application static resources (HTML, JS, CSS), extensions, and other
+ # configuration files which were baked into the managers image.
+ manager:
+
+ image: openremote/manager-swarm:${DATE_TAG:-latest}
+ environment:
+
+ # It is important that all services have the same timezone and are time synchronized.
+ # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
+ TZ: Europe/Amsterdam
+
+ # If developer mode is enabled, all setup tasks will be executed on application startup.
+ # This will clean all data in the database, and then import demo/test data. Some caching and
+ # other runtime performance-optimizations will also be disabled.
+ DEV_MODE: ${DEV_MODE:-false}
+
+ # This switch can wipe your database, this is the factory reset!
+ SETUP_WIPE_CLEAN_INSTALL: ${SETUP_WIPE_CLEAN_INSTALL:-true}
+ SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
+
+ # When you are ready to permanently install your project, replace it with the next lines...
+ # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
+
+ # Configure SMTP smart host, to send password reset emails etc.
+ #SETUP_EMAIL_HOST: smtp-host.demo.tld
+ #SETUP_EMAIL_USER: 'smtp-user'
+ #SETUP_EMAIL_PASSWORD: 'smtp-password'
+ #SETUP_EMAIL_PORT: 25
+ #SETUP_EMAIL_TLS: 'true'
+ #SETUP_EMAIL_FROM_KEYCLOAK: '[email protected]'
+ #SETUP_EMAIL_FROM_DEFAULT: '[email protected]'
+
+ # Other demo data can be imported as needed, these examples only use the simulator protocol.
+ SETUP_IMPORT_DEMO_USERS: 'true'
+ SETUP_IMPORT_DEMO_ASSETS: 'true'
+ SETUP_IMPORT_DEMO_RULES: 'true'
+ SETUP_IMPORT_DEMO_SCENES: 'true'
+
+ # Create a demo agent with example configurations for all built-in protocols:
+ #
+ # - KNX IP gateway
+ # - Velbus IP gateway or serial bridge
+ #
+ SETUP_IMPORT_DEMO_AGENT: 'true'
+ SETUP_IMPORT_DEMO_AGENT_KNX: 'false'
+ # SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP: '10.0.0.11'
+ # SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP: '10.0.0.12'
+ SETUP_IMPORT_DEMO_AGENT_VELBUS: 'false'
+ # SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT: 'COM3'
+ # TODO: Additional docker settings are necessary to use com ports and multicast from within containers
+
+ # The public host name of this OpenRemote installation. This name is used in bearer tokens
+ # and must be the name you access the web services under. If you change proxy#DOMAINNAME, also
+ # change this to match.
+ IDENTITY_NETWORK_HOST: ${IDENTITY_NETWORK_HOST:-localhost}
+
+ # Set if SSL is enabled on the frontend reverse proxy and all internal proxies should assume https
+ IDENTITY_NETWORK_SECURE: 'true'
+
+ # The public port of this OpenRemote installation.
+ IDENTITY_NETWORK_WEBSERVER_PORT: 443
+
+ # The service-internal JDBC connection URL for the database service.
+ DATABASE_CONNECTION_URL: jdbc:postgresql://postgresql/openremote
+
+ # The database connection settings, passwords should be changed in production!
+ DATABASE_USERNAME: openremote
+ DATABASE_PASSWORD: CHANGE_ME_DB_USER_PASSWORD
+ DATABASE_MIN_POOL_SIZE: 5
+ DATABASE_MAX_POOL_SIZE: 20
+ DATABASE_CONNECTION_TIMEOUT_SECONDS: 300
+
+ # The service-internal host name and port of the identity provider.
+ KEYCLOAK_HOST: keycloak
+ KEYCLOAK_PORT: 8080
+ MASTER_REALM_KEYCLOAK_THEME: ${MASTER_REALM_KEYCLOAK_THEME:-openremote}
+
+ # The service-internal webservice interface binding, bind to all interfaces
+ # when running in container. Default is 127.0.0.1.
+ WEBSERVER_LISTEN_HOST: 0.0.0.0
+
+ APP_DEFAULT: ${APP_DEFAULT:-manager}
+
+ JAVA_OPTS: '-Xms400m -Xmx400m
+ -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
+ -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
+ -XX:MaxDirectMemorySize=25m
+ -XX:NativeMemoryTracking=summary
+ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof'
+
+ deploy:
+ replicas: 1
+
+ keycloak:
+
+ # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
+ image: openremote/keycloak:${DATE_TAG:-latest}
+
+ environment:
+
+ # It is important that all services have the same timezone and are time synchronized.
+ # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
+ TZ: Europe/Amsterdam
+
+ # Switch to DEBUG to diagnose Keycloak problems.
+ KEYCLOAK_LOGLEVEL: INFO
+
+ # When you are ready to permanently install your project, replace it with the next line ...
+ # SETUP_ADMIN_PASSWORD: # Allow override on CLI
+
+ # Configure how Keycloak connects to the database
+ DB_VENDOR: postgres
+ DB_ADDR: postgresql
+ DB_PORT: 5432
+ DB_DATABASE: openremote
+ DB_USER: openremote
+ DB_SCHEMA: public
+ DB_PASSWORD: CHANGE_ME_DB_USER_PASSWORD
+ KEYCLOAK_USER: admin
+ PROXY_ADDRESS_FORWARDING: 'true'
+
+ # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
+ KEYCLOAK_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
+
+ # Custom JVM options (increase heap size if required)
+ JAVA_OPTS: '-Xms300m -Xmx300m
+ -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=200m
+ -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
+ -XX:MaxDirectMemorySize=25m
+ -XX:NativeMemoryTracking=summary
+ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
+ -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true'
+
+ ports:
+ - "8081:8080"
+
+ deploy:
+ replicas: 1
+
+ # This configuration stores postgresql data in a Docker volume. You manage this volume
+ # independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
+ # Alternatively, you can store postgresql data in a directory on your host.
+ postgresql:
+ # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
+ image: openremote/postgresql:${DATE_TAG:-latest}
+
+ environment:
+
+ # It is important that all services have the same timezone and are time synchronized.
+ # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
+ TZ: Europe/Amsterdam
+
+ # Create database and user if there is no data. For production, run
+ # this once with your volume mapping for the data directory (see docker-compose.yml),
+ # then remove the variables and restart to preserve the stored data. It
+ # doesn't hurt if you don't remove it, an existing will never be reconfigured.
+ POSTGRES_DB: openremote
+ POSTGRES_USER: openremote
+ POSTGRES_PASSWORD: CHANGE_ME_DB_USER_PASSWORD
+
+ # You can open an SQL console on a running container with:
+ # docker exec -it <container ID> psql -U openremote
+
+ volumes:
+ - postgresql-data:/var/lib/postgresql/data
+
+ deploy:
+ replicas: 1
+