您的位置:首页 > 其它

[k8s]pod调度-不完整版本-及dashboard原理

2017-08-15 10:38 651 查看
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/

deployment下发过程

可以通过查看event看到.



crontab

类似linux定时任务.

先决: crontab需要用到这个版的api,将下面的添加到api的配置

--runtime-config=batch/v2alpha1=true


创建crontab

apiVersion: batch/v2alpha1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure


kubectl create -f crontab.yml


也可以这样运行一个crontab

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:

$ kubectl get cronjob hello
NAME      SCHEDULE      SUSPEND   ACTIVE    LAST-SCHEDULE
hello     */1 * * * *   False     0         <none>


As you can see above, there’s no active job yet, and no job has been scheduled, either.

Watch for the job to be created in around one minute:

$ kubectl get jobs --watch
NAME               DESIRED   SUCCESSFUL   AGE
hello-4111706356   1         1         2s
Now you’ve seen one running job scheduled by “hello”. We can stop watching it and get the cron job again:
$ kubectl get cronjob hello
NAME      SCHEDULE      SUSPEND   ACTIVE    LAST-SCHEDULE
hello     */1 * * * *   False     0         Mon, 29 Aug 2016 14:34:00 -0700


You should see that “hello” successfully scheduled a job at the time specified in LAST-SCHEDULE. There are curre
4000
ntly 0 active jobs, meaning that the job that’s scheduled is completed or failed.

Now, find the pods created by the job last scheduled and view the standard output of one of the pods. Note that your job name and pod name would be different.

# Replace "hello-4111706356" with the job name in your system
$ pods=$(kubectl get pods --selector=job-name=hello-4111706356 --output=jsonpath={.items..metadata.name})

$ echo $pods
hello-4111706356-o9qcm

$ kubectl logs $pods
Mon Aug 29 21:34:09 UTC 2016
Hello from the Kubernetes cluster


删除crontab.

有个疑问,就是crontab没执行起来,

todo:

滚动升级

rc

demployment

pod调用

crontab job daemon staticpod这些特殊的pod

nodeselect

亲和度

还有个没太理解的问题就是dashboard, dashboard访问的是api的https接口?如果集群没配证书怎么搞?

这里懂了

dashboard的yml里有配置api地址的地方,这里架构选用单独一台nginx做vip即api地址.



关于trafix和dashboard的认证,这里指的是界面的认证.

参考:https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md

普通访问:

+-------------+   user             +-------------+   service          +-------------+
|             |   authentication   |             |   authentication   |             |
|  browser    +------------------->+  apiserver  +<-------------------+  dashboard  |
|             |                    |             |                    |             |
+-------------+                    +-------------+                    +-------------+


In the diagram below you can see the full authentication flow with all options, starting with the browser on the lower left hand side.

Workstation                                        Kubernetes
+------------------+                               +----------------------------------------------------+
|                  |                               |                                                    |
|                  |                               |                                                    |
|  +------------+  |                               |  +------------+   apiserver        +------------+  |
|  |            |  |  authentication with kubectl  |  |            |   proxy            |            |  |
|  | kubectl    +------------------------------------>+ apiserver  +------------------->+ dashboard  |  |
|  | proxy      |  |                               |  |            |                    |            |  |
|  |            |  |                               |  |            |                    |            |  |
|  +--------+---+  |                               |  |            |                    |            |  |
|           ^      |                          +------>+            |  service account/  |            |  |
|  localhost|      |                          |    |  |            |  kubeconfig        |            |  |
|           |      |                          |    |  |            +<-------------------+            |  |
|  +--------+---+  |                          |    |  |            |                    |            |  |
|  |            |  |      direct access       |    |  +------------+                    +------+-----+  |
|  | browser    +-----------------------------+    |                                           |        |
|  |            |  |                               |                                           |        |
|  |            +----------------------------------------------------------------------------->O        |
|  +------------+  |      bypass apiserver         |                                        NodePort    |
|                  |                               |                                                    |
|                  |                               |                                                    |
+------------------+                               +----------------------------------------------------+
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: