How to Deploy a SQL Server Container in Alibaba Container Service Kubernetes

Prerequisites

Install a Kubernetes Cluster on Alibaba Cloud.

Connecting to Kubernetes Cluster

To manage the Kubernetes cluster, you need to connect to your cluster in using Cloud Shell CLI 2.0. It will help you execute “kubectl” command from local machine to “Kubernetes Services” which is hosted on Alibaba Cloud.

  1. These commands will not work in cloud shell and must be running on your local machine.
  2. If you are planning to access the Kubernetes cluster using Public IP then copy Internet Access Code.
  3. If you have a VPN setup for this cluster then you can use VPN Access
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install kubernetes-cli
kubectl version
echo $HOMEcd C:\mkdir C:\Kubelet\ .kubecd C:\Kubelet\ .kubeNew-Item config -type file
kubectl cluster-info

Deploy a SQL Server Using Kubernetes Web UI Management Interface

You can configure a SQL Server instance on container using Kubernetes Service, with persistent storage for high availability (HA). The solution also provides high resilience. If the SQL Server instance fails, Kubernetes automatically re-creates it in a new pod. Kubernetes also provides resiliency against a node failure. In this demo we are going to deploy the resources though Kubernetes dashboard in Alibaba Cloud.

kubectl create secret generic mssql --from-literal=SA_PASSWORD="Pass@123db"
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data
spec:
storageClassName: alicloud-disk-ssd #Change the Storage Class value
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mssql-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: mssql
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mssql
image: microsoft/mssql-server-linux
ports:
- containerPort: 1433
env:
- name: ACCEPT_EULA
value: "Y"
- name: SA_PASSWORD
valueFrom:
secretKeyRef:
name: mssql
key: SA_PASSWORD
volumeMounts:
- name: mssql-data
mountPath: /var/opt/mssql
volumes:
- name: mssql-data
persistentVolumeClaim:
claimName: mssql-data
---
apiVersion: v1
kind: Service
metadata:
name: mssql-deployment
spec:
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
type: LoadBalancer

References:

Original Source

https://www.alibabacloud.com/blog/how-to-deploy-a-sql-server-container-in-alibaba-container-service-kubernetes_594949?spm=a2c41.13076641.0.0

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com