前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >17 Dec 2021 cka练习(十)

17 Dec 2021 cka练习(十)

作者头像
俊采
发布2023-10-17 10:35:06
1190
发布2023-10-17 10:35:06
举报
文章被收录于专栏:LEo的网络日志LEo的网络日志
代码语言:javascript
复制
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: liveness
    image: quay.io/prometheus/busybox:latest
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 10; rm -rf /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 10
      periodSeconds: 5
EOF
$ kgp
NAME            READY   STATUS    RESTARTS   AGE
liveness-exec   1/1     Running   1          58s
$ k exec liveness-exec -- ls /tmp
healthy
$ k exec liveness-exec -- rm -rf /tmp/healthy
$ k exec liveness-exec -- ls /tmp
$ kdp
Name:         liveness-exec
Namespace:    ch10
Priority:     0
Node:         kind-control-plane/172.18.0.2
Start Time:   Thu, 16 Dec 2021 12:22:52 +0800
Labels:       test=liveness
Annotations:  <none>
Status:       Running
IP:           10.244.0.51
IPs:
  IP:  10.244.0.51
Containers:
  liveness:
    Container ID:  containerd://d275c56d54591f8252c28a306c303f02272a4dd65ada00d3eb79a794ba540bcc
    Image:         quay.io/prometheus/busybox:latest
    Image ID:      quay.io/prometheus/busybox@sha256:2548dd93c438f7cf8b68dc2ff140189d9bcdae7130d3941524becc31573ec9e3
    Port:          <none>
    Host Port:     <none>
    Args:
      /bin/sh
      -c
      touch /tmp/healthy; sleep 10; rm -rf /tmp/healthy; sleep 600
    State:          Running
      Started:      Thu, 16 Dec 2021 12:23:47 +0800
    Last State:     Terminated
      Reason:       Error
      Exit Code:    137
      Started:      Thu, 16 Dec 2021 12:22:52 +0800
      Finished:     Thu, 16 Dec 2021 12:23:47 +0800
    Ready:          True
    Restart Count:  1
    Liveness:       exec [cat /tmp/healthy] delay=10s timeout=1s period=5s #success=1 #failure=3
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-vv9gz (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  default-token-vv9gz:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-vv9gz
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  62s                default-scheduler  Successfully assigned ch10/liveness-exec to kind-control-plane
  Normal   Pulled     62s                kubelet            Successfully pulled image "quay.io/prometheus/busybox:latest" in 112.409367ms
  Warning  Unhealthy  37s (x3 over 47s)  kubelet            Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory
  Normal   Killing    37s                kubelet            Container liveness failed liveness probe, will be restarted
  Normal   Pulling    7s (x2 over 62s)   kubelet            Pulling image "quay.io/prometheus/busybox:latest"
  Normal   Created    7s (x2 over 62s)   kubelet            Created container liveness
  Normal   Started    7s (x2 over 62s)   kubelet            Started container liveness
  Normal   Pulled     7s                 kubelet            Successfully pulled image "quay.io/prometheus/busybox:latest" in 126.868686ms

参考

  • cka/ckad应试指南:从docker到kubernetes完全攻略 ch-10

LEo at 00:12

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 参考
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档