Skip to content

Commit

Permalink
Initial camel openshift console plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
claudio4j committed Sep 11, 2024
1 parent d02ba08 commit 00b0b41
Show file tree
Hide file tree
Showing 113 changed files with 16,787 additions and 3 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build

on:
push:
branches:
- "main"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Build Plugin Image
uses: docker/build-push-action@v3
with:
context: ./plugin
push: true
tags: cmiranda/camel-openshift-console-plugin:latest
cache-from: type=gha
cache-to: type=gha,mode=max
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Build Service Proxy
run: cd service-proxy && mvn package
- name: Build Serivce Proxy Image
uses: docker/build-push-action@v3
with:
context: ./service-proxy
file: ./service-proxy/src/main/docker/Dockerfile.jvm
push: true
tags: cmiranda/camel-openshift-console-service-proxy:latest
cache-from: type=gha
cache-to: type=gha,mode=max
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags:
- 'v*.*.*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Build Plugin Image
uses: docker/build-push-action@v3
with:
context: ./plugin
push: true
tags: cmiranda/camel-openshift-console-plugin:{{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Build Service Proxy
run: cd service-proxy && mvn package
- name: Build Serivce Proxy Image
uses: docker/build-push-action@v3
with:
context: ./service-proxy
file: ./service-proxy/src/main/docker/Dockerfile.jvm
push: true
tags: cmiranda/camel-openshift-console-service-proxy:{{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules/
dist/
.devcontainer/dev.env
integration-tests/videos
integration-tests/screenshots
integration-tests/.DS_Store
yarn-error.log
.DS_Store
.vscode/

7 changes: 4 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,3 +199,4 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Use bash explicitly in this Makefile to avoid unexpected platform
# incompatibilities among Linux distros.
#

IMAGE_NAME_PLUGIN=quay.io/cmiranda/camel-openshift-console-plugin
IMAGE_NAME_SERVICE_PROXY=quay.io/cmiranda/camel-openshift-console-service-proxy

plugin:
cd plugin && yarn build && yarn install

service-proxy:
cd service-proxy && mvn clean install

service-proxy-image: service-proxy
docker build -t $(IMAGE_NAME_SERVICE_PROXY):latest servcie-proxy -f service-proxy/src/main/docker/Dockerfile.jvm

plugin-image: plugin
docker build -t $(IMAGE_NAME_PLUGIN):latest plugin

images: plugin-image service-proxy-iamge

push-service-proxy: service-proxy-image
docker push $(IMAGE_NAME_SERVICE_PROXY):latest

push-plugin: plugin-image
docker push $(IMAGE_NAME_PLUGIN):latest

push: push-plugin push-service-proxy

deploy-plugin:
./bin/camel-install-openshift-console-plugin

deploy-proxy:
cd service-proxy && \
mvn clean install && \
camel deploy openshift --image-build --namespace plugin-camel-openshift-console-plugin

deploy: deploy-plugin deploy-proxy

undeploy:
helm uninstall camel-openshift-console-plugin --namespace=plugin-camel-openshift-console-plugin

all: images push deploy
6 changes: 6 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
approvers:
- christianvogt
- florkbr
- spadgett
- vojtechszocs
component: Management Console
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Camel OpenShift Console Plugin

This project provides a [console plugin](https://github.com/openshift/console/tree/master/frontend/packages/console-dynamic-plugin-sdk) for [Camel](https://camel.apache.org).
The project is created using [openshift console plugin template](https://github.com/openshift/console-plugin-template)

# Local Development

For development you can login to an existing [OpenShift](https://www.redhat.com/en/technologies/cloud-computing/openshift) and run the console with the plugin included locally.
**Note**: Works well with [OpenShift Sandbox](https://developers.redhat.com/developer-sandbox).

In one terminal window, run:

```sh
cd plugin
yarn install
yarn run start
```

In another terminal window, run:

After running `oc login` (requires [oc](https://console.redhat.com/openshift/downloads) and an [OpenShift cluster](https://console.redhat.com/openshift/create))

```sh
cd plugin
yarn run start-console
```
(requires [Docker](https://www.docker.com) or [podman 3.2.0+](https://podman.io))


This will run the OpenShift console in a container connected to the cluster
you've logged into. The plugin HTTP server runs on port 9001 with CORS enabled.
Navigate to <http://localhost:9000/example> to see the running plugin.

# Deployment to OpenShift

To deploy the console plugin to an actual [OpenShift](https://www.redhat.com/en/technologies/cloud-computing/openshift) cluster the following are needed:

- [oc](https://console.redhat.com/openshift/downloads)
- [helm](https://helm.sh)

### Building the images locally

```sh
docker build -t quay.io/cmiranda/camel-openshift-console-plugin:latest .
docker push quay.io/cmiranda/camel-openshift-console-plugin:latest
```

**Note**: The image `quay.io/cmiranda/camel-openshift-console-plguin:latest` is published so it can be pulled instead.

### Deploying the plugin using Helm

```sh
oc new-project plugin-camel-openshift-console-plugin
helm upgrade -i camel-openshift-console-plugin charts/openshift-console-plugin --namespace plugin-camel-openshift-console-plugin --set plugin.image=quay.io/cmiranda/camel-openshift-console-plugin:latest
```

# The Camel Tab

In the developer perpective the Camel section is now shown:
[![The Camel Plugin Home](screenshots/home.png)](screenshots/home.png)


# Development notes

The frontend is able to retrieve information from the console using the following APIs:

## Kubernetes API /api/kubernetes
**Examples**:
- /api/kubernetes/apis/apps/v1/namespaces/<namespace>/deployments
- /api/kubernetes/apis/apps.openshift.io/v1/namespaces/<namespace>/deploymentconfigs

## Prometheus API /api/prometheus

**Examples**:
- /api/prometheus/api/v1/query_range
45 changes: 45 additions & 0 deletions bin/camel-install-openshift-console-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
TOKEN=""
SERVER=""
IMAGE="quay.io/cmiranda/camel-openshift-console-plugin:latest"
while [[ $# -gt 0 ]]; do
case $1 in
--token)
TOKEN="$2"
shift # past argument
shift # past value
;;
--server)
SERVER_URL="$2"
shift # past argument
shift # past value
;;
--token=*)
TOKEN=`echo $1 | sed -e 's/^[^=]*=//g'`
shift # past argument
;;
--server=*)
SERVER=`echo $1 | sed -e 's/^[^=]*=//g'`
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done

if [ -n "$TOKEN" ] && [ -n "$SERVER" ]; then
echo "Login to server: $SERVER using token: $TOKEN."
oc login --token=$TOKEN --server=$SERVER
fi

EXISTING_PROJECT=`oc get projects | grep plugin-camel-openshift-console-plugin`
if [ -z "$EXISTING_PROJECT" ]; then
oc new-project plugin-camel-openshift-console-plugin
fi
helm upgrade -i camel-openshift-console-plugin charts/openshift-console-plugin --namespace plugin-camel-openshift-console-plugin --set plugin.image=quay.io/cmiranda/camel-openshift-console-plugin:latest
23 changes: 23 additions & 0 deletions charts/openshift-console-plugin/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions charts/openshift-console-plugin/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: openshift-console-plugin
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
Loading

0 comments on commit 00b0b41

Please sign in to comment.