从 AKS 私有集群通过 Internet 访问 Pod

问题描述

我有一个完全私有的 AKS 集群,我将它设置在一个私有 VNET 上,我通过 Azure Bastion 访问该 VNET 以运行 kubectl 命令。我还设置了一个 DevOps 管道,它使用自托管代理在私有集群上运行命令。我所有的豆荚和入口似乎都运行良好。但是,当我尝试使用主机名(通过映射公共 ip)访问我的入口时,我发现 404 未找到。根据我的公共集群设置进行验证时,我没有看到任何问题。有人可以解释一下为什么我无法访问似乎运行良好的 pod 吗?

此外,即使在虚拟网络上的虚拟机上,我似乎也无法访问入口的外部 IP。但我可以运行 kubectl 命令并访问 kubernetes 仪表板。

---
apiVersion: v1
kind: Service
Metadata:
  namespace: app-auth
  labels:
    environment: staging
  name: app-auth-staging # The name of the app
spec:
  type: ClusterIP
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: app-auth-staging
---
apiVersion: apps/v1
kind: Deployment
Metadata:
  name: app-auth-staging
  namespace: app-auth
  labels:
    app: app-auth-staging
    environment: staging # The environment being used
    app-role: api # The application type
    tier: backend # The tier that this app represents
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-auth-staging
  template:
    Metadata:
      labels:
        app: app-auth-staging
        environment: staging
        app-role: api
        tier: backend
      annotations:
        build: _{Tag}_
    spec:
      containers:
        - name: auth
          image: auth.azurecr.io/auth:_{Tag}_ # Note: Do not modify this field.
          imagePullPolicy: Always
          env:
            - name: ConnectionStrings__ZigzyAuth # Note: The appsettings value being replaced
              valueFrom:
                secretKeyRef:
                  name: connectionstrings
                  key: _{ConnectionString}_ # Note: This is an environmental variable,it is replaced accordingly in DevOps
          ports:
            - containerPort: 80
          readinessProbe:
            tcpsocket:
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            tcpsocket:
              port: 80
            initialDelaySeconds: 15
            periodSeconds: 20
          volumeMounts:
            - name: secrets-store-inline
              mountPath: "/mnt/secrets-store"
              readOnly: true
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeselectorTerms:
            - matchExpressions:
              - key: agentpool
                operator: In
                values:
                - general
      volumes:
        - name: secrets-store-inline
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: "aks-provider"
            nodePublishSecretRef:                       
              name: aks-prod-credstore
      imagePullSecrets:
        - name: aks-prod-acrps
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
Metadata:
  name: app-auth-staging-ingress-main # The name of the ingress,ex: app-auth-ingress-main
  namespace: app-auth
  labels:
    environment: staging
  annotations:
    kubernetes.io/ingress.class: Nginx
    # Nginx.ingress.kubernetes.io/enable-cors: "true"
    # Nginx.ingress.kubernetes.io/cors-allow-methods: "GET,POST,OPTIONS"
    # Nginx.ingress.kubernetes.io/cors-allow-origin: "https://admin.example.com"
    # Nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
spec:
  tls:
    - hosts:
      - stagingauth.app.com # Modify
      - frontend.21.72.207.63.nip.io 
      - aksstagingauth.app.com
      secretName: zigzypfxtls
  rules:
  - host: stagingauth.app.com
    http:
      paths:
      - backend:
          serviceName: zigzy-auth-staging # Modify
          servicePort: 80
        path: /
  - host: frontend.21.72.207.63.nip.io 
    http:
      paths:
      - backend:
          serviceName: app-auth-staging # Modify
          servicePort: 80
        path: /
  - host: aksstagingauth.app.com
    http:
      paths:
      - backend:
          serviceName: app-auth-staging # Modify
          servicePort: 80
        path: /

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...