Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to connect basic applications through Kubernetes services

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to connect basic applications through Kubernetes services. Xiaobian thinks it is quite practical, so share it with you. I hope you can gain something after reading this article. Let's not say much. Let's take a look at it together with Xiaobian.

This is the most basic and fundamental feature that all Kubernetes CNI plugins can provide. Application Pods need to be able to communicate with each other, and Kubernetes Services is a way to ensure that Pods achieve application scale and availability over time.

usage scenarios

All major CNI plug-ins provide basic pod-to-Pod connectivity as well as certain service types, such as ClusterIP.

In addition, Tungsten Fabric natively supports LoadBalancer. When running on AWS, LoadBalancer uses Services in an inventory to create a public-facing AWS ELB, making your application accessible in one step from the Internet.

This also means that Kubernetes deployment manifests can be used in applications without change for all Tungsten Fabric integrated Kubernetes, both on-premises and in all major public clouds.

deployment

When creating a deployment, CNI works with Kubernetes to assign network IP addresses to each application pod and "connect" each Pod to the cluster network.

Note: Most CNIs work by creating an overlay network, which in most cases is contained within the boundaries of a single Kubernetes cluster. Therefore, pods in different clusters cannot communicate directly.

We won't cover multi-cluster scenarios in this document, but Tungsten Fabric can support such configurations. Tungsten Fabric can serve multiple Kubernetes clusters simultaneously with a single installation. In this case, pods from different clusters can communicate directly with each other, even if the Kubernetes clusters themselves are located in different locations.

service

Services in Kubernetes are "abstract methods that expose applications running on a set of pods." In most cases, services are simple Round-Robin Load Balancer. It has a virtual IP address ("VIP") for receiving network requests and IP addresses of zero or more endpoints that accept forwarding of those requests.

In most cases, the service automatically discovers endpoint IP addresses belonging to application pods by looking for matching labels (called selectors) on running pods.

Deployment and service examples for applications

Make sure you are on the sandbox control node, logged in as root, and in the correct directory:

#Make sure you are root account

whoami | grep root || sudo -s

#Switch to inventory directory

cd /home/centos/yelb/deployments/platformdeployment/Kubernetes/yaml

Look in the cnawebapp-loadbalancer.yaml file for sections that begin with Kind: Deployment and Kind: Service

less cnawebapp-loadbalancer.yaml

(Use arrows/ PgUp / PgDn to navigate; press q to exit)

Note:

spec.template.spec.containers.ports.containerPort Displays TCP ports on which the Pod will listen in Deployments;

spec.ports Displays the ports on which the service's VIP will listen in the service;

spec.selector displays the label on the Pod to which the service is sending traffic in the service.

Next, deploy our sample application and see what happens:

kubectl create -f cnawebapp-loadbalancer.yaml

This creates the following application topology:

If there are no errors in the application deployment, we should be able to see:

All pods have their own IP addresses and are listening on their respective ports:

All services have VIP and listening ports:

All services discover their endpoints:

Since Tungsten Fabric provides LoadBalancer service support for Kubernetes, it should now be possible to connect to our application from the Internet. We can find out the public DNS name of the Load Balancer:

Let's examine this by pointing our web browser to this address and see that the app is located at:

aa01af9988cc311e9badf06b57ebf630-1452353610.us-west-1.elb.amazonaws.com

It worked!

clean up

After using the application, you can cancel deployment at any time:

kubectl delete -f cnawebapp-loadbalancer.yaml

The above is how to connect basic applications through Kubernetes services. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report