Showing posts with label Datastax. Show all posts
Showing posts with label Datastax. Show all posts

Wednesday, 29 August 2018

Datastax Containers on kubernetes

In this post i will help you to deploy datastax images on kubernetes and we can create a 2 node instance of datastax cluster.

We will deploy containers of   DSE-Search, DSE-Graph, DSE-Database, DSE-Analytics
In this step we will create a DSE Search enabled container and deploy that on node machines.

Commands used
The below yaml file help you to create a dse service for dse-search
#kubectl apply -f dse-search-lb-services.yaml

This will help us to create a volume
#kubectl apply -f dse-search-volume.yaml

This will help us to create a dse-search statefulset.
       #kubectl apply -f dse-search-statefulset.yaml


in the github repository you can see the other yaml files also. https://github.com/vishnuc95/Scripts-Kubernetes-Yaml- 

That we used to configure the DSE-Graph, DSE-Database, DSE-Analytics containers.

As mentioned above apply each yaml file for creating service,volume and statefulset for DSE containers.

#kubectl apply -f dse-graph-lb-services.yaml
#kubectl apply -f dse-graph-volume.yaml
      #kubectl apply -f dse-graph-statefulset.yaml
      #kubectl apply -f dse-database-lb-service.yaml
      #kubectl apply -f dse-database-volume.yaml
      #kubectl apply -f dse-database-statefulset.yaml
      #kubectl apply -f dse-analytics-lb-services.yaml
      #kubectl apply -f dse-analytics-volume.yaml
      #kubectl apply -f dse-analytics-statefulset.yaml




















Finally you can see 2 instance of all the containers. Now we are good with the DSE Containers.

Now we can connect to one of the service through the load balanced ip from the studio.

Log in to the studio and create a connection to the database through the load balanced IP
Please refer my previous blog post for creating studio service :http://biexplored.blogspot.com/2018/08/accessing-kubernetes-pods-from-outside.html

In the below screen shot you can see we have successfully created a connection to the database through the container.







Accessing Kubernetes pods from outside the cluster and Configuring Datastax DSE Studio

To access a kubernetes service from outside world we can use two methods

1) Through Node port
2) Through Load balancer.

If we are going to use Nodeport we can access the application through a port that we specify or kubernetes system will assign with the master ip.

If we are going to use Load balncer we can access the application through the external ip of the load balncer with the tcp port.

let us look into some example here for accessing the application from outside the cluster.

In this example i am usig MetalLB load balncer using layer 2 mode.

Step 1:   Install MetalLB on the cluster.

For this purpose we can use the metalib-kubectl.yaml that you can download from the github.

metalib-kubectl.yaml: https://github.com/vishnuc95/Scripts-Kubernetes-Yaml-/blob/master/metalib-kubectl.yaml

# kubectl apply -f metalib-kubectl.yaml














After installing you can see metallb system created one controller for the master node and 2 speakers for the slave nodes.









·      Step 2:  Configure MetalLB to announce using layer 2 mode and give it some IP addresses to manage
      
      We can have a look into the configuration file
















Here you can see we have specified a range of private ip from 10.30.1.15-10.30.1.19 so metallb will use this range of ip while assigning the ip address. Please use a ip that available to you for configuring.

Note: Please select  a range of private ip after discussing with your network team for making sure that there will not be any ip conflict in future. 

Now we can apply this changes into the system.
# kubectl apply -f metalib-layer2-config.yaml

metalib-layer2-config.yaml: https://github.com/vishnuc95/Scripts-Kubernetes-Yaml-/blob/master/metalib-layer2-config.yaml

You can see the logs using the command #kubectl logs -l component=speaker -n metallb-system







Step 3: Create a load-balanced service, and observe how MetalLB sets it up.

Now we are good with the metallb-system and we can proceed with deploying an application in the cluster. 

We are going to deploy DSE studio as a load balanced service.

#kubectl apply -f dse-studio-deployment.yaml
dse-studio-deployment.yaml : https://github.com/vishnuc95/Scripts-Kubernetes-Yaml-/blob/master/dse-studio-deployment.yaml

Change the values of

nodePort:
loadBalancerIP:

Based on the ip addess that you provided when creating layer 2 configuration.






We can see a new service stated as a load balancer type and it assigned with an ip address and port.







You will be able to access the machine using external ip and tcp port 9091














Try to access the Studio using the master_machine_ip:30455 from outside of your machine(We are accessing this through node port).

In our case the url is http://<Master_IP>:30455

So you can see Datastax Studio is up and running.