我按照https://github.com/terraform-providers/terraform-provider-aws/tree/master/examples/eks-getting-started中的描述在aws上创建了一个简单的 EKS 集群。
在此集群中,我创建了 nginx部署和类型为 Loadbalancer 的服务,如下所述。 该配置在minikube上本地工作。
在AWS上,我看到启动了pod和服务,该服务具有一个外部ip,我可以使用kubectl port-forward访问pod,并且可以ping LoadBalancer。
但是我无法通过浏览器通过http://a53439687c6d511e8837b02b7cab13e7-935938560.eu-west-1.elb.amazonaws.com:3001访问负载均衡器
我收到This site can’t be reached
知道我应该去哪里看看吗?
NGinx部署
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
labels:
run: nginx
name: nginx
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
run: nginx
template:
metadata:
creationTimestamp: null
labels:
run: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
ports:
- containerPort: 80
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
NGinx服务
{
"kind":"Service",
"apiVersion":"v1",
"metadata":{
"name":"nginx",
"labels":{
"app":"nginx"
}
},
"spec":{
"ports": [
{
"port":3001,
"targetPort":80
}
],
"selector":{
"run":"nginx"
},
"type": "LoadBalancer"
}
}
检查
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 172.20.0.1 <none> 443/TCP 1h
nginx LoadBalancer 172.20.48.112 a53439687c6d511e8837b02b7cab13e7-935938560.eu-west-1.elb.amazonaws.com 3001:31468/TCP 45m
kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-768979984b-vqz94 1/1 Running 0 49m
kubectl port-forward pod/nginx-768979984b-vqz94 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
ping a53439687c6d511e8837b02b7cab13e7-935938560.eu-west-1.elb.amazonaws.com
PING a53439687c6d511e8837b02b7cab13e7-935938560.eu-west-1.elb.amazonaws.com (62.138.238.45) 56(84) bytes of data.
64 bytes from 62.138.238.45 (62.138.238.45): icmp_seq=1 ttl=250 time=7.21 ms
服务说明
Name: nginx
Namespace: default
Labels: app=nginx
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"nginx"},"name":"nginx","namespace":"default"},"spec":{"ports":[{"port...
Selector: run=nginx
Type: LoadBalancer
IP: 172.20.48.112
LoadBalancer Ingress: a53439687c6d511e8837b02b7cab13e7-935938560.eu-west-1.elb.amazonaws.com
Port: <unset> 3001/TCP
TargetPort: 80/TCP
NodePort: <unset> 31468/TCP
Endpoints: 10.0.0.181:80
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 57m service-controller Ensuring load balancer
Normal EnsuredLoadBalancer 57m service-controller Ensured load balancer