我试图在kubernetes上部署nginx, kubernetes版本是v1.5.2,
我已经部署了nginx的3个副本,YAML文件如下,
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: deployment-example
spec:
replicas: 3
revisionHistoryLimit: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.10
ports:
- containerPort: 80
现在我想在节点的30062端口上公开它的80端口,为此我在下面创建了一个服务,
kind: Service
apiVersion: v1
metadata:
name: nginx-ils-service
spec:
ports:
- name: http
port: 80
nodePort: 30062
selector:
app: nginx
type: LoadBalancer
这项服务工作得很好,但它不仅在kubernetes仪表板上也在终端上显示为待定。
为在amazon-eks上运行时遇到此错误的用户添加解决方案。
首先运行:
kubectl describe svc <service-name>
然后查看下面示例输出中的events字段:
Name: some-service
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"some-service","namespace":"default"},"spec":{"ports":[{"port":80,...
Selector: app=some
Type: LoadBalancer
IP: 10.100.91.19
Port: <unset> 80/TCP
TargetPort: 5000/TCP
NodePort: <unset> 31022/TCP
Endpoints: <none>
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 68s service-controller Ensuring load balancer
Warning SyncLoadBalancerFailed 67s service-controller Error syncing load balancer: failed to ensure load balancer: could not find any suitable subnets for creating the ELB
查看错误消息:
Failed to ensure load balancer: could not find any suitable subnets for creating the ELB
在我的例子中,没有为创建ELB提供合适的子网的原因是:
原因1:EKS集群部署在错误的子网组中——内部子网,而不是公网子网。
(*)默认情况下,如果没有service.beta.kubernetes, LoadBalancer类型的服务将创建面向公共的负载均衡器。Io /aws-load-balancer-internal:“true”注释)。
2:子网没有按照这里提到的要求进行标记。
为VPC添加标签:
Key: kubernetes.io/cluster/yourEKSClusterName
Value: shared
用以下标记公共子网:
Key: kubernetes.io/role/elb
Value: 1
我在AWS EKS上也有同样的问题
问题是这样解决的:
Amazon虚拟私有云(Amazon VPC)的正确标记
子网
所需的AWS IAM (Identity and Access Management)权限
一个有效的Kubernetes服务定义Load
有足够的空闲IP地址
在子网上
需要确保以下标签
关键:kubernetes.io /集群/ yourEKSClusterName
价值:分享
关键:kubernetes.io /角色/ elb
值:1
关键:kubernetes.io /角色/ internal-elb
值:1
供参考,也确保sts是为您正在工作的区域启用sts设置可以在用户,区域设置下找到。
为在amazon-eks上运行时遇到此错误的用户添加解决方案。
首先运行:
kubectl describe svc <service-name>
然后查看下面示例输出中的events字段:
Name: some-service
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"some-service","namespace":"default"},"spec":{"ports":[{"port":80,...
Selector: app=some
Type: LoadBalancer
IP: 10.100.91.19
Port: <unset> 80/TCP
TargetPort: 5000/TCP
NodePort: <unset> 31022/TCP
Endpoints: <none>
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 68s service-controller Ensuring load balancer
Warning SyncLoadBalancerFailed 67s service-controller Error syncing load balancer: failed to ensure load balancer: could not find any suitable subnets for creating the ELB
查看错误消息:
Failed to ensure load balancer: could not find any suitable subnets for creating the ELB
在我的例子中,没有为创建ELB提供合适的子网的原因是:
原因1:EKS集群部署在错误的子网组中——内部子网,而不是公网子网。
(*)默认情况下,如果没有service.beta.kubernetes, LoadBalancer类型的服务将创建面向公共的负载均衡器。Io /aws-load-balancer-internal:“true”注释)。
2:子网没有按照这里提到的要求进行标记。
为VPC添加标签:
Key: kubernetes.io/cluster/yourEKSClusterName
Value: shared
用以下标记公共子网:
Key: kubernetes.io/role/elb
Value: 1