In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Several ways of exposing Service Ports by kubernetes
If you want to expose Service to an external IP address. Kubernetes supports four implementation methods. Details are as follows:
1: implement access within the cluster: Clusterip
Clusterip is a private ip within the cluster, so it is very convenient to access the service within the cluster, and it is also the default mode of the kuberentes cluster. It can be accessed directly through the Clusterip of service or through ServiceName. The outside of the cluster is inaccessible.
2: access outside the cluster: NodePort
NodePort is an early and widely used service exposure method in kubenretes. The service in Kubernetes uses the ClusterIP type by default. Such a service produces a ClusterIP that can only be accessed within the cluster. To allow external access to the service directly, you need to change the service type to nodePort. Map the service listening port to the node node.
ApiVersion: extensions/v1beta1kind: Deploymentmetadata: name: nginx-dmspec: replicas: 2 template: metadata: labels: name: nginx spec: containers:-name: nginx image: nginx:alpine imagePullPolicy: IfNotPresent ports:-containerPort: 80---apiVersion: v1kind: Servicemetadata: name: nginx-svcspec: type: NodePort ports:-port: 80 targetPort: 80 NodePort: 30004 protocol: TCP selector: name: nginx create kubectl create-f nginx-ds.yaml access test
Outside the cluster, services in the cluster can be accessed through the ip:nodeport of any node node
3:LoadBalancer
LoadBlancer Service is a component of kubernetes deeply combined with cloud platform. When using LoadBlancer Service to expose services, you actually expose services by applying to the underlying cloud platform to create a load balancer. Currently, the cloud platforms supported by LoadBlancer Service are relatively perfect, such as foreign GCE, DigitalOcean, domestic Aliyun, private cloud Openstack, and so on. Because LoadBlancer Service is deeply combined with cloud platforms, it can only be used on some cloud platforms.
4:Ingress
Ingress is a resource type introduced since the kubernetes1.1 version. Ingress controller must be deployed to create Ingress resources, and Ingress controller is provided as a plug-in.
Ingress is widely used: nginx and traefik, personally recommended to use traefik.
How to use Traefik configuration:
Https://blog.51cto.com/michaelkang/2429929
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: 205
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.