#90 create kube_ops_view package
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,6 @@ __pycache__
|
||||
*.pyc
|
||||
.idea/
|
||||
**/node_modules/
|
||||
static/build/
|
||||
kube_ops_view/static/build/
|
||||
*-secret
|
||||
npm-debug.log*
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
0
kube_ops_view/__init__.py
Normal file
0
kube_ops_view/__init__.py
Normal file
3
kube_ops_view/__main__.py
Normal file
3
kube_ops_view/__main__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .main import main
|
||||
|
||||
main()
|
||||
21
app.py → kube_ops_view/main.py
Executable file → Normal file
21
app.py → kube_ops_view/main.py
Executable file → Normal 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
|
||||
if app.debug:
|
||||
# cache busting for local development
|
||||
app_js += '?_={}'.format(time.time())
|
||||
break
|
||||
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())
|
||||
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)
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user