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.
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.
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
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.
No comments:
Post a Comment