Skip to content

kubectl apply -f kompose # working k8s manifests #1263

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d8ad2a4
'docker-compose ...' is now 'docker compose ...' and has different sy…
jamie-mint Nov 9, 2022
f23ec47
copypasta considered harmful
jamie-mint Nov 28, 2022
ce81600
initialize influxdb and use v2
somaesthete Dec 27, 2022
d18237b
Merge branch 'master' of github.com:nargetdev/Mycodo
somaesthete Dec 27, 2022
b49f074
adjust docker-compose.yml for kompose' sake
somaesthete Dec 27, 2022
341a685
uploaded some images (for arm) but those volumes do not get initialized
somaesthete Dec 27, 2022
38fe6cc
Merge branch 'master' of github.com:nargetdev/Mycodo
somaesthete Jan 16, 2023
6a0e9d0
explicit image names .. no build for sanity check
somaesthete Jan 16, 2023
0534b35
these images work on compose side
somaesthete Jan 16, 2023
fc285ce
kompose convert --service-group-mode=label -o kompose-multicontainermode
somaesthete Jan 16, 2023
dd8dfc7
kompose convert --service-group-mode=label -o kompose-multicontainer
somaesthete Jan 16, 2023
72db441
web interface is up
somaesthete Jan 17, 2023
499bb3f
bring influx back in
somaesthete Jan 17, 2023
d85b753
images synced back to docker-compose.yml
somaesthete Jan 17, 2023
6b368c4
booya $> kubectl apply -f kompose
somaesthete Jan 17, 2023
d022641
some explainer in DOCKER.md
somaesthete Jan 17, 2023
07f7b1b
bootstrapping from NFS volumes works. This is running on one of the …
somaesthete Mar 7, 2023
69b9021
Merge branch 'master' of github.com:kizniche/Mycodo into komposed
somaesthete Apr 5, 2023
e472c5e
changed somanas ip on network... should be parametrized helm
somaesthete Apr 5, 2023
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
13 changes: 13 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## k8s notes

@nargetdev managed to configure a `kompose convert` adaptation to run Mycodo on kubernetes.

`kompose` does not quite work out of the box because of a difference in how `docker compose` and `k8s` handle volume initialization..
namely `k8s` does not handle volume initialization at all. For this reason an `initContainer:` is invoked in `mycododaemon-deployment.yaml`

To apply the mycodo manifests to a cluster:

kubectl apply -f kompose

My workflow has been to modify docker-compose.yml, and then run `./kompose_output_directory.sh` to regenerate the `kompose` directory.

# Docker

This effort is to get Mycodo running in Docker containers with all features working. Many parts of the system work, however there are also many that do not.
Expand Down
96 changes: 64 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,43 @@ version: "3.7"

services:

mycodo_influxdb:
container_name: mycodo_influxdb
build:
context: ./
dockerfile: docker/influxdb/Dockerfile
env_file:
- 'docker/influxdb/env.influxdb'
## Deprecated untill I read the prev config.

# mycodo_influxdb:
# container_name: mycodo_influxdb
# build:
# context: ./
# dockerfile: docker/influxdb/Dockerfile
# env_file:
# - 'docker/influxdb/env.influxdb'
# volumes:
# - mycodo_influxdb:/var/lib/influxdb
# ports:
# - 8086:8086

## InfluxDBv2 setup
mycodoinfluxdb:
ports:
- 8086:8086
volumes:
- mycodo_influxdb:/var/lib/influxdb
- mycodo_influxdb:/var/lib/influxdb2
image: influxdb:latest
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=mycodo
- DOCKER_INFLUXDB_INIT_PASSWORD=mmdu77sj3nIoiajjs
- DOCKER_INFLUXDB_INIT_ORG=mycodo
- DOCKER_INFLUXDB_INIT_BUCKET=mycodo_db

mycodo_nginx:
container_name: mycodo_nginx
mycodonginx:
# labels:
# - kompose.service.group=sidecar
container_name: mycodonginx
restart: always
build:
context: ./
dockerfile: docker/nginx/Dockerfile
image: nargetdev/mycodonginx:c0.0.0-v8.15.1
# build:
# context: ./
# dockerfile: docker/nginx/Dockerfile
volumes:
- mycodo:/usr/local/mycodo
- mycodo_log:/var/log/mycodo
Expand All @@ -26,11 +47,16 @@ services:
- 80:80
- 443:443
depends_on:
- mycodo_flask
- mycodoflask

mycodo_daemon:
container_name: mycodo_daemon
image: app
mycododaemon:
image: nargetdev/mycodoapp:c0.0.2-v8.15.1
ports:
- "9080"
# labels:
# - kompose.service.group=sidecar
container_name: mycododaemon
# image: nargetdev/mycodoflask:c0.0.0-v8.15.1
restart: always
environment:
- TZ=America/New_York # See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for valid time zones
Expand All @@ -47,22 +73,26 @@ services:
- mycodo_custom_user_scripts:/home/mycodo/mycodo/user_scripts
- mycodo_log:/var/log/mycodo
- mycodo_ssl_certs:/home/mycodo/mycodo/mycodo_flask/ssl_certs
- /dev:/dev
- /sys:/sys
- /opt:/opt
# - /dev:/dev
- mycodo_sys:/sys
- mycodo_opt:/opt
privileged: true
command: bash -c "wget --quiet --no-check-certificate -p http://mycodo_nginx/ -O /dev/null &&
command: bash -c "wget --quiet --no-check-certificate -p http://mycodonginx/ -O /dev/null &&
PYTHONPATH=/home/mycodo /home/mycodo/env/bin/python mycodo_daemon.py"
depends_on:
- mycodo_flask
- mycodoflask

mycodo_flask:
container_name: mycodo_flask
image: app
hostname: Mycodo # Change to your desired hostname
build:
context: ./
dockerfile: docker/Dockerfile
mycodoflask:
image: nargetdev/mycodoapp:c0.0.2-v8.15.1
ports:
- "9080"
# labels:
# - kompose.service.group=sidecar
container_name: mycodoflask
hostname: mycodohost # Change to your desired hostname
# build:
# context: ./
# dockerfile: docker/Dockerfile
restart: always
environment:
- TZ=America/New_York # See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for valid time zones
Expand All @@ -82,12 +112,12 @@ services:
- mycodo_log:/var/log/mycodo
- mycodo_ssl_certs:/home/mycodo/mycodo/mycodo_flask/ssl_certs
- mycodo_influxdb:/var/lib/influxdb
- /dev:/dev
# - /dev:/dev
- /var/run/docker.sock:/var/run/docker.sock:ro # Permits container to restart itself
privileged: true
command: /home/mycodo/env/bin/python -m gunicorn --workers 1 --bind unix:/usr/local/mycodo/mycodoflask.sock start_flask_ui:app
depends_on:
- mycodo_influxdb
# depends_on:
# - mycodoinfluxdb

# Uncomment the following blocks and rebuild to enable Grafana and/or Telegraf

Expand Down Expand Up @@ -128,3 +158,5 @@ volumes:
mycodo_log:
mycodo_influxdb:
mycodo_grafana:
mycodo_opt:
mycodo_sys:
9 changes: 9 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build:
docker compose build

run:
docker compose up

clean:
docker compose down
docker system prune -a
Empty file added echo
Empty file.
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-cameras-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-cameras
name: mycodo-cameras
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-actions
name: mycodo-custom-actions
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-functions
name: mycodo-custom-functions
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-inputs
name: mycodo-custom-inputs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-outputs
name: mycodo-custom-outputs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-user-css
name: mycodo-custom-user-css
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-user-js
name: mycodo-custom-user-js
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-user-scripts
name: mycodo-custom-user-scripts
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-custom-widgets
name: mycodo-custom-widgets
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-databases-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-databases
name: mycodo-databases
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-env-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-env
name: mycodo-env
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-influxdb-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-influxdb
name: mycodo-influxdb
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-log-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-log
name: mycodo-log
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo
name: mycodo
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
14 changes: 14 additions & 0 deletions kompose-multicontainer/mycodo-ssl-certs-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: mycodo-ssl-certs
name: mycodo-ssl-certs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
Loading