Skip to content

Commit

Permalink
update: web-terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
codekow committed Nov 11, 2023
1 parent 56bd6d1 commit 224c4c0
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 24 deletions.
36 changes: 36 additions & 0 deletions web-terminal/INFO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# web-terminal

Start a Web Terminal in your browser with common CLI tools for interacting with
the cluster.

**Note:** The Web Terminal Operator integrates with the OpenShift Console in
OpenShift 4.5.3 and higher to simplify Web Terminal instance creation and
automate OpenShift login. In earlier versions of OpenShift, the operator can
be installed but Web Terminals will have to be created and accessed manually.

## Description
The Web Terminal Operator leverages the
[DevWorkspace Operator](https://github.com/devfile/devworkspace-operator)
to provision enviroments which support common cloud CLI tools. When this
operator is installed, the DevWorkspace Operator will be installed as a
dependency.

## How to Install
Press the **Install** button, choose the upgrade strategy, and wait for the
**Installed** Operator status.

When the operator is installed, you will see a terminal button appear on the
top right of the console after refreshing the OpenShift console window.

## How to Uninstall
The Web Terminal Operator requires manual steps to fully uninstall the operator.
As the Web Terminal Operator is designed as a way to access the OpenShift
cluster, Web Terminal instances store user credentials. To avoid exposing these
credentials to unwanted parties, the operator deploys webhooks and finalizers
that aren't removed when the operator is uninstalled. See the
[uninstall guide](https://docs.openshift.com/container-platform/latest/web_console/odc-about-web-terminal.html)
for more details.

## Known Issues
1. [Occasionally you will need to press enter to get a prompt inside of the web-terminal](https://issues.redhat.com/browse/WTO-43)
2. [DevWorkspace is created but not opened after previous devworkspace is removed](https://issues.redhat.com/browse/WTO-44)
22 changes: 7 additions & 15 deletions web-terminal/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
# OpenShift Web Terminal Operator
# Web Terminal

Installs the Web Terminal Operator.

This operator enables you to run a web terminal within the OpenShift Console GUI giving easy availability to tools like oc, helm, etc.

This operator depends on the DevWorkspace Operator which will be installed automatically when you install this operator.
Install Web Terminal.

Do not use the `base` directory directly, as you will need to patch the `channel` based on the version of OpenShift you are using, or the version of the operator you want to use.

The current *overlays* available are for the following channels:

* [fast](operator/overlays/fast)

## Usage

If you have cloned the `gitops-catalog` repository, you can install the OpenShift Data Foundation operator based on the overlay of your choice by running from the root `gitops-catalog` directory
If you have cloned the `gitops-catalog` repository, you can install Web Terminal based on the overlay of your choice by running from the root (`gitops-catalog`) directory.

```
oc apply -k web-terminal-operator/overlays/<channel>
oc apply -k web-terminal/operator/overlays/<channel>
```

Or, without cloning:

```
oc apply -k https://github.com/redhat-cop/gitops-catalog/web-terminal-operator/operator/overlays/<channel>
oc apply -k https://github.com/redhat-cop/gitops-catalog/web-terminal/operator/overlays/<channel>
```

As part of a different overlay in your own GitOps repo:

```
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/redhat-cop/gitops-catalog/web-terminal-operator/operator/overlays/<channel>?ref=main
- https://github.com/redhat-cop/gitops-catalog/web-terminal/operator/overlays/<channel>?ref=main
```

## A Note on Previous Versions

Older versions of the Web Terminal Operator required users to configure a DevWorkspaces instance which is no longer required in the current version of the Web Terminal Operator. The Web Terminal Operator will automatically configure any necessary DevWorkspaces components automatically.
10 changes: 10 additions & 0 deletions web-terminal/aggregate/aws/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

commonAnnotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true

resources:
- ../../operator/overlays/stable
- ../../instance/overlays/aws
9 changes: 9 additions & 0 deletions web-terminal/aggregate/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

commonAnnotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true

resources:
- ../../operator/overlays/fast
- ../../instance/overlays/default
5 changes: 5 additions & 0 deletions web-terminal/instance/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- web-terminal-tooling.yaml
24 changes: 24 additions & 0 deletions web-terminal/instance/base/web-terminal-tooling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
annotations:
controller.devfile.io/allow-import-from: '*'
name: web-terminal-tooling
namespace: openshift-operators
labels:
console.openshift.io/terminal: 'true'
spec:
components:
- container:
args:
- tail
- '-f'
- /dev/null
cpuLimit: 400m
cpuRequest: 100m
image: registry.redhat.io/web-terminal/web-terminal-tooling-rhel8@sha256:657874adad93a9e6c2b746b836015de410d2e280f85c079c81e24ae81343fa6c
memoryLimit: 512Mi
memoryRequest: 128Mi
mountSources: false
sourceMapping: /projects
name: web-terminal-tooling
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$patch: delete
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
name: web-terminal-tooling
namespace: openshift-operators
8 changes: 8 additions & 0 deletions web-terminal/instance/overlays/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

patches:
- path: exclude-default-template.yaml
13 changes: 13 additions & 0 deletions web-terminal/instance/overlays/enhanced/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

patches:
# https://github.com/redhat-developer/web-terminal-operator
- target:
group: workspace.devfile.io
kind: DevWorkspaceTemplate
name: web-terminal-tooling
path: web-terminal-tooling.yaml
65 changes: 65 additions & 0 deletions web-terminal/instance/overlays/enhanced/web-terminal-tooling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
annotations:
controller.devfile.io/allow-import-from: '*'
web-terminal.redhat.com/unmanaged-state: 'true'
name: web-terminal-tooling
namespace: openshift-operators
labels:
console.openshift.io/terminal: 'true'
spec:
components:
- container:
args:
- "/bin/bash"
- "-c"
- |
#!/bin/bash
GIT_REPO=https://github.com/codekow/demo-ai-gitops-catalog.git
echo "
echo
GIT_REPO=${GIT_REPO}
printf 'This terminal has been \e[0;32m~Enhanced~\e[0m\n'
printf 'See \033[34;1;1m'${GIT_REPO}'\e[0m\n\n'
" >> ~/.bashrc
git clone "${GIT_REPO}" gitops
echo "
cd gitops; . scripts/functions.sh; cd ..
__git_branch(){
git name-rev --name-only @ 2>/dev/null
}
PS1='\e]\s\a\n\e[33m\w \e[36m\$(__git_branch)\e[m$ '
[ -e ~/.venv/bin/activate ] && . ~/.venv/bin/activate
[ -e ~/gitops/scratch/bin/restic.bash ] && . ~/gitops/scratch/bin/restic.bash
cd ~/gitops
" >> ~/.bashrc
cd gitops
. scripts/functions.sh
[ -d ~/.venv ] || pyvenv-3.6 ~/.venv
bin_check busybox
bin_check oc-mirror
bin_check rclone
bin_check restic
sleep infinity
cpuLimit: 400m
cpuRequest: 100m
image: registry.redhat.io/web-terminal/web-terminal-tooling-rhel8@sha256:657874adad93a9e6c2b746b836015de410d2e280f85c079c81e24ae81343fa6c
memoryLimit: 256Mi
memoryRequest: 128Mi
mountSources: false
sourceMapping: /projects
name: web-terminal-tooling
5 changes: 5 additions & 0 deletions web-terminal/instance/web-terminal/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- web-terminal-tooling.yaml
24 changes: 24 additions & 0 deletions web-terminal/instance/web-terminal/base/web-terminal-tooling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
annotations:
controller.devfile.io/allow-import-from: '*'
name: web-terminal-tooling
namespace: openshift-operators
labels:
console.openshift.io/terminal: 'true'
spec:
components:
- container:
args:
- tail
- '-f'
- /dev/null
cpuLimit: 400m
cpuRequest: 100m
image: registry.redhat.io/web-terminal/web-terminal-tooling-rhel8@sha256:657874adad93a9e6c2b746b836015de410d2e280f85c079c81e24ae81343fa6c
memoryLimit: 512Mi
memoryRequest: 128Mi
mountSources: false
sourceMapping: /projects
name: web-terminal-tooling
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$patch: delete
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
name: web-terminal-tooling
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

patches:
- path: exclude-default-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

patches:
# https://github.com/redhat-developer/web-terminal-operator
- target:
group: workspace.devfile.io
kind: DevWorkspaceTemplate
name: web-terminal-tooling
path: web-terminal-tooling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
annotations:
controller.devfile.io/allow-import-from: '*'
web-terminal.redhat.com/unmanaged-state: 'true'
name: web-terminal-tooling
namespace: openshift-operators
labels:
console.openshift.io/terminal: 'true'
spec:
components:
- container:
args:
- "/bin/bash"
- "-c"
- |
#!/bin/bash
GIT_REPO=https://github.com/codekow/demo-ai-gitops-catalog.git
echo "
echo
GIT_REPO=${GIT_REPO}
printf 'This terminal has been \e[0;32m~Enhanced~\e[0m\n'
printf 'See \033[34;1;1m'${GIT_REPO}'\e[0m\n\n'
" >> ~/.bashrc
git clone "${GIT_REPO}" gitops
echo "
cd gitops; . scripts/functions.sh; cd ..
__git_branch(){
git name-rev --name-only @ 2>/dev/null
}
PS1='\e]\s\a\n\e[33m\w \e[36m\$(__git_branch)\e[m$ '
[ -e ~/.venv/bin/activate ] && . ~/.venv/bin/activate
[ -e ~/gitops/scratch/bin/restic.bash ] && . ~/gitops/scratch/bin/restic.bash
cd ~/gitops
" >> ~/.bashrc
cd gitops
. scripts/functions.sh
[ -d ~/.venv ] || pyvenv-3.6 ~/.venv
bin_check busybox
bin_check oc-mirror
bin_check rclone
bin_check restic
sleep infinity
cpuLimit: 400m
cpuRequest: 100m
image: registry.redhat.io/web-terminal/web-terminal-tooling-rhel8@sha256:657874adad93a9e6c2b746b836015de410d2e280f85c079c81e24ae81343fa6c
memoryLimit: 256Mi
memoryRequest: 128Mi
mountSources: false
sourceMapping: /projects
name: web-terminal-tooling
3 changes: 0 additions & 3 deletions web-terminal/operator/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: openshift-operators

resources:
- subscription.yaml
3 changes: 2 additions & 1 deletion web-terminal/operator/base/subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: web-terminal
namespace: openshift-operators
spec:
channel: patch-me
channel: patch-me-see-overlays-dir
installPlanApproval: Automatic
name: web-terminal
source: redhat-operators
Expand Down
8 changes: 3 additions & 5 deletions web-terminal/operator/overlays/fast/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: openshift-operators

resources:
- ../../base

patches:
- path: patch-channel.yaml
target:
- target:
kind: Subscription
name: web-terminal
path: patch-channel.yaml

0 comments on commit 224c4c0

Please sign in to comment.