Kubernetes 如何检查部署日志?

Kubernetes 如何检查部署日志?,kubernetes,Kubernetes,我正在尝试部署一个使用postgres数据库的SpringBoot应用程序 我使用了本教程: 但是当我做这个命令的时候 kubectl expose deployment spring-boot-postgres-sample --type=LoadBalancer -- port=8080 因此,它会在30分钟左右提供外部IP状态 所以我用 kubectl patch svc <svc-name> -n <namespace> -p '{"spec": {"

我正在尝试部署一个使用postgres数据库的SpringBoot应用程序

我使用了本教程:

但是当我做这个命令的时候

 kubectl expose deployment spring-boot-postgres-sample --type=LoadBalancer -- 
  port=8080
因此,它会在30分钟左右提供外部IP状态

所以我用

kubectl patch svc <svc-name> -n <namespace> -p '{"spec": {"type": "LoadBalancer", "externalIPs":["172.31.71.218"]}}'
使用以下命令:-

kubectl create -f service.yaml
然后尝试访问

但还是有时间吗 如何查看日志

下面是kubectl description pod pod name的输出

    Name:               spring-boot-postgres-sample-7f7c7479d9-fclwb
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               ip-172-31-11-87/172.31.11.87
Start Time:         Thu, 30 May 2019 11:50:24 +0000
Labels:             app=spring-boot-postgres-sample
                    pod-template-hash=7f7c7479d9
Annotations:        <none>
Status:             Running
IP:                 192.168.1.28
Controlled By:      ReplicaSet/spring-boot-postgres-sample-7f7c7479d9
Containers:
  spring-boot-postgres-sample:
    Container ID:  docker://a1278cc26a66eb3b977cf1946d1490c7c5066e9fe0db8c468fd0e8dc47de5ca2
    Image:         djtijare/a2i-web:v1
    Image ID:      docker-pullable://djtijare/a2i-web@sha256:cbeac029eb3b65760b904e93ced0b417eca349280ba5a809de713d5fbb2d608f
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/bash
      -ce
      tail -f /dev/null
    State:          Running
      Started:      Thu, 30 May 2019 11:50:46 +0000
    Ready:          True
    Restart Count:  0
    Environment:
      POSTGRES_USER:      <set to the key 'postgres_user' of config map 'postgres-config'>      Optional: false
      POSTGRES_PASSWORD:  <set to the key 'postgres_password' of config map 'postgres-config'>  Optional: false
      POSTGRES_HOST:      <set to the key 'postgres_host' of config map 'hostname-config'>      Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-6pksq (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  default-token-6pksq:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-6pksq
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>
aquilak8suser@ip-172-31-6-149:~/a2i-web$ kubectl describe pod spring-boot-postgres-sample-7f7c7479d9-fclwb
Name:               spring-boot-postgres-sample-7f7c7479d9-fclwb
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               ip-172-31-11-87/172.31.11.87
Start Time:         Thu, 30 May 2019 11:50:24 +0000
Labels:             app=spring-boot-postgres-sample
                    pod-template-hash=7f7c7479d9
Annotations:        <none>
Status:             Running
IP:                 192.168.1.28
Controlled By:      ReplicaSet/spring-boot-postgres-sample-7f7c7479d9
Containers:
  spring-boot-postgres-sample:
    Container ID:  docker://a1278cc26a66eb3b977cf1946d1490c7c5066e9fe0db8c468fd0e8dc47de5ca2
    Image:         djtijare/a2i-web:v1
    Image ID:      docker-pullable://djtijare/a2i-web@sha256:cbeac029eb3b65760b904e93ced0b417eca349280ba5a809de713d5fbb2d608f
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/bash
      -ce
      tail -f /dev/null
    State:          Running
      Started:      Thu, 30 May 2019 11:50:46 +0000
    Ready:          True
    Restart Count:  0
    Environment:
      POSTGRES_USER:      <set to the key 'postgres_user' of config map 'postgres-config'>      Optional: false
      POSTGRES_PASSWORD:  <set to the key 'postgres_password' of config map 'postgres-config'>  Optional: false
      POSTGRES_HOST:      <set to the key 'postgres_host' of config map 'hostname-config'>      Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-6pksq (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  default-token-6pksq:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-6pksq
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>
Name:spring-boot-postgres-sample-7f7c7479d9-fclwb
名称空间:默认值
优先级:0
PriorityClassName:
节点:ip-172-31-11-87/172.31.11.87
开始时间:2019年5月30日星期四11:50:24+0000
标签:app=spring boot postgres示例
pod模板哈希=7f7c7479d9
注释:
状态:正在运行
IP:192.168.1.28
控制人:ReplicaSet/spring-boot-postgres-sample-7f7c7479d9
容器:
spring boot postgres示例:
容器ID:docker://a1278cc26a66eb3b977cf1946d1490c7c5066e9fe0db8c468fd0e8dc47de5ca2
图片:djtijare/a2i web:v1
图像ID:docker-pullable://djtijare/a2i-web@sha256:cbeac029eb3b65760b904e93ced0b417eca349280ba5a809de713d5fbb2d608f
端口:
主机端口:
命令:
/bin/bash
-行政长官
tail-f/dev/null
状态:正在运行
开始时间:2019年5月30日星期四11:50:46+0000
准备好了吗
重新启动计数:0
环境:
POSTGRES_用户:可选:false
POSTGRES_密码:可选:false
POSTGRES_主机:可选:false
挂载:
/来自default-token-6pksq(ro)的var/run/secrets/kubernetes.io/serviceCount
条件:
类型状态
初始化为True
准备好了吗
集装箱准备好了吗
播客预定为真
卷数:
default-token-6pksq:
类型:Secret(由Secret填充的卷)
SecretName:default-token-6pksq
可选:false
QoS等级:最佳努力
节点选择器:
容差:node.kubernetes.io/未就绪:不执行300秒
node.kubernetes.io/不可访问:不执行300秒
活动:
aquilak8suser@ip-172-31-6-149:~/a2i web$kubectl描述pod spring-boot-postgres-sample-7f7c7479d9-fclwb
名称:spring-boot-postgres-sample-7f7c7479d9-fclwb
名称空间:默认值
优先级:0
PriorityClassName:
节点:ip-172-31-11-87/172.31.11.87
开始时间:2019年5月30日星期四11:50:24+0000
标签:app=spring boot postgres示例
pod模板哈希=7f7c7479d9
注释:
状态:正在运行
IP:192.168.1.28
控制人:ReplicaSet/spring-boot-postgres-sample-7f7c7479d9
容器:
spring boot postgres示例:
容器ID:docker://a1278cc26a66eb3b977cf1946d1490c7c5066e9fe0db8c468fd0e8dc47de5ca2
图片:djtijare/a2i web:v1
图像ID:docker-pullable://djtijare/a2i-web@sha256:cbeac029eb3b65760b904e93ced0b417eca349280ba5a809de713d5fbb2d608f
端口:
主机端口:
命令:
/bin/bash
-行政长官
tail-f/dev/null
状态:正在运行
开始时间:2019年5月30日星期四11:50:46+0000
准备好了吗
重新启动计数:0
环境:
POSTGRES_用户:可选:false
POSTGRES_密码:可选:false
POSTGRES_主机:可选:false
挂载:
/来自default-token-6pksq(ro)的var/run/secrets/kubernetes.io/serviceCount
条件:
类型状态
初始化为True
准备好了吗
集装箱准备好了吗
播客预定为真
卷数:
default-token-6pksq:
类型:Secret(由Secret填充的卷)
SecretName:default-token-6pksq
可选:false
QoS等级:最佳努力
节点选择器:
容差:node.kubernetes.io/未就绪:不执行300秒
node.kubernetes.io/不可访问:不执行300秒
活动:

您可以使用以下命令获取部署日志

kubectl logs -f deployment/spring-boot-postgres-sample
或者,如果您需要特定pod的日志

kubectl logs -f spring-boot-postgres-sample-7f7c7479d9-fclwb

它没有打印任何内容,只是被卡住了。我不知道你在做什么,但是容器中的命令(取自你粘贴的descripe命令)是
tail-f/dev/null
。这就是为什么你看不到任何日志。我只是从某个网站复制了yaml。我是kubernets的新手。请给我一些在kubernetes上部署spring boot应用程序和postgres的链接。谷歌的第一个结果看起来很有希望
kubectl logs -f spring-boot-postgres-sample-7f7c7479d9-fclwb