Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Azure/Loadbalancer] Creating an internal load balancer on Azure Kubernetes Service (AKS).

Posted on May 13, 2025May 14, 2025 By nim No Comments on [Azure/Loadbalancer] Creating an internal load balancer on Azure Kubernetes Service (AKS).

Mình thực hiện apply service với IP internal.

https://learn.microsoft.com/en-us/azure/aks/internal-lb?tabs=set-service-annotations

apiVersion: v1
kind: Service
metadata:
 name: internal-app
 annotations:
   service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
 type: LoadBalancer
 ports:
 - port: 80
 selector:
   app: internal-app

Service đã được tạo nhưng external IP vẫn Pending:

root@work-space-u20:~/azure-cloud/aks_vnet# kubectl get service
NAME           TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
internal-app   LoadBalancer   172.17.188.247   <pending>     80:31732/TCP   32m
kubernetes     ClusterIP      172.17.0.1       <none>        443/TCP        17h

Nếu bạn thực hiện describe service thì thấy các lỗi dưới.

Events:
  Type     Reason                  Age                From                Message
  ----     ------                  ----               ----                -------
  Normal   EnsuringLoadBalancer    32s (x4 over 68s)  service-controller  Ensuring load balancer
  Warning  SyncLoadBalancerFailed  32s (x4 over 68s)  service-controller  Error syncing load balancer: failed to ensure load balancer: GET http://localhost:7788/subscriptions/7f8e5acb-a937-4163-80b1-f874c3a4d62c/resourceGroups/nimtechnology/providers/Microsoft.Network/virtualNetworks/elearning/subnets/elearning-subnet-1
--------------------------------------------------------------------------------
RESPONSE 403: 403 Forbidden
ERROR CODE: AuthorizationFailed
--------------------------------------------------------------------------------
{
  "error": {
    "code": "AuthorizationFailed",
    "message": "The client '67805159-f222-4ecc-9e21-9c87f067ed02' with object id '67805159-f222-4ecc-9e21-9c87f067ed02' does not have authorization to perform action 'Microsoft.Network/virtualNetworks/subnets/read' over scope '/subscriptions/7f8e5acb-a937-4163-80b1-f874c3a4d62c/resourceGroups/nimtechnology/providers/Microsoft.Network/virtualNetworks/elearning/subnets/elearning-subnet-1' or the scope is invalid. If access was recently granted, please refresh your credentials."
  }
}
--------------------------------------------------------------------------------
External Traffic Policy:  Cluster
Events:
  Type     Reason                  Age                From                Message
  ----     ------                  ----               ----                -------
  Normal   EnsuringLoadBalancer    14s (x3 over 29s)  service-controller  Ensuring load balancer
  Warning  SyncLoadBalancerFailed  14s (x3 over 29s)  service-controller  Error syncing load balancer: failed to ensure load balancer: GET http://localhost:7788/subscriptions/7f8e5acb-a937-4163-80b1-f874c3a4d62c/resourceGroups/nimtechnology/providers/Microsoft.Network/virtualNetworks/elearning/subnets/elearning-subnet-1
--------------------------------------------------------------------------------
RESPONSE 403: 403 Forbidden
ERROR CODE: AuthorizationFailed
--------------------------------------------------------------------------------
{
  "error": {
    "code": "AuthorizationFailed",
    "message": "The client '67805159-f222-4ecc-9e21-9c87f067ed02' with object id '67805159-f222-4ecc-9e21-9c87f067ed02' does not have authorization to perform action 'Microsoft.Network/virtualNetworks/subnets/read' over scope '/subscriptions/7f8e5acb-a937-4163-80b1-f874c3a4d62c/resourceGroups/nimtechnology/providers/Microsoft.Network/virtualNetworks/elearning/subnets/elearning-subnet-1' or the scope is invalid. If access was recently granted, please refresh your credentials."
  }
}

Để kiểm tra client ID này là của ai thì bạn có thể kiểm tra bằng lên bên dưới.

root@work-space-u20:~/azure-cloud/aks_vnet# az ad sp show --id 67805159-f222-4ecc-9e21-9c87f067ed02
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#servicePrincipals/$entity",
  "accountEnabled": true,
  "addIns": [],
  "alternativeNames": [
    "isExplicit=False",
    "/subscriptions/7f8e5acb-a937-4163-80b1-f874c3a4d62c/resourcegroups/nimtechnology/providers/Microsoft.ContainerService/managedClusters/terraform-aks-elearning-cluster"
  ],
  "appDescription": null,
  "appDisplayName": null,
  "appId": "a40551dc-b98d-40cf-8c6b-d9d19ef99aad",
  "appOwnerOrganizationId": null,
  "appRoleAssignmentRequired": false,
  "appRoles": [],
  "applicationTemplateId": null,
  "createdDateTime": "2025-05-12T10:20:35Z",
  "deletedDateTime": null,
  "description": null,
  "disabledByMicrosoftStatus": null,
  "displayName": "terraform-aks-elearning-cluster",
  "homepage": null,
  "id": "67805159-f222-4ecc-9e21-9c87f067ed02",
  "info": null,
  "keyCredentials": [],
  "loginUrl": null,
  "logoutUrl": null,
  "notes": null,
  "notificationEmailAddresses": [],
  "oauth2PermissionScopes": [],
  "passwordCredentials": [],
  "preferredSingleSignOnMode": null,
  "preferredTokenSigningKeyThumbprint": null,
  "replyUrls": [],
  "resourceSpecificApplicationPermissions": [],
  "samlSingleSignOnSettings": null,
  "servicePrincipalNames": [
    "a40551dc-b98d-40cf-8c6b-d9d19ef99aad",
    "https://identity.azure.net/6rPoKQaw+9ew40ibYojGX6XgWsclqyNuivczR9LfQ6g="
  ],
  "servicePrincipalType": "ManagedIdentity",
  "signInAudience": null,
  "tags": [],
  "tokenEncryptionKeyId": null,
  "verifiedPublisher": {
    "addedDateTime": null,
    "displayName": null,
    "verifiedPublisherId": null
  }
}

Đây là các subnet của mình

Mô hình hiện tại thì mình cấp Subnet cho các node pool của AKS:

Ở đây chúng ta cần tạo permission cho AKS được đọc vào Subnet:

# Assign the Network Contributor role to the AKS managed identity on each subnet

resource "azurerm_role_assignment" "aks_network_contributor" {
 principal_id         = azurerm_kubernetes_cluster.aks_cluster.identity[0].principal_id
 role_definition_name = "Network Contributor"
 scope                = <Subnet_ID>
}

Sau khi apply permission chúng ta thấy service đã lấy được IP của subnet đặt cho service loadbalancer

Azure Cloud

Post navigation

Previous Post: [Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’
Next Post: [Azure] Create or Provision Cache Azure for redis

More Related Articles

[Azure/Resource Group] Create Resource Group on azure cloud Azure Cloud
[Microsoft] How to disable Microsoft Entra multi-factor authentication MFA from an admin perspective Azure Cloud
[Service Endpoint] Explain the Service Endpoint in Azure VNet. Azure Cloud
[Azure] Insufficient regional vcpu quota left Azure Cloud
[vnet/Azure] VNet provisioning via Terraform. Azure Cloud
[Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’ Azure Cloud

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [WordPress] Hướng dấn gửi mail trên WordPress thông qua gmail. June 15, 2025
  • [Bitbucket] Git Clone/Pull/Push with Bitbucket through API Token. June 12, 2025
  • [Teamcity] How to transfer the value from pipeline A to pipeline B June 9, 2025
  • [Windows] Remove the process that consumes too much CPU. June 3, 2025
  • Deploying Web-Based File Managers: File Browser and KubeFileBrowser with Docker and Kubernetes June 3, 2025

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.