mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #23348 from pwittrock/docs
Update docs to reflect `kubectl run` creates deployments by default i…
This commit is contained in:
commit
c47f74a470
@ -3,7 +3,7 @@
|
||||
|
||||
.SH NAME
|
||||
.PP
|
||||
kubectl expose \- Take a replication controller, service, or pod and expose it as a new Kubernetes Service
|
||||
kubectl expose \- Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
|
||||
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
@ -112,7 +112,7 @@ Operation | Syntax | Description
|
||||
`describe` | `kubectl describe (-f FILENAME | TYPE [NAME_PREFIX | /NAME | -l label]) [flags]` | Display the detailed state of one or more resources.
|
||||
`edit` | `kubectl edit (-f FILENAME | TYPE NAME | TYPE/NAME) [flags]` | Edit and update the definition of one or more resources on the server by using the default editor.
|
||||
`exec` | `kubectl exec POD [-c CONTAINER] [-i] [-t] [flags] [-- COMMAND [args...]]` | Execute a command against a container in a pod.
|
||||
`expose` | `kubectl expose (-f FILENAME | TYPE NAME | TYPE/NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [----external-ip=external-ip-of-service] [--type=type] [flags]` | Expose a replication controller, service, or pod as a new Kubernetes service.
|
||||
`expose` | `kubectl expose (-f FILENAME | TYPE NAME | TYPE/NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [----external-ip=external-ip-of-service] [--type=type] [flags]` | Expose a replication controller, service, deployment or pod as a new Kubernetes service.
|
||||
`get` | `kubectl get (-f FILENAME | TYPE [NAME | /NAME | -l label]) [--watch] [--sort-by=FIELD] [[-o | --output]=OUTPUT_FORMAT] [flags]` | List one or more resources.
|
||||
`label` | `kubectl label (-f FILENAME | TYPE NAME | TYPE/NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--overwrite] [--all] [--resource-version=version] [flags]` | Add or update the labels of one or more resources.
|
||||
`logs` | `kubectl logs POD [-c CONTAINER] [--follow] [flags]` | Print the logs for a container in a pod.
|
||||
|
@ -92,7 +92,7 @@ kubectl
|
||||
* [kubectl edit](kubectl_edit.md) - Edit a resource on the server
|
||||
* [kubectl exec](kubectl_exec.md) - Execute a command in a container.
|
||||
* [kubectl explain](kubectl_explain.md) - Documentation of resources.
|
||||
* [kubectl expose](kubectl_expose.md) - Take a replication controller, service, or pod and expose it as a new Kubernetes Service
|
||||
* [kubectl expose](kubectl_expose.md) - Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
|
||||
* [kubectl get](kubectl_get.md) - Display one or many resources
|
||||
* [kubectl label](kubectl_label.md) - Update the labels on a resource
|
||||
* [kubectl logs](kubectl_logs.md) - Print the logs for a container in a pod.
|
||||
|
@ -34,7 +34,7 @@ Documentation for other releases can be found at
|
||||
|
||||
## kubectl expose
|
||||
|
||||
Take a replication controller, service, or pod and expose it as a new Kubernetes Service
|
||||
Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
|
||||
|
||||
### Synopsis
|
||||
|
||||
|
@ -222,7 +222,7 @@ To remove all created resources, run the following:
|
||||
kubectl delete rc selenium-hub
|
||||
kubectl delete rc selenium-node-chrome
|
||||
kubectl delete rc selenium-node-firefox
|
||||
kubectl delete rc selenium-python
|
||||
kubectl delete deployment selenium-python
|
||||
kubectl delete svc selenium-hub
|
||||
kubectl delete svc selenium-hub-external
|
||||
```
|
||||
|
@ -42,7 +42,7 @@ to Kubernetes and running your first containers on the cluster.
|
||||
|
||||
From this point onwards, it is assumed that `kubectl` is on your path from one of the getting started guides.
|
||||
|
||||
The [`kubectl run`](../docs/user-guide/kubectl/kubectl_run.md) line below will create two [nginx](https://registry.hub.docker.com/_/nginx/) [pods](../docs/user-guide/pods.md) listening on port 80. It will also create a [replication controller](../docs/user-guide/replication-controller.md) named `my-nginx` to ensure that there are always two pods running.
|
||||
The [`kubectl run`](../docs/user-guide/kubectl/kubectl_run.md) line below will create two [nginx](https://registry.hub.docker.com/_/nginx/) [pods](../docs/user-guide/pods.md) listening on port 80. It will also create a [deployment](../docs/user-guide/deployments.md) named `my-nginx` to ensure that there are always two pods running.
|
||||
|
||||
```bash
|
||||
kubectl run my-nginx --image=nginx --replicas=2 --port=80
|
||||
@ -54,16 +54,10 @@ Once the pods are created, you can list them to see what is up and running:
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
You can also see the replication controller that was created:
|
||||
You can also see the deployment that was created:
|
||||
|
||||
```bash
|
||||
kubectl get rc
|
||||
```
|
||||
|
||||
To delete the two replicated containers, delete the replication controller:
|
||||
|
||||
```bash
|
||||
kubectl delete rc my-nginx
|
||||
kubectl get deployment
|
||||
```
|
||||
|
||||
### Exposing your pods to the internet.
|
||||
@ -72,7 +66,7 @@ On some platforms (for example Google Compute Engine) the kubectl command can in
|
||||
to do this run:
|
||||
|
||||
```bash
|
||||
kubectl expose rc my-nginx --port=80 --type=LoadBalancer
|
||||
kubectl expose deployment my-nginx --port=80 --type=LoadBalancer
|
||||
```
|
||||
|
||||
This should print the service that has been created, and map an external IP address to the service. Where to find this external IP address will depend on the environment you run in. For instance, for Google Compute Engine the external IP address is listed as part of the newly created service and can be retrieved by running
|
||||
@ -83,6 +77,14 @@ kubectl get services
|
||||
|
||||
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.
|
||||
|
||||
### Cleanup
|
||||
|
||||
To delete the two replicated containers, delete the deployment:
|
||||
|
||||
```bash
|
||||
kubectl delete deployment my-nginx
|
||||
```
|
||||
|
||||
### Next: Configuration files
|
||||
|
||||
Most people will eventually want to use declarative configuration files for creating/modifying their applications. A [simplified introduction](../docs/user-guide/deploying-applications.md)
|
||||
|
@ -73,7 +73,7 @@ func NewCmdExposeService(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]",
|
||||
Short: "Take a replication controller, service, or pod and expose it as a new Kubernetes Service",
|
||||
Short: "Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service",
|
||||
Long: expose_long,
|
||||
Example: expose_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
@ -48,15 +48,14 @@ Custom metrics in Prometheus format are exposed on "/metrics" endpoint.
|
||||
|
||||
###CURL example
|
||||
```console
|
||||
$ kubectl run resource-consumer --image=gcr.io/google_containers/resource_consumer:beta
|
||||
$ kubectl expose rc resource-consumer --create-external-load-balancer=true --port=8080 --target-port=8080
|
||||
$ kubectl run resource-consumer --image=gcr.io/google_containers/resource_consumer:beta --expose --service-overrides='{ "spec": { "type": "LoadBalancer" } }' --port 8080
|
||||
$ kubectl get services resource-consumer
|
||||
```
|
||||
|
||||
There are two IPs first one is internal, second one is the external load-balanced IP. Both serving port 8080. (Use second one)
|
||||
There are two IPs. The first one is internal, while the second one is the external load-balanced IP. Both serve port 8080. (Use second one)
|
||||
|
||||
```console
|
||||
$ curl --data "millicores=300&durationSec=600" http://104.197.103.250:8080/ConsumeCPU.
|
||||
$ curl --data "millicores=300&durationSec=600" http://<EXTERNAL-IP>:8080/ConsumeCPU
|
||||
```
|
||||
|
||||
300 millicores will be consumed for 600 seconds.
|
||||
|
Loading…
Reference in New Issue
Block a user