Skip to main content

How do I use Wayfinder to deploy a cloud database solution (like MS SQL)?

Prerequisites


Workflow

MS-SQL in Kubernetes, provides a way of running MS-SQL services in your existing Kubernetes clusters, keeping costs low. We advise running MS-SQL Cloud Service for any production workloads to reduce operational overheads and to leverage the clouds scale, reliability and performance.

In this example, we'll use Wayfinder to deploy the MS SQL container component for which the Kubernetes manifests already exist. The steps include:

Process Diagram


Create:

  1. Kubernetes Secret: Store the credentials as a secret to access the MS SQL instance.
  2. Wayfinder Container Component: Reference existing MS SQL Kubernetes manifests in Wayfinder.

Apply:

  1. Apply the updated MS SQL Kubernetes manifests


Instructions

Create


1. Secret for the MS SQL instance

  • See prerequisites section for creating an environment (cluster).

  • Log into Wayfinder's CLI

  • Use the wf access command to access the application environment (AppEnv). In the example below, your workspace is sand2 and your AppEnv (cluster) is demo1 (aks-zsnad):

wf access env app1 demo1
Waiting for access role binding to be ready.......
✔ Access to cluster aks-zsnad with role namespace.admin available until: 22 Jun 24 12:46 BST
Adding/updating active clusters in kubeconfig:
◉ sand2.aks-zsnad

✔ Imported 1 clusters to kubeconfig file: "/Users/test-user/.kube/config"

✔ Current kubectl context set to sand2.aks-zsnad


  • Create the secret using kubectl:
warning

Remember to create a secure password that follows your organisation's security requirements.

kubectl create secret generic mssql --from-literal=MSSQL_SA_PASSWORD="MyC0m9l&xP@ssw0rd"


2. Wayfinder Cloud Container Component

Inform Wayfinder about your existing MS SQL cloud container manifests so that Wayfinder can track them.

  • See prerequisites section for creating an application.

  • Use the wf create appcomponent COMPNAME --app APPNAME --type OwnManifests command to create a container component for which you have existing Kubernetes manifests:

wf create appcomponent mssql --app app1 --type OwnManifests
  • Wayfinder creates the following manifest:
apiVersion: app.appvia.io/v2beta1
kind: AppComponent
metadata:
labels:
appvia.io/app: app1
appvia.io/name: mssql
name: app1-mssql
namespace: ws-sand2
spec:
application: app1
container:
tls: true
key: mssql
name: mssql
type: OwnManifests
  • Include the following labels in your existing deployment manifests so that Wayfinder can track them:
app.kubernetes.io/name : app1
app.kubernetes.io/component : mssql

Wayfinder environments are deployed with the context of their Wayfinder-managed environments. You can access this context by referencing the wf-environment config map in your deployment manifests.

    spec:
containers:
- envFrom:
- configMapRef:
name: wf-environment


Apply


3. Apply the updated MS SQL Kubernetes manifests

  • Use wf access command to access your AppEnv (cluster):
wf access env app1 demo1
Waiting for access role binding to be ready.......
✔ Access to cluster aks-zsnad with role namespace.admin available until: 22 Jun 24 12:46 BST
Adding/updating active clusters in kubeconfig:
◉ sand2.aks-zsnad

✔ Imported 1 clusters to kubeconfig file: "/Users/test-user/.kube/config"

✔ Current kubectl context set to sand2.aks-zsnad

  • Apply the modified MS SQL Kubernetes manifests:
kubectl apply -f sql.yml

You have now successfully deployed your MS SQL container component in your cloud environment using Wayfinder.





Example(s)

Full deployment yaml (sql.yml)

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data
labels:
app.kubernetes.io/name: app1 <--- The name of your Wayfinder application
app.kubernetes.io/component: mssql <--- The name of your Wayfinder container component
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mssql-deployment
labels:
app.kubernetes.io/name: app1 <--- The name of your Wayfinder application
app.kubernetes.io/component: mssql <--- The name of your Wayfinder container component
spec:
replicas: 1
selector:
matchLabels:
app: mssql
template:
metadata:
labels:
app: mssql
spec:
terminationGracePeriodSeconds: 30
hostname: mssqlinst
securityContext:
fsGroup: 10001
containers:
- envFrom:
- configMapRef:
name: wf-environment <--- Add `wf-environment` context to your deployment yaml
- name: mssql
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- containerPort: 1433
env:
- name: MSSQL_PID
value: "Developer"
- name: ACCEPT_EULA
value: "Y"
- name: MSSQL_SA_PASSWORD <--- The secret details you've created in Step 1
valueFrom:
secretKeyRef:
name: mssql
key: MSSQL_SA_PASSWORD
volumeMounts:
- name: mssqldb
mountPath: /var/opt/mssql
volumes:
- name: mssqldb
persistentVolumeClaim:
claimName: mssql-data
---
apiVersion: v1
kind: Service
metadata:
name: mssql-deployment
labels:
app.kubernetes.io/name: app1 <--- The name of your Wayfinder application
app.kubernetes.io/component: mssql <--- The name of your Wayfinder container component
spec:
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
type: LoadBalancer