I ran into some trouble getting an external ip address after posting the following json object (variables excluded):
$json= '{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": ""
},
"spec": {
"ports": [{
"port": 80,
"targetPort": 80
}],
"selector": {
"app": ""
},
"type": "LoadBalancer"
}
}';
The service is created but no external ip is ever given.
Unable to determine where the issue lay, I proceeded to install a clean copy of kubernetes (and the cluster it is defined to install) using the following command provided in the documentation (V1 kubernetes/examples/simple-nginx.md):
curl -sS https://get.k8s.io | bash
This of course set things up automatically. I then ran the following commands to test if the LoadBalancer function was working:
kubectl run my-nginx --image=nginx --replicas=2 --port=80
After running kubectl get pods
to confirm that they were ready, I exposed the service:
kubectl expose rc my-nginx --port=80 --type=LoadBalancer
I then ran kubectl get service
for the past few minutes, and no public ip is being provided..
That cant be right?
EDIT
kubectl get services
NAME LABELS SELECTOR IP(S) PORT(S)
kubernetes component=apiserver,provider=kubernetes <none> 10.0.0.1 443/TCP
my-nginx run=my-nginx run=my-nginx 10.0.136.163 80/TCP
kubectl get service my-nginx -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: 2015-08-11T11:44:02Z
labels:
run: my-nginx
name: my-nginx
namespace: default
resourceVersion: "1795"
selfLink: /api/v1/namespaces/default/services/my-nginx
uid: 434751be-401e-11e5-a219-42010af0da43
spec:
clusterIP: 10.x.xxx.xxx
ports:
- nodePort: 31146
port: 80
protocol: TCP
targetPort: 80
selector:
run: my-nginx
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
After running (Thanks GameScripting):
kubectl describe service my-nginx
I saw the following error:
FirstSeen LastSeen Count From SubobjectPath Reason Message
Tue, 11 Aug 2015 14:00:00 +0200 Tue, 11 Aug 2015 14:02:41 +0200 9 {service-controller } creating loadbalancer failed failed to create external load balancer for service default/my-nginx: googleapi: Error 403: Quota 'FORWARDING_RULES' exceeded. Limit: 15.0
On the Deployment details page, click list Actions > Expose. In the Expose dialog, under Port mapping, set the following values: Port: 80. Target port: 8080.
kubectl expose − This is used to expose the Kubernetes objects such as pod, replication controller, and service as a new Kubernetes service. This has the capability to expose it via a running container or from a yaml file.
After manually removing the Forwarding Rules Under "Networking->Load Balancing->Network Load Balancing" (Or you can use gcloud compute forwarding-rules delete
) I was able to get public Ip's again. It seems somehow the forwarding rules werent deleted and reached the limit. It is strange as when I ran Kubectl stop service
it removed the forwarding rule for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With