gpt4 book ai didi

azure - AKS 公共(public) IP 无法访问

转载 作者:行者123 更新时间:2023-12-02 01:03:49 28 4
gpt4 key购买 nike

我的入口服务中有以下配置:

apiVersion: v1
kind: Service
metadata:
name: nginx-ingress
namespace: nginx-ingress
spec:
externalTrafficPolicy: Local
type: LoadBalancer
loadBalancerIP: **.***.**.***
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
targetPort: 443
protocol: TCP
name: https
selector:
app: nginx-ingress

我们已从 azure 购买了此公共(public) IP。如果我们从服务 yaml 中删除此 loadBalancerIP 并部署,然后使用 kubectl get services -n nginx-ingress 列出的 ip,那么当我们访问服务端点时它可以正常工作。但对于这个公共(public) IP 似乎没有任何作用。

请找到以下服务描述(kubectl 描述服务 nginx-ingress -n nginx-ingress-os):

[openapianil@LHGOPENAPIDEV001 github]$ kubectl describe service nginx-ingress -n nginx-ingress-os
Name: nginx-ingress
Namespace: nginx-ingress-os
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"nginx-ingress","namespace":"nginx-ingress-os"},"spec":{"externalTrafficPolicy"...
Selector: app=nginx-ingress
Type: LoadBalancer
IP: 10.0.0.44
IP: **.**.**.***
LoadBalancer Ingress: **.**.**.***
Port: http 80/TCP
TargetPort: 80/TCP
NodePort: http 31247/TCP
Endpoints: **.**.**.***:80
Port: https 443/TCP
TargetPort: 443/TCP
NodePort: https 32241/TCP
Endpoints: **.**.**.***:443
Session Affinity: None
External Traffic Policy: Local
HealthCheck NodePort: 30880
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 1m service-controller Ensuring load balancer
Normal EnsuredLoadBalancer 43s service-controller Ensured load balancer

请帮忙!!

最佳答案

众所周知,AKS创建完成后,Azure会创建两个资源组。

如果您想使用 IP 地址创建服务,则应在另一个资源组中创建静态 IP 地址,名称如 MC_myResourceGRoup_myAKSCluster_eastus

您可以使用 Azure CLI 命令创建公共(public) IP 地址:

az network public-ip create --resource-group MC_myResourceGRoup_myAKSCluster_eastus --name myAKSPublicIP --allocation-method static

您也可以使用 Azure 门户来创建它,但无法向其中添加 DNS。

然后你可以像这样使用静态IP地址:

apiVersion: v1
kind: Service
metadata:
name: azure-vote-front1
spec:
type: LoadBalancer
loadBalancerIP: 52.224.235.119
ports:
- port: 80
selector:
app: azure-vote-front1

结果如下:

enter image description here

注意:

1.创建不带 DNS 名称的 Azure 公共(public) IP 地址。
2.在此资源组MC_myResourceGRoup_myAKSCluster_eastus中创建Azure公共(public)IP地址。
3.您可以使用kubectl描述服务来检查状态,如下所示:

[root@jasoncli@jasonye jason]# kubectl describe service azure-vote-front1
Name: azure-vote-front1
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=azure-vote-front1
Type: LoadBalancer
IP: 10.0.76.241
IP: 52.224.235.119
LoadBalancer Ingress: 52.224.235.119
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 30416/TCP
Endpoints: 10.244.0.11:80
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CreatingLoadBalancer 45m service-controller Creating load balancer
Normal CreatedLoadBalancer 44m service-controller Created load balancer

更新:

这是我的 yaml 文件:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: azure-vote-back
spec:
replicas: 1
template:
metadata:
labels:
app: azure-vote-back
spec:
containers:
- name: azure-vote-back
image: redis
ports:
- containerPort: 6379
name: redis
---
apiVersion: v1
kind: Service
metadata:
name: azure-vote-back
spec:
ports:
- port: 6379
selector:
app: azure-vote-back
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: azure-vote-front
spec:
replicas: 1
template:
metadata:
labels:
app: azure-vote-front
spec:
containers:
- name: azure-vote-front
image: microsoft/azure-vote-front:v1
ports:
- containerPort: 80
env:
- name: REDIS
value: "azure-vote-back"
---
apiVersion: v1
kind: Service
metadata:
name: azure-vote-front
spec:
loadBalancerIP: 40.71.3.119
type: LoadBalancer
ports:
- port: 80
selector:
app: azure-vote-front

关于azure - AKS 公共(public) IP 无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48859877/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com