Skip to content

Commit

Permalink
Merge branch 'istio'
Browse files Browse the repository at this point in the history
  • Loading branch information
sseide committed Dec 20, 2023
2 parents 548f8f9 + 532239a commit 6f01324
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@
# files pulled by actions, no check in
helm-docs
.github/kubeval
k8s/helm-chart/redis-commander/example.values.yaml
2 changes: 1 addition & 1 deletion k8s/helm-chart/redis-commander/Chart.yaml
Expand Up @@ -11,7 +11,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: 0.4.0
version: 0.5.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
6 changes: 5 additions & 1 deletion k8s/helm-chart/redis-commander/README.md
Expand Up @@ -2,7 +2,7 @@

A Helm chart for redis-commander

![Version: 0.4.0](https://img.shields.io/badge/Version-0.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

## Install

Expand Down Expand Up @@ -39,6 +39,10 @@ helm -n myspace install redis-web-ui ./k8s/helm-chart/redis-commander --set redi
| ingress.legacy | bool | `false` | Use *Legacy*, deprecated Ingress versions. Ingress apiVersions prior to `networking.k8s.io/v1` are deprecated and removed in kubernetes 1.22. Set the `legacy` flag to *true* if you are using kubernetes older than 1.19 or OpenShift v3 and require support for the older API versions. |
| ingress.pathType | string | `"ImplementationSpecific"` | Set the pathType for the v1 Ingress resource. This setting is ignored for `legacy` Ingress resources. Details on **Path Type** are available here; https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types |
| ingress.tls | list | `[]` | |
| istio.enabled | bool | `false` | Enable Istio VirtualService for the service The endpoint (target) is defined by the regular k8s service already defined by the chart |
| istio.gateway | string | `""` | Gateway name to use for the istio definition |
| istio.host | string | `""` | Host name to use for the istio definition |
| istio.hostPrefix | string | `"/"` | Host prefix to use for the istio definition |
| kubeVersion | string | `""` | Optional override Kubernetes version |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | optional set pod node selector definitions for kubernetes |
Expand Down
3 changes: 2 additions & 1 deletion k8s/helm-chart/redis-commander/templates/configmap.yaml
@@ -1,6 +1,7 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
local-production.json: {{ .Values.connections.local_production_json | toJson }}
local-production.json: {{ .Values.connections.local_production_json | toJson }}
3 changes: 2 additions & 1 deletion k8s/helm-chart/redis-commander/templates/ingress.yaml
Expand Up @@ -2,6 +2,7 @@
{{- $fullName := include "redis-commander.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- $pathType := .Values.ingress.pathType -}}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
Expand Down Expand Up @@ -41,4 +42,4 @@ spec:
number: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions k8s/helm-chart/redis-commander/templates/virtual-service.yaml
@@ -0,0 +1,27 @@
{{- if .Values.istio.enabled }}
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: {{ include "redis-commander.fullname" . }}
labels:
{{- include "redis-commander.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
gateways:
- {{ .Values.istio.gateway }}
hosts:
- {{ .Values.istio.host }}
http:
- match:
- uri:
prefix: {{ .Values.istio.hostPrefix }}
route:
- destination:
host: {{ include "redis-commander.fullname" . }}
port:
number: {{ .Values.service.port }}
{{- end}}
11 changes: 11 additions & 0 deletions k8s/helm-chart/redis-commander/values.yaml
Expand Up @@ -123,6 +123,17 @@ ingress:
# hosts:
# - chart-example.local

istio:
# -- Enable Istio VirtualService for the service
# The endpoint (target) is defined by the regular k8s service already defined by the chart
enabled: false
# -- Gateway name to use for the istio definition
gateway: ""
# -- Host name to use for the istio definition
host: ""
# -- Host prefix to use for the istio definition
hostPrefix: "/"

# -- We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down
43 changes: 12 additions & 31 deletions lib/routes/apiv1.js
Expand Up @@ -322,7 +322,7 @@ function clusterNodes (redisConnection, callback) {
}

// this needs special handling for read-only mode. Must check all commands and classify
// if command to view or manipulatie data...
// if command to view or manipulate data...
function postExec (req, res) {
let cmd = req.body.cmd;
let connection = res.locals.connection;
Expand All @@ -337,7 +337,7 @@ function postExec (req, res) {
}
}

// block MULTI command as long as no support implemented. breaks to much things currently
// block MULTI command as long as no support implemented. breaks too many things currently
// same for MONITOR (#424)
if (commandName === 'multi' || commandName === 'monitor') {
return res.json({data: `ERROR: Command ${commandName} not supported via web cli`});
Expand All @@ -364,7 +364,7 @@ function postExec (req, res) {
*
* @param {string} command command name in lower case to check
* @param {Redis} connection active redis connection object with optional additional command list attached
* @return {boolean} true if coammd does not modify state of server
* @return {boolean} true if command does not modify state of server
*/
function isReadOnlyCommand(command, connection) {
// check dynamic command list for this connection if available
Expand All @@ -381,7 +381,7 @@ function isReadOnlyCommand(command, connection) {
}
}

/** this method returns a list with a list of active redis commands that can be send
/** this method returns a list with a list of active redis commands that can be sent
* via POST /exec route. It is used to initialise client-side CmdParser.
* There is no client side check to filter commands send via exec throu this list.
*
Expand Down Expand Up @@ -554,7 +554,7 @@ function getSizeLimitedHashFields(redisConnection, key, res, cb) {
return done(errDetails);
}
// if the strlen > 0 and the result value is undefined then we want to return an explicit
// null value so it can be interpretted as a deferred lookup value
// null value, so it can be interpreted as a deferred lookup value
fieldsAndValues[fieldNames[idx]] = (result[0] < config.get("ui.maxHashFieldSize"))? result[1] : null;
iterate(fieldNames, idx + 1, fieldsAndValues, done);
});
Expand Down Expand Up @@ -1006,7 +1006,7 @@ function editListValue (key, index, value, res, next) {
let redisConnection = res.locals.connection;
myutil.decodeHTMLEntities(value, function (decodedString) {
value = decodedString;
// for deletion - first set this specific index to TOMBSTONE and than delete all TOMBSTONES
// for deletion - first set this specific index to TOMBSTONE and then delete all TOMBSTONES
// otherwise all list entries with this old value will be deleted...
redisConnection.lset(key, index, value, function (err) {
if (err) {
Expand Down Expand Up @@ -1208,41 +1208,22 @@ function saveKey (req, res, next) {
}

function decodeKey (req, res, next) {
let key = req.params.key;
let redisConnection = res.locals.connection;
const key = req.params.key;
const redisConnection = res.locals.connection;

redisConnection.get(key, function (err, val) {
if (err) {
console.error('decodeKey', err);
return next(err);
}

let decoded = "";

if (typeof Buffer.toString === "function") {
// Node 5.10+
decoded = Buffer(val, "base64").toString("ascii");
} else {
// older Node versions
decoded = new Buffer(val, "base64").toString("ascii");
}

const decoded = Buffer(val, "base64").toString("ascii");
return res.send(decoded)
});
}

function encodeString (req, res, next) {
let val = req.params.stringValue;
let encoded = "";

if (typeof Buffer.from === "function") {
// Node 5.10+
encoded = Buffer(val).toString('base64');
} else {
// older Node versions
encoded = new Buffer(val).toString('base64');
}

const val = req.params.stringValue;
const encoded = Buffer(val).toString('base64');
return res.send(encoded)
}

Expand Down Expand Up @@ -1373,7 +1354,7 @@ function getKeysTree (req, res, next) {
// especially for cluster special handling needed
// might have 3 nodes, must iterate result of every node as there might be some follow-up
// calls to the server (TTL, number of hash keys and similar) for "leaf-keys" within this virtual tree level
// afterwards these lists can be unified to one -> there might be keys from different nodes from different server
// afterward these lists can be unified to one -> there might be keys from different nodes from different server
// for the same level:
// e.g. node 1: /blah: one sub-key group "blub/" and one string "yammy"
// node 2: /blah: two sub-key groups "blub/" "blubber/" and one string "yo"
Expand Down
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -46,7 +46,7 @@
"yargs": "17.7.2"
},
"optionalDependencies": {
"bcrypt": "~5.1.0"
"bcrypt": "~5.1.1"
},
"devDependencies": {
"@cyclonedx/bom": "^4.0.2",
Expand Down

0 comments on commit 6f01324

Please sign in to comment.