问题:

如果 k8s 内的 pod 未通过 service 暴露,本地如何访问

 

解决:

可以通过 kubectl port-forward 方式把 pod/deploy/service 的端口暴露到本地,然后通过 http://localhost:**** 访问

如: kubectl port-forward deployment/nginx 8080:80 ,则可以通过 http://localhost:8080 访问 k8s 内 deployment nginx 80 端口

 

参考:

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#port-forward

 

发表评论

电子邮件地址不会被公开。