Kubernetes服务外部IP未被分配
我有以下部署yaml:
apiVersion: v1 kind: Namespace metadata: name: authentication labels: name: authentication --- apiVersion: apps/v1beta1 kind: Deployment metadata: name: authentication-deployment namespace: authentication spec: replicas: 2 template: metadata: labels: app: authentication spec: containers: - name: authentication image: blueapp/authentication:0.0.0 ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: authentication-service namespace: authentication spec: type: NodePort ports: - port: 8080 targetPort: 8080 selector: name: authentication-deployment type: LoadBalancer externalName: authentication
我对kubernetes很新,但是我对Im试图做什么的理解是创build一个名称空间,在该名称空间中创build2个pod的部署,然后创build一个负载均衡器以将stream量分发到这些pod。
当我跑步
$ kubectl create -f deployment.yaml
一切都创造良好,但该服务永远不会被分配一个外部IP
有什么明显的可能导致这个?
你的服务是NodePort
types的。 要获得分配给您的服务的负载均衡器,您应该使用LoadBalancer服务types:
type: LoadBalancer
在这里看到文档: https : //kubernetes.io/docs/concepts/services-networking/service/#publishing-services—service-types
只有在支持的云环境中才能分配外部IP,只要您的云提供商configuration正确。
在创build服务时,请kube-controller-manager
日志中的错误消息。