Azure Arc-Enbaled SQL Server instance with AKS

本文最后更新于:2024年8月9日 晚上

Azure data controller Setup

https://docs.microsoft.com/en-us/azure/azure-arc/data/create-data-controller-direct-cli?tabs=windows

create resources group

1
az group create --name sqlarc --location eastus

create aks

1
2
az aks create --resource-group sqlarc --name aks --node-count 3 --node-vm-size Standard_D8_v3 --enable-addons monitoring --generate-ssh-keys

Get azure aks kubectl admin access

1
2
3
# we can get below info from azure portal when click connect to cluster
az account set --subscription 5f9c889d-272a-4028-ba75-575f6a1dfe3f
az aks get-credentials --resource-group sqlarc --name aks

check k8s context for current environment

1
2
3
kubectl cluster-info
kubectl config get-contexts
kubectl config current-context

check azure k8s namespace

1
2
3
4
5
6
kubectl.exe get ns
NAME STATUS AGE
default Active 19m
kube-node-lease Active 19m
kube-public Active 19m
kube-system Active 19m

Register providers for Azure Arc enabled Kubernetes

1
2
3
az provider register --namespace Microsoft.Kubernetes 
az provider register --namespace Microsoft.KubernetesConfiguration
az provider register --namespace Microsoft.ExtendedLocation

create arc enabled k8s

1
2
3
4
5
6
7
8
9
10
11
12
PS C:\Users\hubo>  az connectedk8s connect --name arck8s --resource-group sqlarc (This operation might take a while...)
PS C:\Users\hubo> az connectedk8s list --resource-group sqlarc -o table
Name Location ResourceGroup
------- ---------- ---------------
arc-aks eastasia sqlarc
PS C:\Users\hubo> kubectl.exe get ns
NAME STATUS AGE
azure-arc Active 22m
default Active 35m
kube-node-lease Active 35m
kube-public Active 35m
kube-system Active 35m

Create service principal and configure roles for metrics

1
2
3
4
5
6
7
PS C:\Users\hubo> az provider register -n Microsoft.AzureArcData --wait
PS C:\Users\hubo> az provider show -n Microsoft.AzureArcData -o table
Namespace RegistrationPolicy RegistrationState
---------------------- -------------------- -------------------
Microsoft.AzureArcData RegistrationRequired Registered
PS C:\Users\hubo> az ad sp create-for-rbac --name azure-arc-jasonoss --role Contributor --scopes /subscriptions/xxxxxxxxx-272a-4028-ba75-575f6a1dfe3f/resourceGroups/sqlarc
PS C:\Users\hubo> az role assignment create --assignee xxxxxxxxx-2344-4695-b7e3-a103c3ff88cd --role 'Monitoring Metrics Publisher' --scope /subscriptions/xxxxxxxxxx-272a-4028-ba75-575f6a1dfe3f/resourceGroups/sqlarc

Create an Arc enabled Kubernetes data services extension

1
PS C:\Users\hubo> az k8s-extension create --name azdata --extension-type microsoft.arcdataservices --cluster-type connectedClusters -c arc-aks -g sqlarc --scope cluster --release-namespace arc --config Microsoft.CustomLocation.ServiceAccount=sa-bootstrapper

Create Custom location

Create azure data controller

Create Azure SQL managed instance -Azure arc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
PS C:\Users\hubo> kubectl.exe get pod -n azarc
NAME READY STATUS RESTARTS AGE
bootstrapper-796c4c67db-2nz4j 1/1 Running 0 58m
control-z842f 2/2 Running 0 52m
controldb-0 2/2 Running 0 52m
logsdb-0 3/3 Running 0 49m
logsui-7k6q9 3/3 Running 0 46m
metricsdb-0 2/2 Running 0 49m
metricsdc-q6vxh 2/2 Running 0 49m
metricsdc-qszhd 2/2 Running 0 49m
metricsdc-rfzck 2/2 Running 0 49m
metricsui-4j2kl 2/2 Running 0 49m
sqlmi-0 4/4 Running 0 20m
sqlmi-ha-0 2/2 Running 0 21m
PS C:\Users\hubo> kubectl.exe get svc -n azarc | findstr.exe sqlmi-external-svc
sqlmi-external-svc LoadBalancer 10.0.240.58 20.124.137.158 1433:32221/TCP,5022:32017/TCP 22m
PS C:\Users\hubo> SQLCMD.EXE -S 20.124.137.158 -Uadmin
Password:
1> select @@version;
2> go
Microsoft Azure SQL Managed Instance - Azure Arc - 16.0.41.7337 (X64)
Apr 25 2022 15:12:13
Copyright (C) 2021 Microsoft Corporation
General Purpose (64-bit) on Linux (Ubuntu 20.04.4 LTS) <X64>

(1 rows affected)


Azure Arc-Enbaled SQL Server instance with AKS
https://git.msft.vip/2024/03/30-Azure-Arc-Enbaled-SQL-Server-instance-with-AKS/
作者
Jas0n0ss
发布于
2024年3月30日
更新于
2024年8月9日
许可协议