Merge pull request #12423 from brendandburns/service
Make services print on a single line.
This commit is contained in:
@@ -67,8 +67,8 @@ kubectl expose rc nginx --port=80
|
||||
This should print:
|
||||
|
||||
```console
|
||||
NAME LABELS SELECTOR IP PORT(S)
|
||||
nginx <none> run=nginx <ip-addr> 80/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
nginx 10.179.240.1 <none> 80/TCP run=nginx 8d
|
||||
```
|
||||
|
||||
Hit the webserver:
|
||||
|
@@ -151,11 +151,11 @@ kubectl expose rc nginx --port=80
|
||||
This should print:
|
||||
|
||||
```console
|
||||
NAME LABELS SELECTOR IP PORT(S)
|
||||
nginx run=nginx run=nginx <ip-addr> 80/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
nginx 10.0.93.211 <none> 80/TCP run=nginx 1h
|
||||
```
|
||||
|
||||
If ip-addr is blank run the following command to obtain it. Know issue #10836
|
||||
If `CLUSTER_IP` is blank run the following command to obtain it. Know issue #10836
|
||||
|
||||
```sh
|
||||
kubectl get svc nginx
|
||||
|
@@ -145,15 +145,11 @@ $ kubectl get --all-namespaces services
|
||||
should show a set of [services](../user-guide/services.md) that look something like this:
|
||||
|
||||
```console
|
||||
NAMESPACE NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
default kubernetes component=apiserver,provider=kubernetes <none> 10.0.0.1 443/TCP
|
||||
kube-system kube-dns k8s-app=kube-dns,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeDNS k8s-app=kube-dns 10.0.0.10 53/UDP
|
||||
53/TCP
|
||||
kube-system kube-ui k8s-app=kube-ui,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeUI k8s-app=kube-ui 10.0.59.25 80/TCP
|
||||
kube-system monitoring-grafana kubernetes.io/cluster-service=true,kubernetes.io/name=Grafana k8s-app=influxGrafana 10.0.41.246 80/TCP
|
||||
kube-system monitoring-heapster kubernetes.io/cluster-service=true,kubernetes.io/name=Heapster k8s-app=heapster 10.0.59.48 80/TCP
|
||||
kube-system monitoring-influxdb kubernetes.io/cluster-service=true,kubernetes.io/name=InfluxDB k8s-app=influxGrafana 10.0.210.156 8083/TCP
|
||||
8086/TCP
|
||||
NAMESPACE NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
default kubernetes 10.0.0.1 <none> 443/TCP <none> 1d
|
||||
kube-system kube-dns 10.0.0.2 <none> 53/TCP,53/UDP k8s-app=kube-dns 1d
|
||||
kube-system kube-ui 10.0.0.3 <none> 80/TCP k8s-app=kube-ui 1d
|
||||
... 8086/TCP
|
||||
```
|
||||
|
||||
Similarly, you can take a look at the set of [pods](../user-guide/pods.md) that were created during cluster startup.
|
||||
|
@@ -227,7 +227,7 @@ $ ./cluster/kubectl.sh get pods
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
|
||||
$ ./cluster/kubectl.sh get services
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
|
||||
$ ./cluster/kubectl.sh get replicationcontrollers
|
||||
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
||||
@@ -282,11 +282,8 @@ my-nginx-gr3hh 1/1 Running 0 1m
|
||||
my-nginx-xql4j 1/1 Running 0 1m
|
||||
|
||||
$ ./cluster/kubectl.sh get services
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
|
||||
$ ./cluster/kubectl.sh get replicationcontrollers
|
||||
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
||||
my-nginx my-nginx nginx run=my-nginx 3
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
my-nginx 10.0.0.1 <none> 80/TCP run=my-nginx 1h
|
||||
```
|
||||
|
||||
We did not start any services, hence there are none listed. But we see three replicas displayed properly.
|
||||
|
@@ -133,8 +133,9 @@ Check your Service:
|
||||
|
||||
```console
|
||||
$ kubectl get svc
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
nginxsvc app=nginx app=nginx 10.0.116.146 80/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
kubernetes 10.179.240.1 <none> 443/TCP <none> 8d
|
||||
nginxsvc 10.179.252.126 122.222.183.144 80/TCP,81/TCP,82/TCP run=nginx2 11m
|
||||
```
|
||||
|
||||
As mentioned previously, a Service is backed by a group of pods. These pods are exposed through `endpoints`. The Service's selector will be evaluated continuously and the results will be POSTed to an Endpoints object also named `nginxsvc`. When a pod dies, it is automatically removed from the endpoints, and new pods matching the Service’s selector will automatically get added to the endpoints. Check the endpoints, and note that the IPs are the same as the pods created in the first step:
|
||||
@@ -195,9 +196,8 @@ Kubernetes offers a DNS cluster addon Service that uses skydns to automatically
|
||||
|
||||
```console
|
||||
$ kubectl get services kube-dns --namespace=kube-system
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
kube-dns <none> k8s-app=kube-dns 10.0.0.10 53/UDP
|
||||
53/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
kube-dns 10.179.240.10 <none> 53/UDP,53/TCP k8s-app=kube-dns 8d
|
||||
```
|
||||
|
||||
If it isn’t running, you can [enable it](http://releases.k8s.io/HEAD/cluster/addons/dns/README.md#how-do-i-configure-it). The rest of this section will assume you have a Service with a long lived IP (nginxsvc), and a dns server that has assigned a name to that IP (the kube-dns cluster addon), so you can talk to the Service from any pod in your cluster using standard methods (e.g. gethostbyname). Let’s create another pod to test this:
|
||||
@@ -412,18 +412,18 @@ Lets now recreate the Service to use a cloud load balancer, just change the `Typ
|
||||
```console
|
||||
$ kubectl delete rc, svc -l app=nginx
|
||||
$ kubectl create -f ./nginx-app.yaml
|
||||
$ kubectl get svc -o json | grep -i ingress -A 5
|
||||
"ingress": [
|
||||
{
|
||||
"ip": "104.197.68.43"
|
||||
}
|
||||
]
|
||||
}
|
||||
$ curl https://104.197.68.43 -k
|
||||
$ kubectl get svc nginxsvc
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
nginxsvc 10.179.252.126 162.222.184.144 80/TCP,81/TCP,82/TCP run=nginx2 13m
|
||||
|
||||
$ curl https://162.22.184.144 -k
|
||||
...
|
||||
<title>Welcome to nginx!</title>
|
||||
```
|
||||
|
||||
The IP address in the `EXTERNAL_IP` column is the one that is available on the public internet. The `CLUSTER_IP` is only available inside your
|
||||
cluster/private cloud network.
|
||||
|
||||
## What's next?
|
||||
|
||||
[Learn about more Kubernetes features that will help you run containers reliably in production.](production-pods.md)
|
||||
|
@@ -209,16 +209,16 @@ walk-through - you can use your own `Service`'s details here.
|
||||
|
||||
```console
|
||||
$ kubectl expose rc hostnames --port=80 --target-port=9376
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
hostnames app=hostnames app=hostnames 80/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
hostnames 10.0.0.1 <none> 80/TCP run=hostnames 1h
|
||||
```
|
||||
|
||||
And read it back, just to be sure:
|
||||
|
||||
```console
|
||||
$ kubectl get svc hostnames
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
hostnames app=hostnames app=hostnames 10.0.1.175 80/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
hostnames 10.0.0.1 <none> 80/TCP run=hostnames 1h
|
||||
```
|
||||
|
||||
As before, this is the same as if you had started the `Service` with YAML:
|
||||
|
@@ -74,8 +74,6 @@ CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
||||
nginx-app nginx-app nginx run=nginx-app 1
|
||||
# expose a port through with a service
|
||||
$ kubectl expose rc nginx-app --port=80 --name=nginx-http
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
nginx-http run=nginx-app run=nginx-app 80/TCP
|
||||
```
|
||||
|
||||
With kubectl, we create a [replication controller](replication-controller.md) which will make sure that N pods are running nginx (where N is the number of replicas stated in the spec, which defaults to 1). We also create a [service](services.md) with a selector that matches the replication controller's selector. See the [Quick start](quick-start.md) for more information.
|
||||
|
@@ -107,9 +107,9 @@ mypod 1/1 Running 0 1h
|
||||
|
||||
$ kubectl create -f docs/user-guide/persistent-volumes/simpletest/service.json
|
||||
$ kubectl get services
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
frontendservice <none> name=frontendhttp 10.0.0.241 3000/TCP
|
||||
kubernetes component=apiserver,provider=kubernetes <none> 10.0.0.2 443/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
frontendservice 10.0.0.241 <none> 3000/TCP name=frontendhttp 1d
|
||||
kubernetes 10.0.0.2 <none> 443/TCP <none> 2d
|
||||
```
|
||||
|
||||
## Next steps
|
||||
|
@@ -76,17 +76,20 @@ Through integration with some cloud providers (for example Google Compute Engine
|
||||
|
||||
```console
|
||||
$ kubectl expose rc my-nginx --port=80 --type=LoadBalancer
|
||||
NAME LABELS SELECTOR IP(S) PORT(S)
|
||||
my-nginx run=my-nginx run=my-nginx 80/TCP
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
my-nginx 10.179.240.1 <none> 80/TCP run=nginx 8d
|
||||
```
|
||||
|
||||
To find the public IP address assigned to your application, execute:
|
||||
|
||||
```console
|
||||
$ kubectl get svc my-nginx -o json | grep \"ip\"
|
||||
"ip": "130.111.122.213"
|
||||
$ kubectl get svc my-nginx
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
|
||||
my-nginx 10.179.240.1 25.1.2.3 80/TCP run=nginx 8d
|
||||
```
|
||||
|
||||
You may need to wait for a minute or two for the external ip address to be provisioned.
|
||||
|
||||
In order to access your nginx landing page, you also have to make sure that traffic from external IPs is allowed. Do this by opening a [firewall to allow traffic on port 80](services-firewalls.md).
|
||||
|
||||
## Killing the application
|
||||
|
Reference in New Issue
Block a user