az storage account create \
    --name <your-storage-account-name> \
    --resource-group <your-resource-group-name> \
    --location <location> \
    --sku Standard_LRS

az storage share create \
    --name <your-fileshare-name> \
    --account-name <your-storage-account-name> \
    --account-key $(az storage account keys list --resource-group <your-resource-group-name> --account-name <your-storage-account-name> --query "[0].value" --output tsv)

kubectl create secret generic azure-secret \
    --from-literal=azurestorageaccountname=<your-storage-account-name> \
    --from-literal=azurestorageaccountkey=$(az storage account keys list --resource-group <your-resource-group-name> --account-name <your-storage-account-name> --query "[0].value" --output tsv)

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurefile-csi
provisioner: file.csi.azure.com
parameters:
  skuName: Standard_LRS
  secretName: azure-secret           # Reference to the secret created
  secretNamespace: default           # Namespace where the secret is created
  shareName: <your-fileshare-name>   # Specify the file share name explicitly
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000
reclaimPolicy: Retain
volumeBindingMode: Immediate
allowVolumeExpansion: true

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mssql-statefulset
spec:
  serviceName: "mssql-service"
  replicas: 1
  selector:
    matchLabels:
      app: mssql
  template:
    metadata:
      labels:
        app: mssql
    spec:
      containers:
      - name: mssql
        # Linux-based MSSQL Server image
        image: mcr.microsoft.com/mssql/server:2019-latest
        ports:
        - containerPort: 1433
          name: mssql
        env:
        - name: ACCEPT_EULA
          value: "Y"
        - name: SA_PASSWORD
          value: "password@123"  # Replace with your own strong password
        volumeMounts:
        - name: mssql-data
          mountPath: /var/opt/mssql
      tolerations:
      - key: "kubernetes.azure.com/scalesetpriority"
        operator: "Equal"
        value: "spot"
        effect: "NoSchedule"
  volumeClaimTemplates:
  - metadata:
      name: mssql-data
    spec:
      accessModes: ["ReadWriteMany"]
      storageClassName: "azurefile-csi"
      resources:
        requests:
          storage: 20Gi


No comments:

Post a Comment