Browse Source
Merge pull request #4 from nmasse-itix/main
Update the kiosk application to have an online and offline version
ca-cert-and-multi-ks
Bertrand d'Hérouville
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with
97 additions and
96 deletions
-
application/Dockerfile
-
application/README.md
-
application/src/app.py
-
application/src/local/index.html
-
application/src/online/index.html
-
application/src/static/style.css
-
application/src/templates/index.html
-
rpms/SOURCES/microshift-main-manifest.yaml
|
|
|
@ -1,21 +1,5 @@ |
|
|
|
# Use an official Python runtime as a parent image |
|
|
|
FROM python:3.8-slim |
|
|
|
|
|
|
|
# Set the working directory in the container |
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
# Copy the current directory contents into the container at /app |
|
|
|
COPY src /app |
|
|
|
|
|
|
|
# Install any needed packages specified in requirements.txt |
|
|
|
RUN pip install --trusted-host pypi.python.org Flask |
|
|
|
|
|
|
|
# Make port 80 available to the world outside this container |
|
|
|
EXPOSE 5000 |
|
|
|
|
|
|
|
# Define environment variable |
|
|
|
ENV NAME World |
|
|
|
|
|
|
|
# Run app.py when the container launches |
|
|
|
CMD ["python", "app.py"] |
|
|
|
# Use the Nginx unprivileged as a parent image |
|
|
|
FROM docker.io/nginxinc/nginx-unprivileged:1.25-alpine |
|
|
|
|
|
|
|
# Copy the static content into the container at /usr/share/nginx/html/ |
|
|
|
COPY src/local/index.html /usr/share/nginx/html/ |
|
|
|
|
|
|
|
@ -1,5 +1,7 @@ |
|
|
|
# Sample kiosk application |
|
|
|
|
|
|
|
## Local version |
|
|
|
|
|
|
|
Build the container image. |
|
|
|
|
|
|
|
```sh |
|
|
|
@ -9,13 +11,13 @@ podman build -t localhost/kiosk-app:latest . |
|
|
|
Run the container image. |
|
|
|
|
|
|
|
```sh |
|
|
|
podman run -it --rm --name kiosk-app -p 5000:5000 localhost/kiosk-app:latest |
|
|
|
podman run -it --rm --name kiosk-app -p 8080:8080 localhost/kiosk-app:latest |
|
|
|
``` |
|
|
|
|
|
|
|
Test it. |
|
|
|
|
|
|
|
```sh |
|
|
|
curl -I http://localhost:5000/ |
|
|
|
curl -I http://localhost:8080/ |
|
|
|
``` |
|
|
|
|
|
|
|
Login to the registry. |
|
|
|
@ -30,3 +32,7 @@ Publish it to the registry. |
|
|
|
podman tag localhost/kiosk-app:latest quay.io/nmasse_itix/kiosk-app:latest |
|
|
|
podman push quay.io/nmasse_itix/kiosk-app:latest |
|
|
|
``` |
|
|
|
|
|
|
|
## Online version |
|
|
|
|
|
|
|
The online version is deployed using [Netlify](https://app.netlify.com/) at [redhat-kiosk-app.netlify.app](https://redhat-kiosk-app.netlify.app/). |
|
|
|
|
|
|
|
@ -1,20 +0,0 @@ |
|
|
|
import platform |
|
|
|
from flask import Flask, render_template |
|
|
|
|
|
|
|
app = Flask(__name__, template_folder="/app/templates") |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/') |
|
|
|
def system_info(): |
|
|
|
system_info = { |
|
|
|
'System': platform.system(), |
|
|
|
'Node Name': platform.node(), |
|
|
|
'Release': platform.release(), |
|
|
|
'Version': platform.version(), |
|
|
|
'Machine': platform.machine(), |
|
|
|
'Processor': platform.processor() |
|
|
|
} |
|
|
|
return render_template('index.html', system_info=system_info) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
app.run(host="0.0.0.0", debug=True) |
|
|
|
@ -0,0 +1,36 @@ |
|
|
|
<!DOCTYPE html> |
|
|
|
<html lang="en"> |
|
|
|
<head> |
|
|
|
<meta charset="UTF-8"> |
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
|
<meta http-equiv="refresh" content="5"> |
|
|
|
<style> |
|
|
|
body { |
|
|
|
font-family: Arial, sans-serif; |
|
|
|
margin: 0; |
|
|
|
padding: 0; |
|
|
|
background-color: #f2f2f2; |
|
|
|
} |
|
|
|
|
|
|
|
header { |
|
|
|
background-color: #333; |
|
|
|
color: white; |
|
|
|
padding: 1em; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
main { |
|
|
|
margin: 2em; |
|
|
|
} |
|
|
|
</style> |
|
|
|
<title>Kiosk application</title> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<header> |
|
|
|
<h1>Kiosk application</h1> |
|
|
|
</header> |
|
|
|
<main> |
|
|
|
<p>You are viewing the <strong>local</strong> version.</p> |
|
|
|
</main> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
@ -0,0 +1,36 @@ |
|
|
|
<!DOCTYPE html> |
|
|
|
<html lang="en"> |
|
|
|
<head> |
|
|
|
<meta charset="UTF-8"> |
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
|
<meta http-equiv="refresh" content="5"> |
|
|
|
<style> |
|
|
|
body { |
|
|
|
font-family: Arial, sans-serif; |
|
|
|
margin: 0; |
|
|
|
padding: 0; |
|
|
|
background-color: #f2f2f2; |
|
|
|
} |
|
|
|
|
|
|
|
header { |
|
|
|
background-color: #333; |
|
|
|
color: white; |
|
|
|
padding: 1em; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
main { |
|
|
|
margin: 2em; |
|
|
|
} |
|
|
|
</style> |
|
|
|
<title>Kiosk application</title> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<header> |
|
|
|
<h1>Kiosk application</h1> |
|
|
|
</header> |
|
|
|
<main> |
|
|
|
<p>You are viewing the <strong>online</strong> version.</p> |
|
|
|
</main> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
@ -1,18 +0,0 @@ |
|
|
|
/* static/style.css */ |
|
|
|
body { |
|
|
|
font-family: Arial, sans-serif; |
|
|
|
margin: 0; |
|
|
|
padding: 0; |
|
|
|
background-color: #f2f2f2; |
|
|
|
} |
|
|
|
|
|
|
|
header { |
|
|
|
background-color: #333; |
|
|
|
color: white; |
|
|
|
padding: 1em; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
main { |
|
|
|
margin: 2em; |
|
|
|
} |
|
|
|
@ -1,29 +0,0 @@ |
|
|
|
<!-- templates/system_info.html --> |
|
|
|
<!DOCTYPE html> |
|
|
|
<html lang="en"> |
|
|
|
<head> |
|
|
|
<meta charset="UTF-8"> |
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> |
|
|
|
<title>System Information</title> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<header> |
|
|
|
<h1>System Information</h1> |
|
|
|
</header> |
|
|
|
<main> |
|
|
|
<table> |
|
|
|
<tr> |
|
|
|
<th>Attribute</th> |
|
|
|
<th>Value</th> |
|
|
|
</tr> |
|
|
|
{% for key, value in system_info.items() %} |
|
|
|
<tr> |
|
|
|
<td>{{ key }}</td> |
|
|
|
<td>{{ value }}</td> |
|
|
|
</tr> |
|
|
|
{% endfor %} |
|
|
|
</table> |
|
|
|
</main> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
@ -18,6 +18,7 @@ data: |
|
|
|
global |
|
|
|
log stdout format raw local0 |
|
|
|
maxconn 4000 |
|
|
|
ssl-server-verify none |
|
|
|
|
|
|
|
defaults |
|
|
|
mode http |
|
|
|
@ -36,20 +37,25 @@ data: |
|
|
|
|
|
|
|
frontend webserver |
|
|
|
bind 0.0.0.0:8080 |
|
|
|
|
|
|
|
# The following configuration monitors availability of the main backend |
|
|
|
# and if there is no more available servers in the main backend (online), |
|
|
|
# it redirects to the backup backend (local). |
|
|
|
acl main_service_failed nbsrv(appserver_main) le 0 |
|
|
|
use_backend appserver_backup if main_service_failed |
|
|
|
default_backend appserver_main |
|
|
|
|
|
|
|
backend appserver_main |
|
|
|
http-request set-header Host ipinfo.io |
|
|
|
http-request set-header Host redhat-kiosk-app.netlify.app |
|
|
|
balance roundrobin |
|
|
|
# 34.117.186.192 is one of the IP Addresses serving the website "ipinfo.io" |
|
|
|
server svc-main1 34.117.186.192:80 check |
|
|
|
# IP Addresses of the Netlify's APEX Load Balancer (apex-loadbalancer.netlify.com) |
|
|
|
server svc-main1 75.2.60.5:443 check ssl sni str(redhat-kiosk-app.netlify.app) |
|
|
|
server svc-main2 99.83.231.61:443 check ssl sni str(redhat-kiosk-app.netlify.app) |
|
|
|
|
|
|
|
backend appserver_backup |
|
|
|
http-request set-header Host kiosk-app.kiosk-app.svc.cluster.local |
|
|
|
balance roundrobin |
|
|
|
server svc-backup1 kiosk-app:5000 check |
|
|
|
server svc-backup1 kiosk-app:8080 check |
|
|
|
--- |
|
|
|
apiVersion: apps/v1 |
|
|
|
kind: Deployment |
|
|
|
@ -117,7 +123,7 @@ spec: |
|
|
|
- name: kiosk-app |
|
|
|
image: quay.io/nmasse_itix/kiosk-app:latest |
|
|
|
ports: |
|
|
|
- containerPort: 5000 |
|
|
|
- containerPort: 8080 |
|
|
|
--- |
|
|
|
apiVersion: v1 |
|
|
|
kind: Service |
|
|
|
@ -127,7 +133,7 @@ metadata: |
|
|
|
spec: |
|
|
|
type: ClusterIP |
|
|
|
ports: |
|
|
|
- port: 5000 |
|
|
|
targetPort: 5000 |
|
|
|
- port: 8080 |
|
|
|
targetPort: 8080 |
|
|
|
selector: |
|
|
|
app: kiosk-app |
|
|
|
|