Giter Site home page Giter Site logo

sandwi / redis-commander Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joeferner/redis-commander

0.0 1.0 0.0 2.83 MB

Redis management tool written in node.js

Home Page: http://joeferner.github.io/redis-commander/

License: MIT License

Shell 5.38% Dockerfile 0.68% JavaScript 67.92% CSS 3.53% HTML 22.50%

redis-commander's Introduction

Redis Commander

This project is fork of open source redis-commander project: http://joeferner.github.io/redis-commander/.

This fork adds support for running redis-commander on PCF by automatically registering connection(s) to Redis Service instance(s) the redis-commander app is bound to at the time of pushing to PCF.

Redis management tool written in node.js, hence it requires node and npm or yarn to be installed. Follow instructions to install node (see Node download page https://nodejs.org/en/download/). It is recommended to use a package manager for the OS/Platform where you are installing node, like Homebrew for MaxOS X or apt for ubuntu/debian or rpm for RHEL.

Install and Run

To install globally on your machine

$ npm install -g redis-commander
$ redis-commander

To run from the project directory

$ npm install
$ node bin/redis-commander.js

Usage

$ redis-commander --help or node bin/redis-commander.js --help
Options:
  --redis-port                         The port to find redis on.               [string]
  --redis-host                         The host to find redis on.               [string]
  --redis-socket                       The unix-socket to find redis on.        [string]
  --redis-password                     The redis password.                      [string]
  --redis-db                           The redis database.                      [string]
  --redis-label                        The label to display for the connection. [string]
  --sentinel-port                      The port to find redis sentinel on.      [string]
  --sentinel-host                      The host to find redis sentinel on.      [string]
  --http-auth-username, --http-u       The http authorisation username.         [string]
  --http-auth-password, --http-p       The http authorisation password.         [string]
  --http-auth-password-hash, --http-h  The http authorisation password hash.    [string]
  --address, -a                        The address to run the server on.        [string]  [default: 0.0.0.0]
  --port, -p                           The port to run the server on.           [string]  [default: 8081]
  --url-prefix, -u                     The url prefix to respond on.            [string]  [default: ""]
  --root-pattern, --rp                 The root pattern of the redis keys.      [string]  [default: "*"]
  --nosave, --ns                       Do not save new connections to config.   [boolean] [default: true]
  --noload, --nl                       Do not load connections from config.     [boolean] [default: false]
  --use-scan, --sc                     Use scan instead of keys.                [boolean] [default: false]
  --clear-config, --cc                 clear configuration file.
  --migrate-config                     migrate old configuration file in $HOME to new style.
  --scan-count, --sc                   The size of each seperate scan.          [integer] [default: 100]
  --no-log-data                        Do not log data values from redis store. [boolean] [default: false]
  --open                               Open web-browser with Redis-Commander.   [boolean] [default: false]
  --folding-char, --fc                 Character to fold keys at in tree view.  [character] [default: ":"]
  --test, -t                           test final configuration (file, env-vars, command line)

The connection can be established either via direct connection to redis server or indirect via a sentinel instance.

Configuration

Redis Commander can be configured by configuration files, environment variables or using command line parameters. The different types of config values overwrite each other, only the last (most important) value is used.

For configuration files the node-config module (https://github.com/lorenwest/node-config) is used, with default to json syntax.

The order of precedence for all configuration values (from least to most important) is:

  • Configuration files

    default.json - this file contains all default values and SHOULD NOT be changed

    local.json - optional file, all local overwrites for values inside default.json should be placed here as well as a list of redis connections to use at startup

    local-<NODE_ENV>.json - Do not add anything else than connections to this file! Redis Commander will overwrite this whenever a connection is added or removed via user interface. Inside docker container this file is used to store all connections parsed from REDIS_HOSTS env var. This file overwrites all connections defined inside local.json

    There are some more possible files available to use - please check the node-config Wiki for an complete list of all possible file names (https://github.com/lorenwest/node-config/wiki/Configuration-Files)

  • Environment variables - the full list of env vars possible (except the docker specific ones) can be get from the file config/custom-environment-variables.json together with their mapping to the respective configuration key.

  • Command line parameters - Overwrites everything

To check the final configuration created from files, env-vars set and command line param overwrites start redis commander with additional param "--test". All invalid configuration keys will be listed in the output. The config test does not check if hostnames or ip addresses can be resolved.

Environment Variables

These environment variables can be used starting Redis Commander as normal application or inside docker container (defined inside file config/custom-environment-variables.json):

HTTP_USER
HTTP_PASSWORD
HTTP_PASSWORD_HASH
ADDRESS
PORT
URL_PREFIX
ROOT_PATTERN
NOSAVE
NO_LOG_DATA
FOLDING_CHAR
USE_SCAN
SCAN_COUNT
FLUSH_ON_IMPORT
REDIS_CONNECTION_NAME
REDIS_LABEL

Docker

All environment variables listed at "Environment Variables" can be used running image with Docker. The following additional environment variables are available too (defined inside docker startup script):

REDIS_PORT
REDIS_HOST
REDIS_SOCKET
REDIS_TLS
REDIS_PASSWORD
REDIS_DB
REDIS_HOSTS
SENTINEL_PORT
SENTINEL_HOST
K8S_SIGTERM

The K8S_SIGTERM variable (default "0") can be set to "1" to work around kubernetes specificas to allow pod replacement with zero downtime. More information on how kubernetes handles termination of old pods and the setup of new ones can be found within the thread [kubernetes-retired/contrib#1140 (comment)]

Hosts can be optionally specified with a comma separated string by setting the REDIS_HOSTS environment variable.

After running the container, redis-commander will be available at localhost:8081.

Valid host strings

the REDIS_HOSTS environment variable is a comma separated list of host definitions, where each host should follow one of these templates:

hostname

label:hostname

label:hostname:port

label:hostname:port:dbIndex

label:hostname:port:dbIndex:password

Connection strings defined with REDIS_HOSTS variable do not support TLS connections. If remote redis server needs TLS write all connections into a config file instead of using REDIS_HOSTS.

With docker-compose

version: '3'
services:
  redis:
    container_name: redis
    hostname: redis
    image: redis

  redis-commander:
    container_name: redis-commander
    hostname: redis-commander
    image: rediscommander/redis-commander:latest
    restart: always
    environment:
    - REDIS_HOSTS=local:redis:6379
    ports:
    - "8081:8081"

Without docker-compose

Simplest

If you're running redis on localhost:6379, this is all you need to get started.

docker run --rm --name redis-commander -d \
  -p 8081:8081 \
  rediscommander/redis-commander:latest

Specify single host

docker run --rm --name redis-commander -d \
  --env REDIS_HOSTS=10.10.20.30 \
  -p 8081:8081 \
  rediscommander/redis-commander:latest

Specify multiple hosts with labels

docker run --rm --name redis-commander -d \
  --env REDIS_HOSTS=local:localhost:6379,myredis:10.10.20.30 \
  -p 8081:8081 \
  rediscommander/redis-commander:latest

Kubernetes

An example deployment can be found at k8s/redis-commander/deployment.yaml.

If you already have a cluster running with redis in the default namespace, deploy redis-commander with kubectl apply -f k8s/redis-commander. If you don't have redis running yet, you can deploy a simple pod with kubectl apply -f k8s/redis.

Alternatively, you can add a container to a deployment's spec like this:

containers:
- name: redis-commander
  image: rediscommander/redis-commander
  env:
  - name: REDIS_HOSTS
    value: instance1:redis:6379
  ports:
  - name: redis-commander
    containerPort: 8081

Pivotal Cloud Foundry

  1. Update sample Cloud Foundry manifest.yml to match your cloud foundry environment.
  2. Create a new vars-{env}.yml file using vars-sample.yml to match your cloud foundry environment.
  3. Run npm install if you have to get all the required NPM modules (this may be needed if you are running in corporate environment where access to public NPM has been blocked).
  4. Create an instance of Redis for Pivotal Cloud Foundry (PCF) or use one if it already exists in the CF Space to which redis-commander will be deployed.
    • cf create-service p-redis dedicated-vm my-redis-instance.
  5. Push redis-commander to Cloud Foundry:
    • cf push redis-commander -f manifest.yml --vars-file vars-{env}.yml.
  6. Access redis-commander using the route that was specified in the manifest: https://((cfroute)).

OpenShift V3

To use the stock Node.js image builder do the following.

  1. Open Catalog and select the Node.js template
  2. Specify the name of the application and the URL to the redis-command github repository
  3. Click the advanced options link
  4. (optional) specify the hostname for the route - if one is not specified it will be generated
  5. In the Deployment Configuration section
    • Add REDIS_HOST environment variable whose value is the name of the redis service - e.g., redis
    • Add REDIS_PORT environment variable whose value is the port exposed of the redis service - e.g., 6379
    • Add value from secret generated by the redis template:
      • name: REDIS_PASSWORD
      • resource: redis
      • key: database-password
  6. (optional) specify a label such as appl=redis-commander-dev1
    • this label will be applied on all objects created allowing for easy deletion later via:
    oc delete all --selector appl=redis-commander-dev1

Build images based on this one

To use this images as a base image for other images you need to call "apk update" inside your Dockerfile before adding other apk packages with "apk add foo". Afterwards, to reduce your image size, you may remove all temporary apk configs too again as this Dockerfile does.

redis-commander's People

Contributors

ajnasz avatar alexanderscott avatar amauryortega avatar andy-ganchrow avatar antoineleclair avatar blamoo avatar caiknife avatar cybermaxs avatar evantahler avatar evildevru avatar hagai26 avatar jalessio avatar joeferner avatar jsemig avatar jweyrich avatar luto avatar m-allanson avatar ozomer avatar plamworapot avatar reneluria avatar sandwi avatar scotteadams avatar seanc2222 avatar sschueller avatar sseide avatar stevenaldinger avatar submitteddenied avatar tperalta82 avatar tvernon avatar vfedyk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.