Rancher 2.7.0 创建ingress 访问问题求解

环境信息:
版本

  • RKE1
  • k8s版本 v1.24.13

节点 CPU 架构,操作系统和版本:

  • Linux host-10-9-24-62 3.10.0-1160.88.1.el7.x86_64
  • Linux host-10-9-24-72 3.10.0-1160.el7.x86_64
  • Linux host-10-9-24-75 3.10.0-1160.88.1.el7.x86_64

集群配置:

  • 集群 dev
  • master 10.9.24.62 Control Plane, Etcd
  • node01 10.9.24.72 Worker
  • node02 10.9.24.75 Worker

问题描述:

  • 配置域名 www.test.com 无法访问 my-nginx服务,域名 www.test.com 绑定的是 master机器
  • 域名这块是为了托敏,所以截图经过处理了显示www.test.com
  • 访问 www.test.com 显示如下
    image

配置截图



你在本地 hosts 或者 dns 服务器上做了 这个域名的映射了么?你可以 ping 试一下

本地可以访问的通 www.test.com(10.9.24.62)这台机器
image

我在自己的环境上测试了下,是没问题的,你可以比对下这些 rancher 的 yaml 看看是不是哪地方配置错了:

nginx-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: '1'
    field.cattle.io/publicEndpoints: >-
      [{"addresses":["13.232.138.116"],"port":80,"protocol":"HTTP","serviceName":"default:ksd-nginx","ingressName":"default:ksd-nginx-ingress","hostname":"www.test.com","path":"/","allNodes":false}]
  creationTimestamp: '2023-06-09T01:42:50Z'
  generation: 2
  labels:
    workload.user.cattle.io/workloadselector: apps.deployment-default-ksd-nginx
  managedFields:
    - apiVersion: apps/v1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            f:field.cattle.io/publicEndpoints: {}
          f:labels:
            .: {}
            f:workload.user.cattle.io/workloadselector: {}
        f:spec:
          f:progressDeadlineSeconds: {}
          f:replicas: {}
          f:revisionHistoryLimit: {}
          f:selector: {}
          f:strategy:
            f:rollingUpdate:
              .: {}
              f:maxSurge: {}
              f:maxUnavailable: {}
            f:type: {}
          f:template:
            f:metadata:
              f:labels:
                .: {}
                f:workload.user.cattle.io/workloadselector: {}
              f:namespace: {}
            f:spec:
              f:affinity: {}
              f:containers:
                k:{"name":"container-0"}:
                  .: {}
                  f:image: {}
                  f:imagePullPolicy: {}
                  f:name: {}
                  f:ports:
                    .: {}
                    k:{"containerPort":80,"protocol":"TCP"}:
                      .: {}
                      f:containerPort: {}
                      f:name: {}
                      f:protocol: {}
                  f:resources: {}
                  f:securityContext:
                    .: {}
                    f:allowPrivilegeEscalation: {}
                    f:privileged: {}
                    f:readOnlyRootFilesystem: {}
                    f:runAsNonRoot: {}
                  f:terminationMessagePath: {}
                  f:terminationMessagePolicy: {}
              f:dnsPolicy: {}
              f:restartPolicy: {}
              f:schedulerName: {}
              f:securityContext: {}
              f:terminationGracePeriodSeconds: {}
      manager: agent
      operation: Update
      time: '2023-06-09T01:44:25Z'
    - apiVersion: apps/v1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:deployment.kubernetes.io/revision: {}
        f:status:
          f:availableReplicas: {}
          f:conditions:
            .: {}
            k:{"type":"Available"}:
              .: {}
              f:lastTransitionTime: {}
              f:lastUpdateTime: {}
              f:message: {}
              f:reason: {}
              f:status: {}
              f:type: {}
            k:{"type":"Progressing"}:
              .: {}
              f:lastTransitionTime: {}
              f:lastUpdateTime: {}
              f:message: {}
              f:reason: {}
              f:status: {}
              f:type: {}
          f:observedGeneration: {}
          f:readyReplicas: {}
          f:replicas: {}
          f:updatedReplicas: {}
      manager: kube-controller-manager
      operation: Update
      subresource: status
      time: '2023-06-09T01:44:25Z'
  name: ksd-nginx
  namespace: default
  resourceVersion: '3081844'
  uid: a07d7c82-2876-4413-9e10-beb44d88bf34
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      workload.user.cattle.io/workloadselector: apps.deployment-default-ksd-nginx
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        workload.user.cattle.io/workloadselector: apps.deployment-default-ksd-nginx
      namespace: default
    spec:
      affinity: {}
      containers:
        - image: nginx
          imagePullPolicy: IfNotPresent
          name: container-0
          ports:
            - containerPort: 80
              name: ksd-nginx
              protocol: TCP
          resources: {}
          securityContext:
            allowPrivilegeEscalation: false
            privileged: false
            readOnlyRootFilesystem: false
            runAsNonRoot: false
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  conditions:
    - lastTransitionTime: '2023-06-09T01:43:01Z'
      lastUpdateTime: '2023-06-09T01:43:01Z'
      message: Deployment has minimum availability.
      reason: MinimumReplicasAvailable
      status: 'True'
      type: Available
    - lastTransitionTime: '2023-06-09T01:42:50Z'
      lastUpdateTime: '2023-06-09T01:43:01Z'
      message: ReplicaSet "ksd-nginx-58855f9858" has successfully progressed.
      reason: NewReplicaSetAvailable
      status: 'True'
      type: Progressing
  observedGeneration: 2
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

nginx-svc.yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    field.cattle.io/targetWorkloadIds: '["default/ksd-nginx"]'
    management.cattle.io/ui-managed: 'true'
  creationTimestamp: '2023-06-09T01:42:51Z'
  managedFields:
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:field.cattle.io/targetWorkloadIds: {}
            f:management.cattle.io/ui-managed: {}
          f:ownerReferences:
            .: {}
            k:{"uid":"a07d7c82-2876-4413-9e10-beb44d88bf34"}: {}
        f:spec:
          f:internalTrafficPolicy: {}
          f:ports:
            .: {}
            k:{"port":80,"protocol":"TCP"}:
              .: {}
              f:name: {}
              f:port: {}
              f:protocol: {}
              f:targetPort: {}
          f:selector: {}
          f:sessionAffinity: {}
          f:type: {}
      manager: agent
      operation: Update
      time: '2023-06-09T01:42:51Z'
  name: ksd-nginx
  namespace: default
  ownerReferences:
    - apiVersion: apps/v1
      controller: true
      kind: Deployment
      name: ksd-nginx
      uid: a07d7c82-2876-4413-9e10-beb44d88bf34
  resourceVersion: '3081021'
  uid: 82930af3-77be-4f51-b9b9-25a2b0550e0c
spec:
  clusterIP: 10.43.93.80
  clusterIPs:
    - 10.43.93.80
  internalTrafficPolicy: Cluster
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
  ports:
    - name: ksd-nginx
      port: 80
      protocol: TCP
      targetPort: 80
  selector:
    workload.user.cattle.io/workloadselector: apps.deployment-default-ksd-nginx
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

nginx-ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    field.cattle.io/publicEndpoints: >-
      [{"addresses":["13.232.138.116"],"port":80,"protocol":"HTTP","serviceName":"default:ksd-nginx","ingressName":"default:ksd-nginx-ingress","hostname":"www.test.com","path":"/","allNodes":false}]
  creationTimestamp: '2023-06-09T01:43:51Z'
  generation: 1
  managedFields:
    - apiVersion: networking.k8s.io/v1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:field.cattle.io/publicEndpoints: {}
        f:spec:
          f:rules: {}
      manager: agent
      operation: Update
      time: '2023-06-09T01:44:25Z'
    - apiVersion: networking.k8s.io/v1
      fieldsType: FieldsV1
      fieldsV1:
        f:status:
          f:loadBalancer:
            f:ingress: {}
      manager: nginx-ingress-controller
      operation: Update
      subresource: status
      time: '2023-06-09T01:44:25Z'
  name: ksd-nginx-ingress
  namespace: default
  resourceVersion: '3081845'
  uid: d71a9d77-7064-4f90-9a29-843ccd014f27
spec:
  rules:
    - host: www.test.com
      http:
        paths:
          - backend:
              service:
                name: ksd-nginx
                port:
                  number: 80
            path: /
            pathType: Prefix
status:
  loadBalancer:
    ingress:
      - ip: 13.232.138.116

非常感谢,我晚上检查一下 :+1: