Helm Redis NodePort
Set ServiceType as NodePort
helm install --set master.service.type=NodePort stable/redis
NAME: impressive-alligator
LAST DEPLOYED: Wed Jun 20 20:40:39 2018
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1beta1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
impressive-alligator-redis-slave 1 1 1 0 0s
==> v1beta2/StatefulSet
NAME DESIRED CURRENT AGE
impressive-alligator-redis-master 1 1 0s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
impressive-alligator-redis-slave-6f59bfdf89-mbj8l 0/1 ContainerCreating 0 0s
impressive-alligator-redis-master-0 0/1 Pending 0 0s
==> v1/Secret
NAME TYPE DATA AGE
impressive-alligator-redis Opaque 1 0s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
impressive-alligator-redis-master NodePort 100.64.116.136 <none> 6379:32149/TCP 0s
impressive-alligator-redis-slave NodePort 100.67.196.191 <none> 6379:32680/TCP 0s
NOTES:
** Please be patient while the chart is being deployed **
Redis can be accessed via port 6379 on the following DNS names from within your cluster:
impressive-alligator-redis-master.default.svc.cluster.local for read/write operations
impressive-alligator-redis-slave.default.svc.cluster.local for read-only operations
To get your password run:
export REDIS_PASSWORD=$(kubectl get secret --namespace default impressive-alligator-redis -o jsonpath="{.data.redis-password}" | base64 --decode)
To connect to your Redis server:
1. Run a Redis pod that you can use as a client:
kubectl run --namespace default impressive-alligator-redis-client --rm --tty -i \
--env REDIS_PASSWORD=$REDIS_PASSWORD \
--image docker.io/bitnami/redis:4.0.10 -- bash
2. Connect using the Redis CLI:
redis-cli -h impressive-alligator-redis-master -a $REDIS_PASSWORD
redis-cli -h impressive-alligator-redis-slave -a $REDIS_PASSWORD
To connect to your database from outside the cluster execute the following commands:
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services impressive-alligator-redis-master)
redis-cli -h $NODE_IP -p $NODE_PORT -a $REDIS_PASSWORD
Connect to Redis outside the cluster
export REDIS_PASSWORD=$(kubectl get secret --namespace default impressive-alligator-redis -o jsonpath="{.data.redis-password}" | base64 --decode)
echo $REDIS_PASSWORD
XLFVFbdhRv
export NODE_IP=`curl icanhazip.com`
echo $NODE_IP
13.127.94.53
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services impressive-alligator-redis-master)
echo $NODE_PORT
32149
redis-cli -h $NODE_IP -p $NODE_PORT -a $REDIS_PASSWORD
13.127.94.53:32149> set foo bar
OK
13.127.94.53:32149> get foo
"bar"
13.127.94.53:32149>