2

we are using Sitecore 10.1 MCS using Containers. We have requirement to create custom DB. In order to deploy this DB on SQL server, we have created a custom image containing a dacpac file. Below is the dockerfile snippet. Image is getting created correctly.

# escape=`

ARG BASE_IMAGE

FROM ${BASE_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY .\db\ .\db

ENTRYPOINT C:\DeployDatabases.ps1 -ResourcesDirectory C:\db -SqlServer $env:SQL_SERVER -SqlAdminUser $env:SQL_ADMIN_LOGIN -SqlAdminPassword $env:SQL_ADMIN_PASSWORD -SkipStartingServer; `

To deploy on K8S, we have created a new init job. However, Application pipeline is failing while executing this job (at "Wait - event management Mssql-init job" step ) i.e. Job is not running to completion.

mssql-init-event-management.yaml

apiVersion: batch/v1
kind: Job
metadata:
  name: mssql-init-event-managment
spec:
  template:
    spec:
      imagePullSecrets:
        - name: sitecore-docker-registry
      containers:
      - name: mssql-init-event-management
        image: "{{ docker_images.sitecore.mssql_init_event_management }}"
        env:
        - name: sitecore_admin_password
          valueFrom:
            secretKeyRef:
              name: sitecore-admin
              key: sitecore-adminpassword.txt
        - name: SQL_ADMIN_PASSWORD
          valueFrom:
            secretKeyRef:
              name: sitecore-database
              key: sitecore-databasepassword.txt
        - name: SQL_ADMIN_LOGIN
          valueFrom:
            secretKeyRef:
              name: sitecore-database
              key: sitecore-databaseusername.txt
        - name: SQL_SERVER
          valueFrom:
            secretKeyRef:
              name: sitecore-database
              key: sitecore-databaseservername.txt
        - name: SQL_ELASTIC_POOL_NAME
          valueFrom:
            secretKeyRef:
              name: sitecore-database
              key: sitecore-database-elastic-pool-name.txt
        - name: DATABASES_TO_DEPLOY
          value: Event
      restartPolicy: Never
  backoffLimit: 5

init.yaml

- name: Execute event management mssql-init jobs
  k8s:
    apply: true
    namespace: "{{ solution_id }}"
    state: present
    definition: "{{ lookup('template', 'mssql-init-event-management.yaml') }}"

- name: 'Wait - event management Mssql-init job'
  k8s_info:
    kind: Job
    name: mssql-init-event-managment
    namespace: "{{ solution_id }}"
  register: event_management_mssql_init_result
  until: (event_management_mssql_init_result.resources[0].status.conditions[0].type | default('')) == 'Complete'
  retries: 15
  delay: 60

- name: Get all event management Mssql completed pods
  k8s_info:
    kind: Pod
    namespace: "{{ solution_id }}"
    label_selectors:
      - job-name = mssql-init-event-managment
  no_log: true
  register: event-managment_mssql_pod_list

- name: Remove event management Mssql job's pods
  k8s:
    kind: Pod
    name: "{{ item.metadata.name }}"
    namespace: "{{ solution_id }}"
    state: absent
  no_log: true
  with_items: "{{ event-managment_mssql_pod_list.resources }}"

Pipeline is failing and Need help in checking if the followed steps are correct or not for the deployment.

1 Answer 1

0

Do you have any logs available from the init container? Not a lot of information to go on otherwise.

An alternative approach would be to create the images in advance with custom databases on, then simply add those as pods with out the need for init tasks.

Have a look at these.

Custom image from ldf/mdf: https://deanobrien.uk/how-to-create-mssql-image-with-custom-dbs-attached/

Custom image from bak files:

https://deanobrien.uk/how-to-create-mssql-image-with-custom-dbs-attached-using-bak-files/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.