Connect ไปที่ AKS clusters อย่างไร หลังจาก Kubernetes v1.26 update [TH]
- swiftweb1
- 27 ก.ย. 2567
- ยาว 1 นาที
อัปเดตเมื่อ 1 ต.ค. 2567
เรียนรู้วิธีการใช้ Azure kubelogin ตัวใหม่ เพื่อ authenticate ไปที่ AKS clusters ผ่าน Azure AD
Kubernetes v1.26 เปลี่ยนวิธีการที่เรา connect ไปที่ Azure Kubernetes Service (AKS) clusters ของเรา
ด้วยการมาของ v1.26, Kubernetes ไม่มี gcp และ azure plugin ฝังมาที่ kubectl อย่างแต่ก่อนแล้ว
ตอนนี้ แต่ละ Cloud Provider ต้อง provide auth plugin ภายนอก เพื่อใช้ร่วมกับ kubectl
สิ่งแรกที่ต้องทำ คือ download และ install Azure CLI version ล่าสุด.ซึ่งเราสามารถ Download ได้จาก
หลังจากนั้นให้เปิด Powershell และ Run Command:
az login
เราจะถูกส่งไปยังหน้า Login และให้ทำการ Login
จากนั้น Run Command:
az account set --subscription <subscription-id>
เพื่อเลือก Subscription หลังจากนั้น Run Command:
az aks get-credentials --resource-group my-rg-name --name my-aks-cluster-name
เพื่อสร้าง kubeconfig ไฟล์โดยปกติ
จากนั้นให้เรา install Azure’s kubelogin เพื่อจัดการเรื่อง azure authentication ให้กับ kubectl
az aks install-cli
az aks install-cli จะ download และ install kubectl และ azure-kubelogin version ล่าสุดซึ่งจำเป็นต้องใช้ในการทำ authentication on AKS clusters ผ่าน Azure AD
⚠️หลังจาก installation, ให้ทำการปิด PowerShell และเปิดใหม่อีกครั้ง ไม่งั้น kubelogin จะมองไม่เห็นใน path
จากนั้นใช้ Kubelogin เพื่อ convert kubeconfig ของเรา ให้เป็น kubeconfig ตัวใหม่ ที่ต้องต่อกับ AD ผ่าน Kubelogin ด้วย Command นี้
kubelogin convert-kubeconfig
จากนั้นลองใช้งาน kubectl
kubectl get deployments --all-namespaces=true
เย้ เราสามารถต่อ Cluster ของเราได้แล้ว แล้วยังผ่าน Lens ได้อีกด้วยน้า
Comments