Skip to content

Commit

Permalink
Merge pull request #5 from rhpds/judd-double-terminal
Browse files Browse the repository at this point in the history
double terminals with stacked option
  • Loading branch information
newgoliath authored Jul 16, 2024
2 parents 0696915 + c65d956 commit 5f12d4d
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ helm template ./showroom-single-pod \
--set documentation.repoUrl=https://github.com/rhpds/showroom_template_default \
| oc apply -f -
----

+
NOTE: If the above doesn't work, the following worked for me:
+
---
----
helm template showroom showroom-single-pod \
--set deployer.domain=apps.shared-410.openshift.redhatworkshops.io \
--set general.guid=my-test \
--set documentation.repoUrl=https://github.com/rhpds/showroom_template_default \
| oc apply -f -
---
----

=== Deploy as cluster-admin with `helm install`

Expand Down
2 changes: 1 addition & 1 deletion charts/showroom-single-pod/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.2.1
version: 1.3.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
92 changes: 75 additions & 17 deletions charts/showroom-single-pod/files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,31 @@
</div>
<div class="split right">
<div class="tab">
{{- if eq .Values.terminal.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'terminal_tab')" id="defaultOpen" tabindex="0">Terminal</button>
<!-- tabbed terminals - start -->

{{- if eq .Values.stacked_terminals.setup "false" }}
{{- if eq .Values.terminal.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'terminal_tab1')" id="defaultOpen" tabindex="0">{{ .Values.terminal.display_name }}</button>
{{- end }}
{{- if eq .Values.terminal2.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'terminal_tab2')" id="defaultOpen" tabindex="0">{{ .Values.terminal2.display_name }}</button>
{{- end }}
{{- if eq .Values.wetty.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'wetty_tab1')" id="defaultOpen" tabindex="0">{{ .Values.wetty.display_name }}</button>
{{- end }}
{{- if eq .Values.wetty2.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'wetty_tab2')" id="defaultOpen" tabindex="0">{{ .Values.wetty2.display_name }}</button>
{{- end }}
{{- end }}
{{- if eq .Values.wetty.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'terminal_tab')" id="defaultOpen" tabindex="0">SSH Terminal</button>
<!-- tabbed terminals - end -->

<!-- stacked terminals - start -->
{{- if eq .Values.stacked_terminals.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'stacked_terminals')" id="defaultOpen" tabindex="0">{{ .Values.stacked_terminals.display_name }}</button>
{{- end }}
<!-- stacked terminals - end -->

<!-- other tabs - start -->
{{- if eq .Values.codeserver.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'codeserver_tab')">Code Server</button>
{{- end }}
Expand All @@ -31,22 +50,56 @@
{{- if eq .Values.novnc.setup "true" }}
<button class="tablinks" onclick="openTerminal(event, 'novnc_tab')">Desktop</button>
{{- end }}
<!-- other tabs - end -->
</div>
{{- if eq .Values.terminal.setup "true" }}
<div id="terminal_tab" class="tabcontent">
<iframe id="terminal_01" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/terminal" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- if eq .Values.wetty.setup "true" }}
<div id="terminal_tab" class="tabcontent">
<iframe id="terminal_01" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/wetty" width="100%" style="border:none;"></iframe>
</div>

<!-- iframe definition - start -->
<!-- tabbed terminals iframes - start -->
{{- if eq .Values.stacked_terminals.setup "false" }}
{{- if eq .Values.terminal.setup "true" }}
<div id="terminal_tab1" class="tabcontent">
<iframe id="terminal_01" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/terminal" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- if eq .Values.terminal2.setup "true" }}
<div id="terminal_tab2" class="tabcontent">
<iframe id="terminal_02" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/terminal2" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- if eq .Values.wetty.setup "true" }}
<div id="wetty_tab1" class="tabcontent">
<iframe id="terminal_01" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/wetty" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- if eq .Values.wetty2.setup "true" }}
<div id="wetty_tab2" class="tabcontent">
<iframe id="terminal_02" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/wetty2" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- if eq .Values.codeserver.setup "true" }}
<div id="codeserver_tab" class="tabcontent">
<iframe id="codeserver" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/codeserver" width="100%" style="border:none;"></iframe>
</div>
{{- end }}
{{- end }}
{{- if eq .Values.codeserver.setup "true" }}
<div id="codeserver_tab" class="tabcontent">
<iframe id="codeserver" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/codeserver" width="100%" style="border:none;"></iframe>
</div>
<!-- tabbed terminals iframes - end -->
<!-- stacked terminals iframes - start -->
{{- if eq .Values.stacked_terminals.setup "true" }}

<div id="stacked_terminals" class="tabcontent">
<div class="split top">
<iframe id="{{ .Values.stacked_terminals.top }}" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/{{ .Values.stacked_terminals.top }}" width="100%" style="border:none;"></iframe>
</div>
<div class="split bottom">
<iframe id="{{ .Values.stacked_terminals.bottom }}" src="https://{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.deployer.domain }}/{{ .Values.stacked_terminals.bottom }}" width="100%" style="border:none;"></iframe>
</div>
</div>

{{- end }}

<!-- stacked terminals iframes - end -->


{{- if eq .Values.ocpconsole.setup "true" }}
<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>
Expand All @@ -60,6 +113,7 @@
</div>
{{- end }}
</div>
<!-- iframe definition - end -->
<script>
document.getElementById("defaultOpen").click();
function openTerminal(evt, tabName) {
Expand All @@ -85,6 +139,10 @@
Split(['.left', '.right'], {
sizes: [45,55],
});
Split(['.top', '.bottom'], {
sizes: [65,35],
direction: 'vertical',
});
</script>
</body>
</html>
48 changes: 48 additions & 0 deletions charts/showroom-single-pod/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ spec:
resources:
{{- toYaml .Values.terminal.resources | nindent 10 }}
{{- end }}
{{- if eq .Values.terminal2.setup "true" }}
- name: terminal2
image: {{ .Values.terminal2.image }}
imagePullPolicy: IfNotPresent
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: GUID
value: "{{ .Values.guid }}"
volumeMounts:
- name: terminal-lab-user-home
mountPath: /home/lab-user
ports:
- containerPort: {{ .Values.terminal2.port }}
protocol: TCP
resources:
{{- toYaml .Values.terminal2.resources | nindent 10 }}
{{- end }}
{{- if eq .Values.ocpconsole.setup "true" }}
- name: console-app
image: "quay.io/openshift/origin-console:4.14"
Expand Down Expand Up @@ -151,6 +171,34 @@ spec:
{{- toYaml .Values.wetty.resources | nindent 10 }}
{{- end }}

{{- if eq .Values.wetty2.setup "true" }}
- name: wetty2
image: {{ .Values.wetty2.image }}
imagePullPolicy: IfNotPresent
args:
- --base="/{{ .Values.wetty2.base }}/"
- --port={{ .Values.wetty2.port }}
{{- if eq .Values.wetty2.ssh.autoSshToBastion "true" }}
- --ssh-host={{ .Values.wetty2.ssh.sshHost }}
- --ssh-port={{ .Values.wetty2.ssh.sshPort }}
- --ssh-user={{ .Values.wetty2.ssh.sshUser }}
- --ssh-auth={{ .Values.wetty2.ssh.sshAuth }}
- --ssh-pass={{ .Values.wetty2.ssh.sshPass }}
{{- end }}
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: GUID
value: "{{ .Values.guid }}"
ports:
- containerPort: {{ .Values.wetty2.port }}
protocol: TCP
resources:
{{- toYaml .Values.wetty2.resources | nindent 10 }}
{{- end }}

{{- if eq .Values.novnc.setup "true" }}
- name: novnc
image: {{ .Values.novnc.image }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ data:
}
{{- end }}

{{- if eq .Values.terminal2.setup "true" }}
location /terminal2/ {
proxy_pass http://localhost:{{ .Values.terminal2.port }};
rewrite ^/terminal2/(.*)$ /$1 break;

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 $http_host;
proxy_set_header X-NginX-Proxy true;
}
{{- end }}

{{- if eq .Values.wetty.setup "true" }}
location ^~ /wetty {
proxy_pass http://localhost:{{ .Values.wetty.port }}/{{ .Values.wetty.base }};
Expand All @@ -75,6 +92,21 @@ data:
}
{{- end }}

{{- if eq .Values.wetty2.setup "true" }}
location ^~ /wetty2 {
proxy_pass http://localhost:{{ .Values.wetty2.port }}/{{ .Values.wetty2.base }};
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 $http_host;
proxy_set_header X-NginX-Proxy true;
}
{{- end }}

{{- if eq .Values.ocpconsole.setup "true" }}
location /ocp/ {
# JM: not working, don't know why
Expand Down
53 changes: 53 additions & 0 deletions charts/showroom-single-pod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@ content:
user_data: |
bastion_password: from_helm
# to have two terminals in one tab
# set stacked_terminals to "true"
# and indicate which two terminals you want
stacked_terminals:
setup: "false"
name: stacked-terminal
display_name: "Stacked Terminal"
top: "terminal"
bottom: "wetty2"

terminal:
setup: "true"
image: quay.io/rhpds/openshift-showroom-terminal-ocp:latest
name: terminal
display_name: "Terminal 1"
port: 7681
resources:
limits:
Expand All @@ -51,10 +62,31 @@ terminal:
# Use default Storage Class when empty
storageClass: ""

terminal2:
setup: "false"
image: quay.io/rhpds/openshift-showroom-terminal-ocp:latest
name: terminal2
display_name: "Terminal 2"
port: 7682
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
# Set up persistent storage for the lab-user's home directory
storage:
setup: "true"
pvcSize: 5Gi
# Use default Storage Class when empty
storageClass: ""

wetty:
setup: "false"
image: quay.io/rhpds/wetty:latest
name: wetty
display_name: "Login Terminal 1"
port: 8001
base: "wetty"
resources:
Expand All @@ -71,6 +103,27 @@ wetty:
sshAuth: password
sshPass: password

wetty2:
setup: "true"
image: quay.io/rhpds/wetty:latest
name: wetty2
display_name: "Login Terminal 2"
port: 8002
base: "wetty2"
resources:
limits:
memory: 256Mi
requests:
cpu: 500m
memory: 256Mi
ssh:
autoSshToBastion: "false"
sshHost: shared-410-bastion.openshift.redhatworkshops.io
sshPort: 22
sshUser: ec2-user
sshAuth: password
sshPass: password

# To be fully implemented
codeserver:
setup: "false"
Expand Down

0 comments on commit 5f12d4d

Please sign in to comment.