AppGateway(AGIC)notpointingtoserviceinsteadpointingtopodsintheAKS
创始人
2024-09-10 07:01:01
0

App Gateway(AGIC)应该指向Kubernetes Service而不是Pod。解决方法是,在Kubernetes环境中创建一个Service并将它绑定到App gateway上。具体实现可参考以下代码示例:

  1. 部署一个示例应用程序
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sample-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: sample-app
  template:
    metadata:
      labels:
        app: sample-app
    spec:
      containers:
      - name: sample-app
        image: mcr.microsoft.com/oss/nginx/nginx:1.17.9-alpine
        ports:
        - containerPort: 80
  1. 创建一个Service
apiVersion: v1
kind: Service
metadata:
  name: sample-app-service
spec:
  selector:
    app: sample-app
  ports:
    - name: http
      port: 80
      targetPort: 80
  1. 配置App Gateway

创建一个App Gateway,将它配置为使用已创建的sample-app-service。以下是App Gateway配置文件的示例:

{
  "type": "Microsoft.Network/applicationGateways",
  "name": "myAppGateway",
  "location": "[resourceGroup().location]",
  "properties": {
      "sku": {
        "name": "WAF_Medium",
        "tier": "WAF",
        "capacity": 2
      },
      "gatewayIPConfigurations": [
        {
          "name": "myAppGatewayIpConfig",
          "properties": {
            "subnet": {
              "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
            }
          }
        }
      ],
      "frontendIPConfigurations": [
        {
          "name": "myFrontendIp",
          "properties": {
            "privateIPAllocationMethod": "Dynamic",
            "subnet": {
              "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
            }
          }
        }
      ],
      "frontendPorts": [
        {
          "name": "myFrontendHttpPort",
          "properties": {
            "Port": 80
          }
        }
      ],
      "backendAddressPools": [
        {
          "name": "myBackendAddressPool",
          "properties": {
            "BackendAddresses": [
              {
                "fqdn": "[concat('sample-app-service.default.svc.cluster.local:', '80')]"
              }
            ]
          }
        }
      ],
      "backendHttpSettingsCollection": [
        {
          "name": "myBackendHttpSettings",
          "properties": {
            "Port": 80,
            "Protocol": "Http",
            "CookieBasedAffinity": "Disabled"
          }
        }
      ],
      "httpListeners": [
        {
          "name": "myHttpListener",
          "properties": {
            "FrontendIPConfiguration": {
              "id": "[concat(resourceGroupId('Microsoft.Network/applicationGateways'), '/frontendIPConfigurations/', 'myFrontendIp')]"
            },
            "FrontendPort": {
              "id": "[concat(resourceGroupId('Microsoft.Network/applicationGateways'), '/frontendPorts/', 'myFrontendHttpPort')]"
            },
            "Protocol": "Http",
            "SslCertificate

相关内容

热门资讯

必看攻略!随意玩游戏平台官方挂... 必看攻略!随意玩游戏平台官方挂开挂,吉祥填大坑机制原理,详细器(揭秘有挂)1、全新机制【随意玩游戏平...
于此同时!wepoker私人局... 于此同时!wepoker私人局有透视吗,德扑之星透视软件免费入口官网,总是确实有挂(有挂功能)1、这...
揭秘几款!腾微填大坑辅助,天天... 揭秘几款!腾微填大坑辅助,天天贵阳辅助工具,详细挂(有挂方略)所有人都在同一条线上,像星星一样排成一...
今年以来!德州圈脚本,智星菠萝... 今年以来!德州圈脚本,智星菠萝可以辅助吗,原来真的有挂(今日头条)1、智星菠萝可以辅助吗辅助器安装包...
总算了解!悟空大厅辅助器,广东... 总算了解!悟空大厅辅助器,广东闲来辅助神器,详细工具(有挂秘诀)1、这是跨平台的广东闲来辅助神器轻量...
有玩家发现!aapoker怎么... 有玩家发现!aapoker怎么拿好牌,德普之星透视,其实真的是有挂(果真有挂)1、德普之星透视模拟器...
玩家必看秘籍!聚友联盟辅助器,... 玩家必看秘籍!聚友联盟辅助器,雀神麻雀充运势用吗,详细脚本(新版有挂)雀神麻雀充运势用吗脚本下载中分...
截至目前!wejoker辅助脚... 截至目前!wejoker辅助脚本,德普之星透视辅助软件,切实确实有挂(真实有挂)一、德普之星透视辅助...
程序员教你!欢乐卡五星插件,微... 程序员教你!欢乐卡五星插件,微信新海贝之城辅助,详细方法(竟然有挂)1、点击下载安装,微信新海贝之城...
有了最新消息!we-poker... 有了最新消息!we-poker正规吗,德扑之星辅助器,果然确实有挂(有挂猫腻)1、完成德扑之星辅助器...