Deploy Redis Cluster on Kubernetes

Ticker

6/recent/ticker-posts

Deploy Redis Cluster on Kubernetes

 Question:  1.) Create Persistent Volumes as mentioned below:

a) Create a first PersistentVolume which should be named redis-pv-01. Configure spec as accessModes which should be ReadWriteOnce, storage capacity should be 1Gi, Type should be hostPath, its hostPath should be /redis01 and directory should be already created on the worker node.

b. Create a second PersistentVolume which should be named redis-pv-02. Configure spec as accessModes which should be ReadWriteOnce, storage capacity should be 1Gi, Type should be hostPath, its hostPath should be /redis02 and directory should already be created on the worker node.

c. Create a third PersistentVolume which should be named redis-pv-03. Configure spec as accessModes which should be ReadWriteOnce, storage capacity should be 1Gi, Type: hostPath, hostPath: /redis03, directory should be already created on the worker node.

d. Creata a fourth PersistentVolume which should be named redis-pv-04. Configure spec as accessModes should be ReadWriteOnce, storage capcity should be 1Gi, Type should be hostPath, its hostPath should be /redis04 and directory should be already created on the worker node.

e. Create a fifth PersistentVolume which should be named as redis-pv-05. Configure spec as accessModes which should be ReadWriteOnce, storage capacity should be 1Gi, Type should be hostPath, its hostPath should be /redis05 and directory should be already created on the worker node.

f. Create a sixth PersistentVolume which should be named redis-pv-06. Configure spec as accessModes which should be ReadWriteOnce, storage capacity should be 1Gi, Type should be hostPath, hostPath should be /redis06 and directory should be already created on the worker node.

2.) We already created ConfigMap named as redis-cluster-configmap. You can try to inspect it.

3.) Create a service which should be named redis-cluster-service. Configure spec as first port name should be client, its port should be 6379 and its targetPort should be 6379. The second port name should be gossip, its port should be 16379 and its targetPort should be 16379, its type should be ClusterIP. And the selector's app should be redis-cluster.

4.) Create a StatefulSet which should be named redis-cluster. Confiugre spec as replicas should be 6, selector's matchLabels app should be redis-cluster. Template's labels app should be redis-cluster under the metadata. The container name should be redis-container, use image redis:5.0.1-alpine ( use exact name of image as mentioned ), use command: ["/conf/update-node.sh", "redis-server", "/conf/redis.conf"], env name should be POD_IP, valueFrom should be fieldRef, fieldPath should be status.podIP (apiVersion: v1). First port name should be client, its containerPort should be 6379, second port name should be gossip, its containerPort should be 16379. First volumeMount name should be conf, its mountPath should be /conf and readOnly should be false ( ConfigMap Mount ), second volumeMount name should be data, its mountPath should be /data, readOnly should be false ( volumeClaim ). Volume name should be conf, its configMap name should be redis-cluster-configmap and its defaultMode should be 0755. volumeClaimTemplates name should be data under metadata, accessModes should be ReadWriteOnce and storage request should be 1Gi.

5.) Configure the Cluster. Once the StatefulSet has been deployed with 6 Running pods, run the following commands and type yes when prompted. Command: kubectl exec -it redis-cluster-0 -- redis-cli --cluster create --cluster-replicas 1 $(kubectl get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 {end}').


Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍

Solution:  

1. At first  kubectl  utility configure and working from jump server, run below commands

    kubectl get namespace

    kubectl get pods

    kubectl get pv


2. Create first persistent volumes & then deploy the pods & services


 3. Create yaml  file with all the parameters , you can copy form gitlab

    https://gitlab.com/nb-tech-support/devops.git


    Refer Below Video for more clarity )



4.  Wait for pod running status 

    kubectl get pods


5.  Validate the task by executing command given in task  
    

6.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this , 

please go through and share your comments. Like and share the knowledge




Post a Comment

25 Comments

  1. Can you please share the link for the ConfigMap file. I couldn't find it anywhere

    ReplyDelete
    Replies
    1. I have mailed you the configmap , even kept on gitlab. Please have look. Keep learning

      Delete
    2. tawfikemohamed@yahoo.com

      Delete
    3. Can I have it also, yhis is my email: mikezbragais@gmail.com

      Delete
    4. I have mailed you please check. Keep Learning

      Delete
  2. could you pls explain about config map( /conf/update-node.sh", "redis-server", "/conf/redis.conf)

    ReplyDelete
    Replies
    1. I have kept on gitlab. If you wont able to find then share me your email id, will mail you.
      Keep learning

      Delete
  3. Hi, I couldn't see the configmap on GitLab, could you please mail the yaml for configmap to me? Many thanks!

    ReplyDelete
    Replies
    1. Thanks for approching , I have emailed you . Keep Learning

      Delete
  4. I couldn't see the configmap on GitLab, could you please mail the yaml for configmap to me?

    ReplyDelete
  5. Can you please share the link for the ConfigMap file. I couldn't find it anywhere

    ReplyDelete
  6. Can you please share the config map

    ReplyDelete
    Replies
    1. Sure will share . Please share your email id or check mine git repo

      Delete
  7. I couldn't see the configmap on GitLab, could you share the link for that?

    ReplyDelete
  8. Can you please share the link for config map in git repo?

    ReplyDelete
    Replies
    1. I have kept on gitlab. If you wont able to find then share me your email id, will mail you.
      Keep learning

      Delete

  9. Can you please share the link for config map in git repo?
    namle1254@gmail.com

    ReplyDelete
    Replies
    1. Thanks for approaching. I have email you config map , please check

      Delete
    2. sorry, my mail is namle1264@gmail.com

      Delete
  10. Can you please share the link for config map in git repo?
    saiatainas@gmail.com

    ReplyDelete
  11. Can you please share the link for config map in git repo?
    manifest998@gmail.com

    ReplyDelete
  12. can u pls share configmap? akshay10101053@gmail.com

    ReplyDelete