try Helm for first time

Shi
CI/CD/DevOps
Published in
2 min readJun 13, 2020

using Helm to deploy Redis

Prerequisite:

install kubectl
install minikube
install helm

Step to deploy redis server in the minikube cluster:

%minikube start%minikube status%kubectl get nodes //now we have a single node k8s cluster ready
NAME STATUS ROLES AGE VERSION
minikube Ready master 4m1s v1.18.3
%helm repo add bitnami https://charts.bitnami.com/bitnami%helm install redis bitnami/redis --set serviceType=NodePort
NAME: redis
LAST DEPLOYED: Sat Jun 13 06:52:39 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
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:
redis-master.default.svc.cluster.local for read/write operations
redis-slave.default.svc.cluster.local for read-only operations
To get your password run:export REDIS_PASSWORD=$(kubectl get secret --namespace default 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 redis-client --rm --tty -i --restart='Never' \
--env REDIS_PASSWORD=$REDIS_PASSWORD \
--image docker.io/bitnami/redis:6.0.5-debian-10-r2 -- bash
2. Connect using the Redis CLI:
redis-cli -h redis-master -a $REDIS_PASSWORD
redis-cli -h redis-slave -a $REDIS_PASSWORD
To connect to your database from outside the cluster execute the following commands:kubectl port-forward --namespace default svc/redis-master 6379:6379 &
redis-cli -h 127.0.0.1 -p 6379 -a $REDIS_PASSWORD

Testing the helm deployment

Let’s spin up a redis container and try to connect to the redis server,

ubuntu@ip-172-31-31-103:~/installer/synopsysctl$ kubectl run --namespace default redis-client --rm --tty -i --restart='Never' \
> --env REDIS_PASSWORD=$REDIS_PASSWORD \
> --image docker.io/bitnami/redis:6.0.5-debian-10-r2 -- bash
If you don't see a command prompt, try pressing enter.I have no name!@redis-client:/$ redis-cli -h redis-master -a $REDIS_PASSWORD
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
redis-master:6379> exit
I have no name!@redis-client:/$ redis-cli -h redis-slave -a $REDIS_PASSWORD
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
redis-slave:6379>

Let’s s expose the redis server port 6379 and connect to the redis server from outside the cluster,

$sudo apt install redis-tools$kubectl port-forward — namespace default svc/redis-master 6379:6379&&redis-cli -h 127.0.0.1 -p 6379 -a $REDIS_PASSWORD
Handling connection for 6379
127.0.0.1:6379>

wrap up and clear the environment.

ubuntu@ip-172-31-31-103:~/ws/psc-helm-chart$ helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION

redis default 1 2020-06-13 06:52:39.555187364 +0000 UTC deployed redis-10.7.1 6.0.5
ubuntu@ip-172-31-31-103:~/ws/psc-helm-chart$ helm delete chart-1592230489 chart-1592230776 redis

release "redis" uninstalled

Ref: https://docs.bitnami.com/kubernetes/get-started-kubernetes/

--

--

Shi
CI/CD/DevOps

I am a coder/engineer/application security specialist. I like to play around with language and tools; I have strong interest in efficiency improvement.