我已經用minikube創建了一個集群minikube start 應用了這個 yaml 清單:apiVersion: apps/v1kind: Deploymentmetadata: name: gateway-deploymentspec: selector: matchLabels: app: gateway replicas: 1 template: metadata: labels: app: gateway spec: containers: - name: gateway image: docker_gateway imagePullPolicy: Never ports: - containerPort: 4001 protocol: TCP---apiVersion: v1kind: Servicemetadata: name: gatewayspec: selector: app: gateway ports: - protocol: TCP port: 4001我的 GO 應用程序在容器中docker_gateway只是一個帶有一條路由的 gin http 服務器package mainimport "github.com/gin-gonic/gin"func main() { r := gin.Default() r.GET("/hello", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "hello", }) }) server = &http.Server{ Addr: ":4001", Handler: r, } server.ListenAndServe()}在 Postman 中,我向 192.168.252.130:4001/hello 發出請求并獲得響應但 Kubernetes 中的 Kubernetes Pod 日志不會打印這些請求。我期望得到這個:[GIN] 2019/10/25 - 14:17:20 | 200 | 1.115μs | 192.168.252.1| GET /hello但有趣的是當我添加 Ingress 時apiVersion: networking.k8s.io/v1beta1kind: Ingressmetadata: name: ingressspec: backend: serviceName: gateway servicePort: 4001我能夠向 192.168.252.130/hello 和 192.168.252.130:4001/hello 發出請求,并且沒有端口 Pod 的日志打印請求,但使用端口 - 它們不會。[GIN] 2019/10/25 - 14:19:13 | 200 | 2.433μs | 192.168.252.1| GET /hello
添加回答
舉報
0/150
提交
取消