#90 create kube_ops_view package
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,6 @@ __pycache__
|
|||||||
*.pyc
|
*.pyc
|
||||||
.idea/
|
.idea/
|
||||||
**/node_modules/
|
**/node_modules/
|
||||||
static/build/
|
kube_ops_view/static/build/
|
||||||
*-secret
|
*-secret
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
|||||||
@@ -12,13 +12,11 @@ EXPOSE 8080
|
|||||||
COPY requirements.txt /
|
COPY requirements.txt /
|
||||||
RUN pip3 install -r /requirements.txt
|
RUN pip3 install -r /requirements.txt
|
||||||
|
|
||||||
COPY app.py /
|
COPY kube_ops_view /
|
||||||
COPY templates /templates
|
|
||||||
COPY app /app
|
COPY app /app
|
||||||
COPY static /static
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN npm install && npm run build
|
RUN npm install && npm run build
|
||||||
|
|
||||||
WORKDIR /
|
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
|
$ pip3 install -r requirements.txt
|
||||||
$ kubectl proxy &
|
$ kubectl proxy &
|
||||||
$ (cd app && npm start &)
|
$ (cd app && npm start &)
|
||||||
$ ./app.py
|
$ python3 -m kube_ops_view
|
||||||
|
|
||||||
Now direct your browser to http://localhost:8080
|
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
|
$ pip3 install -r requirements.txt
|
||||||
$ (cd app && npm start &)
|
$ (cd app && npm start &)
|
||||||
$ MOCK=true ./app.py
|
$ MOCK=true python3 -m kube_ops_view
|
||||||
|
|
||||||
You can also run the latest Docker image directly:
|
You can also run the latest Docker image directly:
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "=========================== Kubernetes Operational View ===========================",
|
"description": "=========================== Kubernetes Operational View ===========================",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"config": {
|
"config": {
|
||||||
"buildDir": "../static/build"
|
"buildDir": "../kube_ops_view/static/build"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prestart": "npm install",
|
"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 string
|
||||||
import time
|
import time
|
||||||
import tokens
|
import tokens
|
||||||
|
from pathlib import Path
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from redlock import Redlock
|
from redlock import Redlock
|
||||||
|
|
||||||
@@ -244,14 +245,16 @@ def health():
|
|||||||
@app.route('/')
|
@app.route('/')
|
||||||
@authorize
|
@authorize
|
||||||
def index():
|
def index():
|
||||||
app_js = None
|
static_build_path = Path(__file__).parent / 'static' / 'build'
|
||||||
for entry in os.listdir('static/build'):
|
candidates = sorted(static_build_path.glob('app*.js'))
|
||||||
if entry.startswith('app'):
|
if candidates:
|
||||||
app_js = entry
|
app_js = candidates[0].name
|
||||||
if app.debug:
|
if app.debug:
|
||||||
# cache busting for local development
|
# cache busting for local development
|
||||||
app_js += '?_={}'.format(time.time())
|
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)
|
return flask.render_template('index.html', app_js=app_js)
|
||||||
|
|
||||||
|
|
||||||
@@ -553,7 +556,7 @@ def exit_gracefully(signum, frame):
|
|||||||
gevent.spawn(shutdown)
|
gevent.spawn(shutdown)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
signal.signal(signal.SIGTERM, exit_gracefully)
|
signal.signal(signal.SIGTERM, exit_gracefully)
|
||||||
http_server = gevent.wsgi.WSGIServer(('0.0.0.0', SERVER_PORT), app)
|
http_server = gevent.wsgi.WSGIServer(('0.0.0.0', SERVER_PORT), app)
|
||||||
gevent.spawn(update)
|
gevent.spawn(update)
|
||||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user