Logical Microsoft SQL Server Backup
MS SQL Server is a relational database developed by Microsoft. The example below covers SQL Server instances running natively on Kubernetes. Use the following commands to deploy the SQL Server using Kubernetes manifests.
$ kubectl create ns sqlserver
$ kubectl create secret generic mssql --from-literal=SA_PASSWORD="MyC0m9l&xP@ssw0rd" -n sqlserver
$ cat <<EOF | kubectl create -f -
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data
namespace: sqlserver
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
EOF
$ cat <<EOF | kubectl create -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: mssql-deployment
namespace: sqlserver
labels:
app: mssql
spec:
replicas: 1
selector:
matchLabels:
app: mssql
template:
metadata:
labels:
app: mssql
spec:
terminationGracePeriodSeconds: 30
hostname: mssqlinst
securityContext:
fsGroup: 10001
containers:
- name: mssql
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- containerPort: 1433
env:
- name: MSSQL_PID
value: "Developer"
- name: ACCEPT_EULA
value: "Y"
- name: SA_PASSWORD
valueFrom:
secretKeyRef:
name: mssql
key: SA_PASSWORD
volumeMounts:
- name: mssqldb
mountPath: /var/opt/mssql
volumes:
- name: mssqldb
persistentVolumeClaim:
claimName: mssql-data
EOF
$ cat <<EOF | kubectl create -f -
apiVersion: v1
kind: Service
metadata:
name: mssql-deployment
namespace: sqlserver
spec:
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
type: ClusterIP
EOF
The following command can be used to create the MS SQL Server Blueprint in the K10 namespace.
$ kubectl --namespace kasten-io apply -f \
https://raw.githubusercontent.com/kanisterio/kanister/0.107.0/examples/mssql/blueprint-v2/mssql-blueprint.yaml
Note
The provided Microsoft SQL Server backup example serves as a blueprint template for logical backups on Kubernetes. Please note that these examples may need to be modified for specific production environments and setups. As a result, it is highly recommended to carefully review and modify the blueprints as needed before deploying them for production use.
Alternatively, use the Blueprints page on K10 Dashboard to create the Blueprint resource.
Once the Blueprint is created, add an annotation to the SQL Server Deployment to instruct K10 to use the Blueprint when performing operations on this instance.
$ kubectl annotate deployment mssql-deployment \
kanister.kasten.io/blueprint='mssql-blueprint' --namespace sqlserver
Finally, use K10 to backup and restore the application.
Known Limitations
Currently, the backup process in the Kanister Blueprint creates the temporary database backup files in the same volume as the database. Due to this, it is necessary to use a PVC at least twice the size of the database.