-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* get namespaces via rest call; add rbac rules to helm chart * add local tests * Enable select field for selecting the namespace generated by the rest-api * update npm and pip dependencies * fix pylint issues * fix missing EOF; remove comment line * fix missing EOF; remove comment line * Add optional display name for the application; update helm chart; update README * fix README Co-authored-by: Jan Herber <jaydee>
- Loading branch information
Showing
21 changed files
with
2,574 additions
and
1,490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ chart/kubeseal-webgui/values-local.yaml | |
test.sh | ||
test.yaml | ||
*.pyc | ||
.dockerignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Provides REST-API and kubeseal-cli specific functionality.""" | ||
import logging | ||
import json | ||
|
||
from kubernetes import client, config | ||
from flask_restful import Resource, abort | ||
|
||
LOGGER = logging.getLogger("kubeseal-webgui") | ||
|
||
|
||
class KubernetesNamespacesEndpoint(Resource): | ||
"""Provides REST-API for sealing sensitive data.""" | ||
|
||
@classmethod | ||
def get(cls): | ||
"""References GET method. Used for retrieving cluster namespaces.""" | ||
try: | ||
return get_incluster_namespaces() | ||
except RuntimeError: | ||
abort(500) | ||
|
||
|
||
def get_incluster_namespaces(): | ||
"""Function for retrieving all namespaces from current kubernetes cluster as JSON-Array""" | ||
config.load_incluster_config() | ||
namespaces_list = [] | ||
|
||
v1 = client.CoreV1Api() | ||
LOGGER.info("Resolving in-cluster Namespaces") | ||
namespaces = v1.list_namespace() | ||
for ns in namespaces.items: | ||
namespaces_list.append(ns.metadata.name) | ||
|
||
LOGGER.debug("Namespaces list %s", namespaces_list) | ||
return json.dumps(namespaces_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
-i https://pypi.org/simple | ||
click==7.1.1 | ||
click==7.1.2 | ||
cssmin==0.2.0 | ||
dominate==2.5.1 | ||
dominate==2.6.0 | ||
flask-assets==2.0 | ||
flask-bootstrap==3.3.7.1 | ||
Flask-Cors==3.0.9 | ||
Flask-Cors==3.0.10 | ||
flask-wtf==0.14.3 | ||
Flask-RESTful==0.3.8 | ||
flask==1.1.2 | ||
pytest==6.0.1 | ||
pytest==6.2.2 | ||
pylint==2.6.0 | ||
itsdangerous==1.1.0 | ||
json_log_formatter==0.3.0 | ||
jinja2==2.11.1 | ||
jinja2==2.11.3 | ||
markupsafe==1.1.1 | ||
visitor==0.1.3 | ||
webassets==2.0 | ||
werkzeug==1.0.1 | ||
wtforms==2.2.1 | ||
wtforms==2.3.3 | ||
kubernetes==12.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
apiVersion: v1 | ||
name: kubeseal-webgui | ||
description: A Helm chart for installing kubeseal-webgui | ||
version: 2.0.0 | ||
appVersion: 2.0.0 | ||
version: 2.1.0 | ||
appVersion: 2.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.serviceaccount.create }} | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: kubeseal-webgui-list-namespaces | ||
labels: | ||
{{- include "kubeseal-webgui.labels" . | nindent 4 }} | ||
{{- with .Values.route.annotations }} | ||
annotations: | ||
{{ toYaml . | indent 4 }} | ||
{{- end }} | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["namespaces"] | ||
verbs: ["list"] | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{- if .Values.serviceaccount.create }} | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: kubeseal-webgui-list-namespaces | ||
labels: | ||
{{- include "kubeseal-webgui.labels" . | nindent 4 }} | ||
{{- with .Values.route.annotations }} | ||
annotations: | ||
{{ toYaml . | indent 4 }} | ||
{{- end }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kubeseal-webgui | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
kind: ClusterRole | ||
name: kubeseal-webgui-list-namespaces | ||
apiGroup: rbac.authorization.k8s.io | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{- if .Values.serviceaccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kubeseal-webgui | ||
labels: | ||
{{- include "kubeseal-webgui.labels" . | nindent 4 }} | ||
{{- with .Values.route.annotations }} | ||
annotations: | ||
{{ toYaml . | indent 4 }} | ||
{{- end }} | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /bin/sh | ||
|
||
BASEDIR=$(dirname "$0") | ||
docker build $BASEDIR/../api/ -t api:2.0.0 -t kubesealwebgui/api:2.0.0 | ||
docker build $BASEDIR/.. -f $BASEDIR/../Dockerfile.api -t api:2.1.0 -t kubesealwebgui/api:2.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /bin/sh | ||
|
||
BASEDIR=$(dirname "$0") | ||
docker build $BASEDIR/../ui/ -t ui:2.0.0 -t kubesealwebgui/ui:2.0.0 | ||
docker build $BASEDIR/.. -f $BASEDIR/../Dockerfile.ui -t ui:2.1.0 -t kubesealwebgui/ui:2.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /bin/sh | ||
|
||
BASEDIR=$(dirname "$0") | ||
minikube start && eval $(minikube docker-env) | ||
|
||
helm template kubesealwebgui $BASEDIR/../chart/kubeseal-webgui/ | kubectl delete -f - | ||
|
||
$BASEDIR/build-api-image.sh | ||
$BASEDIR/build-ui-image.sh | ||
|
||
helm template kubesealwebgui $BASEDIR/../chart/kubeseal-webgui/ | kubectl apply -f - | ||
|
||
sleep 2 | ||
|
||
NEW_POD=$(kubectl get pods --field-selector status.phase=Pending -o custom-columns=":metadata.name") | ||
echo " " | ||
echo "Use the following commands to locally port-forward to the kubesealwebgui pod" | ||
echo "-------------------------------------------" | ||
printf "kubectl port-forward ${NEW_POD} -p 5000:5000\n" | ||
printf "kubectl port-forward ${NEW_POD} -p 8080:8080\n" | ||
echo " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const fetch = require('node-fetch'); | ||
async function get_namespaces(){ | ||
const url = 'http://localhost:5000/namespaces' | ||
const res = await fetch(url); | ||
const data = await res.json();//assuming data is json | ||
var namespaces = JSON.parse(data); | ||
renderNamespaces(namespaces); | ||
pushNamespaceOptions(namespaces); | ||
} | ||
|
||
function renderNamespaces(ns){ | ||
ns.forEach(element => { | ||
console.log(element); | ||
}); | ||
} | ||
|
||
function pushNamespaceOptions(namespaces) { | ||
var namespaceOptions = []; | ||
namespaces.forEach(element => { | ||
namespaceOptions.push({ | ||
text: element, | ||
value: element, | ||
}) | ||
}); | ||
console.log(namespaceOptions) | ||
} | ||
|
||
get_namespaces(); | ||
|
Oops, something went wrong.