Follow these steps to achieve desired functionality like previously shown in
mysql-deployment.
Used image of Redis https://hub.docker.com/_/redis has to be wrapped in the similar manner and exposed as redis-service:6379.
This tutorial shows cluster overview by Lens (via kubectl) rather than raw kubectl CLI.
Generate base64 password and place it into redis-secret file.
➜ redis-deployment git:(main) ✗ chmod u+x 0-encode-base64.zsh
➜ redis-deployment git:(main) ✗ zsh 0-encode-base64.zsh password
cGFzc3dvcmQ=
➜ redis-deployment git:(main) ✗ kubectl apply -f 0-redis-secret.yaml
secret/redis-secrets created➜ redis-deployment git:(main) ✗ kubectl apply -f 1-pv-pvc-redis.yaml ➜ redis-deployment git:(main) ✗ kubectl apply -f 2-deployment-redis.yaml ➜ redis-deployment git:(main) ✗ kubectl apply -f 3-service-redis.yaml Redis should be running on tcp://redis-service:6379?auth=PASSWD
Both MySQL and Redis are were tested on multireplica deployment of our LAMP application SwimmPair.
Peek. Visualization on how containers share databases - which have both persistent storage. Database for obvious purposes, Redis for keeping sessions live in case of reboots or death of all containers.
- mysql-service:3306,
- redis-service:6379.
We, however, have to change php.ini to adjust PHP for using Redis for session handling as follows:
session.save_handler: 'redis'
session.save_path: 'tcp://redis:6379?auth=aGVzbG8='Our docker image thecodingmachine/php:7.2-v4-apache has way how to override these params via ENV VARIABLES. Both docker-compose and Kubernetes Deployment have same notation.
environment:
PHP_INI_SESSION__SAVE_HANDLER: 'redis'
PHP_INI_SESSION__SAVE_PATH: 'tcp://redis:6379?auth=aGVzbG8='After that we should be able to call phpinfo(); to see session.save_handler and session.save_path set up as mentioned above.





