While designed for web development, the PHP scripting language also provides general-purpose use. Redis (Remote Dictionary Server) is a very popular and widely-used open source, fast, distributed and efficient in-memory key-value database/data structure server. It offers a rich set of features that make it effective for a wide range of use cases: as a database, caching layer, message broker, or queue; applicable in web applications, chat and messaging applications, gaming, real-time data. We would like to show you a description here but the site won’t allow us.
You can install Traefik with the following flavors:
Use the Official Docker Image¶
Choose one of the official Docker images and run it with one sample configuration file:
For more details, go to the Docker provider documentation
Tip
- Prefer a fixed version than the latest that could be an unexpected version.ex:
traefik:v2.1.4
- Docker images are based from the Alpine Linux Official image.
- Any orchestrator using docker images can fetch the official Traefik docker image.
Use the Helm Chart¶
Warning
The Traefik Chart from Helm's default charts repository is still using Traefik v1.7.
Traefik can be installed in Kubernetes using the Helm chart from https://github.com/traefik/traefik-helm-chart.
Ensure that the following requirements are met:
- Kubernetes 1.14+
- Helm version 3.x is installed
Add Traefik's chart repository to Helm:
You can update the chart repository by running:
And install it with the helm
command line:
Helm Features
All Helm features are supported.For instance, installing the chart in a dedicated namespace:
You can customize the installation by specifying custom values,as with any helm chart.
The values are not (yet) documented, but are self-explanatory:you can look at the default values.yaml
file to explore possibilities.
You can also set Traefik command line flags using additionalArguments
.Example of installation with logging set to DEBUG
:
Exposing the Traefik dashboard¶
This HelmChart does not expose the Traefik dashboard by default, for security concerns.Thus, there are multiple ways to expose the dashboard.For instance, the dashboard access could be achieved through a port-forward :
Accessible with the url: http://127.0.0.1:9000/dashboard/
Another way would be to apply your own configuration, for instance,by defining and applying an IngressRoute CRD (kubectl apply -f dashboard.yaml
):
Use the Binary Distribution¶
Grab the latest binary from the releases page.
And run it:
Compile your Binary from the Sources¶
All the details are available in the Contributing Guide
Redis and Express are tools that provide a simple and clean approach to their problem domains. What follows is a Docker/Docker Compose v2 setup.
The repo is available at: https://github.com/HugoDF/express-redis-docker.
The docker-compose.yml
is available at: github.com/HugoDF/express-redis-docker/docker-compose.yml
Redis is “an open source, in-memory data structure store, used as a database, cache and message broker”. It’s as simple and unopinionated as a database as it gets, it’s known for its performance and simplicity as a key-value store. It has great flexibility and can also be used as a message queue, circular buffer (and pretty much anything else a developer can come up with short of a relational database).
Express is a “fast, unopinionated, minimalist web framework for Node.js”. In other words, it’s a wrapper around Node’s server, that provides a way to write what’s called “middleware” to share and compose functionality across HTTP endpoints as well as define said endpoints.
Getting Redis and Express to work together is trivial. Getting Redis and Express to work together in a way that’s fool and future-proof, and reproducible across local and deployed environments, is slightly harder. That’s where Docker and Docker Compose come in.
MacOS High Sierra v10.13.1 苹果官方正式版(附安装+U盘安装),macOS High Sierra系统带来了全新的苹果文件系统,照片应用界面和编辑工具也有巨大变化,另外还有Safari 11,iCloud文件共享,各种底层架构改进等. Nov 13, 2017 To get this software, open the App Store and search for 'High Sierra.' After clicking on the entry, you will either see an Open or Download button. Once Install Disk Creator opens (Figure A. The easiest way to create a USB flash installer is with the free program, Disk Creator. Download the macOS Sierra installer and Disk Creator. Insert an 8GB (or larger) flash drive. Nov 29, 2017 How to download macOS High Sierra 10.13.1. As we mentioned earlier, Apple has now released macOS High Sierra 10.13.1, an updated version of High Sierra that includes a number of bug fixes. Disk creator high sierra.
Docker is a containerisation system, Docker Compose is a way to define how multiple Docker containers interact. In the context of Node web application development, Docker tends to be used to define a container that has the required system-level dependencies (eg. Node version, any extra database drivers). Docker Compose would be used to define dependencies outside of the Node application, for example databases.
To start off, we should create a new directory/initialise npm:
We can then install Express:
And create a server.js
file that looks like the following:
That can be run using:
We can check that it’s working as expected
To begin you’ll want to install Docker Community Edition (https://www.docker.com/community-edition).Then we can add a Dockerfile
and a docker-compose.yml
:
Now run the app inside of Docker/Docker Compose:
And check that it still works
Some extra context:
- The
Dockerfile
defines what container the application will be running in (here a Node 10 default container) docker-compose.yml
:build
explains which image should be used by theapp
service definition (in this case, it points to what would be created by running theDockerfile
)volumes
defines what should be mounted where (in this case, we’ll mount the whole directory as/var/www/app
ports
maps ports from the host system to ports inside the containerenvironment
sets environment variables for the containercommand
determines what will be run on startup of the container, here it runsnpm install
followed by the server startup command
To add Redis to our Express app we should use the redis
package:
Install Redis Docker Command
Then we should probably wrap all the callback-based methods we want to use (see the api docs for the redis package, https://github.com/NodeRedis/node_redis#api).Let’s do this using a redis-client.js
module:
To running Redis inside of Docker Compose in such a way that our app can access it:
We can now access the Redis client from the app container:
We can now create a HTTP API that will allow us to store data using query params and retrieve them using a get request (this isn’t RESTful at all but oh well 🙂 ).
Install Redis Docker Image
If you have any questions about the above code let me know @hugo__df. It is using a couple of more advanced features like async/await and destructuring as well as Express features to get query and path parameters (see https://expressjs.com/en/api.html#req.query, https://expressjs.com/en/api.html#req.params).
Get the app running again: docker-compose up
- Store some data:
- Retrieve that data:
Note to more advanced Express users, and API design gurus.The reason I used an old school query-param based system is to avoid the boilerplate of using body-parser
with POST requests
Full repository available at: https://github.com/HugoDF/express-redis-docker
Cover photo by Ben Koorengevel on Unsplash
Get The Jest Handbook (100 pages)
Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.
orJoin 1000s of developers learning about Enterprise-grade Node.js & JavaScript