#90 create kube_ops_view package

This commit is contained in:
Henning Jacobs
2017-01-14 13:25:03 +01:00
parent b6d75bf240
commit 850683c368
11 changed files with 21 additions and 17 deletions

2
.gitignore vendored
View File

@@ -3,6 +3,6 @@ __pycache__
*.pyc
.idea/
**/node_modules/
static/build/
kube_ops_view/static/build/
*-secret
npm-debug.log*

View File

@@ -12,13 +12,11 @@ EXPOSE 8080
COPY requirements.txt /
RUN pip3 install -r /requirements.txt
COPY app.py /
COPY templates /templates
COPY kube_ops_view /
COPY app /app
COPY static /static
WORKDIR /app
RUN npm install && npm run build
WORKDIR /
CMD /app.py
ENTRYPOINT ["/usr/bin/python3", "-m", "kube_ops_view"]

View File

@@ -45,7 +45,7 @@ You can run the app locally:
$ pip3 install -r requirements.txt
$ kubectl proxy &
$ (cd app && npm start &)
$ ./app.py
$ python3 -m kube_ops_view
Now direct your browser to http://localhost:8080
@@ -74,7 +74,7 @@ You can start the app in "mock mode" to see all UI features without running any
$ pip3 install -r requirements.txt
$ (cd app && npm start &)
$ MOCK=true ./app.py
$ MOCK=true python3 -m kube_ops_view
You can also run the latest Docker image directly:

View File

@@ -4,7 +4,7 @@
"description": "=========================== Kubernetes Operational View ===========================",
"main": "src/app.js",
"config": {
"buildDir": "../static/build"
"buildDir": "../kube_ops_view/static/build"
},
"scripts": {
"prestart": "npm install",

View File

View File

@@ -0,0 +1,3 @@
from .main import main
main()

15
app.py → kube_ops_view/main.py Executable file → Normal file
View File

@@ -21,6 +21,7 @@ import signal
import string
import time
import tokens
from pathlib import Path
from queue import Queue
from redlock import Redlock
@@ -244,14 +245,16 @@ def health():
@app.route('/')
@authorize
def index():
app_js = None
for entry in os.listdir('static/build'):
if entry.startswith('app'):
app_js = entry
static_build_path = Path(__file__).parent / 'static' / 'build'
candidates = sorted(static_build_path.glob('app*.js'))
if candidates:
app_js = candidates[0].name
if app.debug:
# cache busting for local development
app_js += '?_={}'.format(time.time())
break
else:
logging.error('Could not find JavaScript application bundle app*.js in {}'.format(static_build_path))
flask.abort(503, 'JavaScript application bundle not found (missing build)')
return flask.render_template('index.html', app_js=app_js)
@@ -553,7 +556,7 @@ def exit_gracefully(signum, frame):
gevent.spawn(shutdown)
if __name__ == '__main__':
def main():
signal.signal(signal.SIGTERM, exit_gracefully)
http_server = gevent.wsgi.WSGIServer(('0.0.0.0', SERVER_PORT), app)
gevent.spawn(update)

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB