Jea*_*eri 3 azure kubernetes azure-aks
我正在运行一个 Pod(网站)和一个简单的服务
apiVersion: v1
kind: Service
metadata:
name: ui
spec:
type: NodePort
selector:
app: ui
ports:
- protocol: TCP
port: 80
targetPort: 3000
$> kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR LABELS
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 83m <none> component=apiserver,provider=kubernetes
ui NodePort 10.0.25.205 <none> 80:30180/TCP 53m app=ui <none>
Run Code Online (Sandbox Code Playgroud)
由于此服务是一种类型,因此NodePort
它会在每个群集节点上打开一个端口。就我而言,我在 Azure 中运行 kubernetes,单节点设置。但我如何访问我的服务/网站?
$> kubectl describe service ui
Name: ui
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"Service","metadata": {"annotations":{},"name":"ui","namespace":"default"},"spec":{"ports":[{"port":80,"protocol"...
Selector: app=ui
Type: NodePort
IP: 10.0.25.205
Port: <unset> 80/TCP
TargetPort: 3000/TCP
NodePort: <unset> 30180/TCP
Endpoints: 10.244.0.14:3000,10.244.0.15:3000
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Type 29m service-controller NodePort -> LoadBalancer
Normal EnsuringLoadBalancer 29m service-controller Ensuring load balancer
Normal EnsuredLoadBalancer 27m service-controller Ensured load balancer
Normal Type 10m service-controller LoadBalancer -> NodePort
Normal DeletingLoadBalancer 10m service-controller Deleting load balancer
Normal DeletedLoadBalancer 9m5s service-controller Deleted load balancer
Run Code Online (Sandbox Code Playgroud)
我没有看到外部 IP。
例如,如果我更改NodePort
为LoadBalancer
我获得外部IP并且可以访问我的网站,但是我如何使用NodePort来做到这一点?
据我所知,AKS 是一项托管服务,它仅公开主服务器,该主服务器也由 Azure 管理以控制所有操作。从节点不暴露,默认没有外部IP。
在 AKS 群集中,只能通过具有负载均衡器的服务或入口(其服务也使用负载均衡器)来访问应用程序。
如果你确实想在你的服务中使用节点类型,也有一种方法可以解决。您可以手动创建公共 IP,并将其关联到要创建具有节点类型的服务的节点。然后节点就有了外部IP。但不建议对 AKS Iaas 进行所有操作。因此,如果您想从 Internet 访问这些服务,负载均衡器类型是最适合该服务的方式。
归档时间: |
|
查看次数: |
6114 次 |
最近记录: |