Code snippents shouldn't include the command prompt (#12779)
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
99e4d3bac6
commit
d3cca48e3f
@@ -50,21 +50,27 @@ This example cron job config `.spec` file prints the current time and a hello me
|
||||
Run the example cron job by downloading the example file and then running this command:
|
||||
|
||||
```shell
|
||||
$ kubectl create -f ./cronjob.yaml
|
||||
kubectl create -f ./cronjob.yaml
|
||||
```
|
||||
```
|
||||
cronjob "hello" created
|
||||
```
|
||||
|
||||
Alternatively, you can use `kubectl run` to create a cron job without writing a full config:
|
||||
|
||||
```shell
|
||||
$ kubectl run hello --schedule="*/1 * * * *" --restart=OnFailure --image=busybox -- /bin/sh -c "date; echo Hello from the Kubernetes cluster"
|
||||
kubectl run hello --schedule="*/1 * * * *" --restart=OnFailure --image=busybox -- /bin/sh -c "date; echo Hello from the Kubernetes cluster"
|
||||
```
|
||||
```
|
||||
cronjob "hello" created
|
||||
```
|
||||
|
||||
After creating the cron job, get its status using this command:
|
||||
|
||||
```shell
|
||||
$ kubectl get cronjob hello
|
||||
kubectl get cronjob hello
|
||||
```
|
||||
```
|
||||
NAME SCHEDULE SUSPEND ACTIVE LAST-SCHEDULE
|
||||
hello */1 * * * * False 0 <none>
|
||||
```
|
||||
@@ -73,7 +79,9 @@ As you can see from the results of the command, the cron job has not scheduled o
|
||||
Watch for the job to be created in around one minute:
|
||||
|
||||
```shell
|
||||
$ kubectl get jobs --watch
|
||||
kubectl get jobs --watch
|
||||
```
|
||||
```
|
||||
NAME DESIRED SUCCESSFUL AGE
|
||||
hello-4111706356 1 1 2s
|
||||
```
|
||||
@@ -82,7 +90,9 @@ Now you've seen one running job scheduled by the "hello" cron job.
|
||||
You can stop watching the job and view the cron job again to see that it scheduled the job:
|
||||
|
||||
```shell
|
||||
$ kubectl get cronjob hello
|
||||
kubectl get cronjob hello
|
||||
```
|
||||
```
|
||||
NAME SCHEDULE SUSPEND ACTIVE LAST-SCHEDULE
|
||||
hello */1 * * * * False 0 Mon, 29 Aug 2016 14:34:00 -0700
|
||||
```
|
||||
@@ -95,12 +105,18 @@ Note that the job name and pod name are different.
|
||||
|
||||
```shell
|
||||
# Replace "hello-4111706356" with the job name in your system
|
||||
$ pods=$(kubectl get pods --selector=job-name=hello-4111706356 --output=jsonpath={.items..metadata.name})
|
||||
pods=$(kubectl get pods --selector=job-name=hello-4111706356 --output=jsonpath={.items..metadata.name})
|
||||
|
||||
$ echo $pods
|
||||
echo $pods
|
||||
```
|
||||
```
|
||||
hello-4111706356-o9qcm
|
||||
```
|
||||
|
||||
$ kubectl logs $pods
|
||||
```shell
|
||||
kubectl logs $pods
|
||||
```
|
||||
```
|
||||
Mon Aug 29 21:34:09 UTC 2016
|
||||
Hello from the Kubernetes cluster
|
||||
```
|
||||
@@ -110,7 +126,9 @@ Hello from the Kubernetes cluster
|
||||
When you don't need a cron job any more, delete it with `kubectl delete cronjob`:
|
||||
|
||||
```shell
|
||||
$ kubectl delete cronjob hello
|
||||
kubectl delete cronjob hello
|
||||
```
|
||||
```
|
||||
cronjob "hello" deleted
|
||||
```
|
||||
|
||||
|
||||
@@ -46,9 +46,16 @@ cluster and reuse it for many jobs, as well as for long-running services.
|
||||
Start RabbitMQ as follows:
|
||||
|
||||
```shell
|
||||
$ kubectl create -f examples/celery-rabbitmq/rabbitmq-service.yaml
|
||||
kubectl create -f examples/celery-rabbitmq/rabbitmq-service.yaml
|
||||
```
|
||||
```
|
||||
service "rabbitmq-service" created
|
||||
$ kubectl create -f examples/celery-rabbitmq/rabbitmq-controller.yaml
|
||||
```
|
||||
|
||||
```shell
|
||||
kubectl create -f examples/celery-rabbitmq/rabbitmq-controller.yaml
|
||||
```
|
||||
```
|
||||
replicationcontroller "rabbitmq-controller" created
|
||||
```
|
||||
|
||||
@@ -64,7 +71,9 @@ First create a temporary interactive Pod.
|
||||
|
||||
```shell
|
||||
# Create a temporary interactive container
|
||||
$ kubectl run -i --tty temp --image ubuntu:18.04
|
||||
kubectl run -i --tty temp --image ubuntu:18.04
|
||||
```
|
||||
```
|
||||
Waiting for pod default/temp-loe07 to be running, status is Pending, pod ready: false
|
||||
... [ previous line repeats several times .. hit return when it stops ] ...
|
||||
```
|
||||
@@ -161,9 +170,11 @@ For our example, we will create the queue and fill it using the amqp command lin
|
||||
In practice, you might write a program to fill the queue using an amqp client library.
|
||||
|
||||
```shell
|
||||
$ /usr/bin/amqp-declare-queue --url=$BROKER_URL -q job1 -d
|
||||
/usr/bin/amqp-declare-queue --url=$BROKER_URL -q job1 -d
|
||||
job1
|
||||
$ for f in apple banana cherry date fig grape lemon melon
|
||||
```
|
||||
```shell
|
||||
for f in apple banana cherry date fig grape lemon melon
|
||||
do
|
||||
/usr/bin/amqp-publish --url=$BROKER_URL -r job1 -p -b $f
|
||||
done
|
||||
@@ -184,7 +195,7 @@ example program:
|
||||
Give the script execution permission:
|
||||
|
||||
```shell
|
||||
$ chmod +x worker.py
|
||||
chmod +x worker.py
|
||||
```
|
||||
|
||||
Now, build an image. If you are working in the source
|
||||
@@ -195,7 +206,7 @@ and [worker.py](/examples/application/job/rabbitmq/worker.py). In either case,
|
||||
build the image with this command:
|
||||
|
||||
```shell
|
||||
$ docker build -t job-wq-1 .
|
||||
docker build -t job-wq-1 .
|
||||
```
|
||||
|
||||
For the [Docker Hub](https://hub.docker.com/), tag your app image with
|
||||
@@ -240,7 +251,9 @@ kubectl create -f ./job.yaml
|
||||
Now wait a bit, then check on the job.
|
||||
|
||||
```shell
|
||||
$ kubectl describe jobs/job-wq-1
|
||||
kubectl describe jobs/job-wq-1
|
||||
```
|
||||
```
|
||||
Name: job-wq-1
|
||||
Namespace: default
|
||||
Selector: controller-uid=41d75705-92df-11e7-b85e-fa163ee3c11f
|
||||
|
||||
Reference in New Issue
Block a user