如何检查部署日志?

时间:2019-05-30 13:14:29

标签: kubernetes

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

我使用了本教程: https://github.com/mkjelland/spring-boot-postgres-on-k8s-sample

但是当我这样做时

<asp:GridView ID="Gv"
  runat="server"     
  ShowFooter="true"
  OnLoad="Gv_Load">

因此它提供了大约30分钟的外部IP状态

所以我使用

对此进行了修补
 kubectl expose deployment spring-boot-postgres-sample --type=LoadBalancer -- 
  port=8080

因此,当我尝试访问http://172.31.71.218:8080时,超时。

我想查看日志在幕后发生的事情。

我还尝试通过使用Yaml文件使用群集IP服务

kubectl patch svc <svc-name> -n <namespace> -p '{"spec": {"type": "LoadBalancer", "externalIPs":["172.31.71.218"]}}'

使用以下命令:-

    apiVersion: v1
kind: Service
metadata:
  labels:
    app: spring-boot-postgres-sample
  name: spring-boot-postgres-sample
  namespace: default
spec:
  ports:
  - nodePort: 30500
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: spring-boot-postgres-sample
  type: NodePort

然后尝试访问   http://myhostip:30500/

但仍然超时 我该如何查看日志

这是 kubectl描述pod podname

的输出
kubectl create -f service.yaml

1 个答案:

答案 0 :(得分:0)

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

kubectl logs -f deployment/spring-boot-postgres-sample

或者如果您想要特定容器的日志

kubectl logs -f spring-boot-postgres-sample-7f7c7479d9-fclwb
相关问题