apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mssql-statefulset
  namespace: mssql
  labels:
    app: mssql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mssql
  serviceName: mssql-service
  template:
    metadata:
      labels:
        app: mssql
    spec:
      securityContext:
        runAsUser: 10001
        fsGroup: 10001
      containers:
        - name: mssql
          image: mcr.microsoft.com/mssql/server:2019-latest
          env:
            - name: ACCEPT_EULA
              value: "Y"
            - name: SA_PASSWORD
              value: "password"
          ports:
            - name: mssql
              containerPort: 1433
          volumeMounts:
            - name: mssql-pvc
              mountPath: /var/opt/mssql
      nodeSelector:
        kubernetes.io/os: linux
  volumeClaimTemplates:
    - metadata:
        name: mssql-pvc
      spec:
        accessModes:
          - ReadWriteOnce
        storageClassName: managed-premium-retained
        resources:
          requests:
            storage: 10Gi
