0

我在 Hetzner 服务器上使用这个nginx 入口控制器。安装入口控制器后,我可以通过其 IP 访问工作节点,但无法访问集群内 pod 上运行的应用程序。我错过了什么吗?Ingress 和 Traefik 是否不同,在术语上有点混淆。

服务文件 -

apiVersion: v1
kind: Service
metadata:
  name: service-name-xxx
spec:
  selector:
    app: app-name
  ports:
    - protocol: 'TCP'
      port: 80
      targetPort: 4200
  type: LoadBalancer

部署文件 -

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-name
  labels:
    app: app-name
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-name
  template:
    metadata:
      labels:
        app: app-name
    spec:
      imagePullSecrets:
      - name: my-registry-key
      containers:
      - name: container-name
        image: my-private-docker-img
        imagePullPolicy: Always
        ports:
        - containerPort: 4200

入口文件 -

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-name
spec:
  rules:
  - host:
    http:
      paths:
      - pathType: Prefix
        path: "/app"
        backend:
          service:
            name: service-name-xxx
            port:
              number: 4200
4

2 回答 2

0

我认为您必须kubernetes.io/ingress.class: "nginx"Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-name
    spec:
      name: hsts-ingress-backend1-minion
      annotations:
        kubernetes.io/ingress.class: "nginx"
于 2021-07-17T13:07:36.110 回答
0

您已在服务中设置port为 80 和targetPort4200。应该在入口 yaml 中提及端口 80。

backend:
    service:
      name: service-name-xxx
      port: 80
      targetPort: 4200
于 2021-07-16T08:26:31.863 回答