Ask Your Question
0

How can SQL Server be set up on local kubernetes with a volume stored on the local machine using Minikube?

asked 2021-06-20 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-07-16 06:00:00 +0000

david gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-20 11:00:00 +0000

Seen: 10 times

Last updated: Jul 16 '22