Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To set up SQL Server on a local Kubernetes cluster using Minikube with a volume stored on the local machine, follow these steps:

  1. Install Minikube on your local machine by following the instructions on the official website.

  2. Create a Kubernetes deployment YAML file for SQL Server, with specifications for the volume mount and local storage path. Here's an example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: sqlserver-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sqlserver
  template:
    metadata:
      labels:
        app: sqlserver
    spec:
      containers:
      - name: sqlserver
        image: mcr.microsoft.com/mssql/server
        resources:
          limits:
            cpu: "1"
            memory: 1Gi
        ports:
        - containerPort: 1433
        env:
        - name: MSSQL_SA_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mssql
              key: sa-password
        - name: ACCEPT_EULA
          value: Y
        volumeMounts:
        - name: data
          mountPath: /var/opt/mssql
      volumes:
      - name: data
        hostPath:
          path: /path/to/local/sqlserver/data
  1. Create a Kubernetes secret for the SQL Server SA password using the following command:
kubectl create secret generic mssql --from-literal=sa-password="<password>"

Replace <password> with the desired password.

  1. Apply the deployment YAML file using the following command:
kubectl apply -f sqlserver-deployment.yaml
  1. Verify that the deployment and pod are running using the following commands:
kubectl get deployment
kubectl get pods
  1. Connect to SQL Server running inside the pod using any SQL client or tool, specifying the pod IP address and SA credentials.

That's it! You now have SQL Server running on your local Kubernetes cluster with persistent storage provided by a volume mounted from your local machine.