Skip to content

Commit

Permalink
Merge pull request #3 from kincl/jkincl-add-novnc
Browse files Browse the repository at this point in the history
Adding support for running noVNC in same pod as showroom
  • Loading branch information
newgoliath authored Apr 9, 2024
2 parents a49577e + 0986365 commit c6f6f3e
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-image-novnc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: build-image-novnc

on:
push:
branches:
- main
tags:
- "v*"
paths:
- "images/showroom-novnc/**"

permissions:
packages: write

concurrency:
group: build
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: set datetime
run: |
echo "datetime=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Build image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: showroom-novnc
tags: latest ${{ github.ref_name }}
context: images/showroom-novnc/
containerfiles: |
./images/showroom-novnc/Containerfile
build-args: |
CREATED_AT=${{ env.datetime }}
GITHUB_SHA=${{ github.sha }}
- name: push image to ghcr.io
id: push-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/rhpds
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}"
13 changes: 13 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ helm install myshowroom myrhpds/showroom --set deployer.domain=apps.shared-410.o

NOTE: The above creates the namespace `showroom-test` where the helm release exists, AND creates the namespace `showroom-test2` there the actual application is deployed.

==== Deploy noVNC

For deploying showroom with noVNC, you need to have a host with a VNC server configured and running.

. Using Helm
----
helm install
...
--set novnc.setup=true \
--set novnc.vncServer=my.host.local:5900 \
--set novnc.password=secret123
----

== Hosting Helm Repo with on \https://rhpds.github.io/

=== Prereqs
Expand Down
8 changes: 8 additions & 0 deletions charts/showroom-single-pod/files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
{{- end }}
{{- if eq .Values.ocpconsole.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'ocpconsole_tab')">OCP Web Console</button>
{{- end }}
{{- if eq .Values.novnc.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'novnc_tab')">Desktop</button>
{{- end }}
</div>
{{- if eq .Values.terminal.setup "true" }}
Expand All @@ -48,6 +51,11 @@
<div id="ocpconsole_tab" class="tabcontent">
<iframe id="ocpconsole" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/console/" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- if eq .Values.novnc.setup "true" }}
<div id="novnc_tab" class="tabcontent">
<iframe id="novnc" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/novnc/vnc.html?password={{ .Values.novnc.password }}&autoconnect=true&resize=remote" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
</div>
{{- end }}
Expand Down
16 changes: 16 additions & 0 deletions charts/showroom-single-pod/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ spec:
{{- toYaml .Values.wetty.resources | nindent 10 }}
{{- end }}

{{- if eq .Values.novnc.setup "true" }}
- name: novnc
image: {{ .Values.novnc.image }}
imagePullPolicy: IfNotPresent
args:
- websockify
- --web=/www
- 127.0.0.1:{{ .Values.novnc.port }}
- "{{ .Values.novnc.vncServer }}"
ports:
- containerPort: {{ .Values.novnc.port }}
protocol: TCP
resources:
{{- toYaml .Values.novnc.resources | nindent 10 }}
{{- end }}

volumes:
- name: showroom
emptyDir: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,29 @@ data:
proxy_set_header X-Forwarded-Proto $scheme;
}
{{- end }}

{{- if eq .Values.novnc.setup "true" }}
location ^~ /novnc {
proxy_pass http://127.0.0.1:{{ .Values.novnc.port }};

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
}

location ^~ /websockify {
proxy_pass http://127.0.0.1:{{ .Values.novnc.port }}/websockify;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 43200000;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
}
{{- end }}
}
}
13 changes: 13 additions & 0 deletions charts/showroom-single-pod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,16 @@ codeserver:
# To be fully implemented
ocpconsole:
setup: "false"

novnc:
setup: "false"
image: ghcr.io/rhpds/showroom-novnc:latest
port: 6080
vncServer: 127.0.0.1:5900
password: password
resources:
limits:
memory: 256Mi
requests:
cpu: 500m
memory: 256Mi
20 changes: 20 additions & 0 deletions images/showroom-novnc/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM registry.access.redhat.com/ubi9:9.2-722

ARG CREATED_AT=none
ARG GITHUB_SHA=none

LABEL org.opencontainers.image.created="$CREATED_AT"
LABEL org.opencontainers.image.revision="$GITHUB_SHA"

RUN curl -L https://github.com/novnc/websockify/archive/refs/tags/v0.11.0.tar.gz \
--output websockify.tar.gz && \
tar xzf websockify.tar.gz && \
cd /websockify-0.11.0 && python3 setup.py install

RUN curl -L https://github.com/novnc/noVNC/archive/refs/tags/v1.4.0.tar.gz \
--output noVNC.tar.gz && \
mkdir -p /www/novnc && \
tar xzf noVNC.tar.gz --strip-components 1 -C /www/novnc

#
CMD ["websockify"]

0 comments on commit c6f6f3e

Please sign in to comment.