Skip to content

Example Kubernetes YAML

This example is connecting to a Microsoft SQL Server database, if you are connecting to a MySQL or MariaDB database, the correct connection.driver, connection.url, and hibernate.dialect must be used. All values wrapped by {} should be replaced for your environment.

apiVersion: apps/v1
kind: Deployment
metadata:
   name: qie
   labels:
      app: qie
spec:
   # number of replicated nodes in this cluster
   replicas: 2
   # when deploying a new image of QIE (upgrading the engine), then Recreate is REQUIRED
   # if updating a container with new ports listening, then RollingUpdate should be used
   # - Recreate = All pods are stopped and destroyed, then new pods are created (this causes down time)
   # - RollingUpdate = One pod is destroyed and replaced at a time until full cluster is updated (this has no down time)
   strategy:
      type: Recreate
   selector:
      matchLabels:
         app: qie
   template:
      metadata:
         name: qie
         # This label is used to match these pods with the service below
         labels:
            app: qie
      spec:
         # QIE can take up to 5 minutes to stop, so we need to let Kubernetes know to wait this long before destroying the container
         terminationGracePeriodSeconds: 300
         containers:
            - name: qie
              image: qvera/qie:latest
              # named port allows us to use it in the probes below
              ports:
                 - name: console-port
                   containerPort: 8081
                 - name: rec-20001
                   containerPort: 20001
                 - name: rec-20002
                   containerPort: 20002
                 - name: probe-port
                   containerPort: 8080
                 - name: rec-20003
                   containerPort: 20003
              # only pull the image from the repository if it does not exist in the local node repository (acceptable values: Always, IfNotPresent, Never)
              imagePullPolicy: IfNotPresent
              # environment variables are added as needed
              env:
                 - name: JETTY_PORT
                   value: "8081"
                 - name: JAVA_OPTIONS
                   value: "-Xmx3G -D{anotherOption}={value}"
                 - name: qie.haEngine
                   value: EnterpriseHAServiceImpl
                 - name: connection.driver
                   value: com.microsoft.sqlserver.jdbc.SQLServerDriver
                 - name: connection.url
                   value: jdbc:sqlserver://{host}:1433;databaseName={db_name}
                 - name: hibernate.dialect
                   value: com.qvera.qie.persistence.SQLServer2019UnicodeDialect
                 - name: qie.probePort
                   value: "8080"
                 - name: connection.username
                   value: "{databaseUsername}"
                 - name: connection.password
                   value: "{databasePassword}"
              # livenessProbe will allow kubernetes to detect if the JettyConsole stops, if it does, then it will replace this container
              livenessProbe:
                 httpGet:
                    path: /qieStatus
                    port: probe-port
                 failureThreshold: 3
                 periodSeconds: 10
              # startupProbe will prevent the livenessProbe from initiating until the service has started up completely, due to the Schema update, the default startup is 2 hours, but can be adjusted if needed
              startupProbe:
                 httpGet:
                    path: /qieStatus
                    port: probe-port
                 failureThreshold: 3600
                 periodSeconds: 2
              # readinessProbe will prevent kubernetes from placing the pod into service until the QIE application is fully initialized
              readinessProbe:
                 httpGet:
                    path: /qieStatus
                    port: probe-port
                 failureThreshold: 3600
                 periodSeconds: 2
         imagePullSecrets:
            - name: regcred
---
apiVersion: v1
kind: Service
metadata:
   name: qie-svc
   labels:
      app: qie
spec:
   type: LoadBalancer
   # This is the jettyPort for the console manager, any other ingress ports need to be listed here, and exposed in the docker image
   ports:
      - name: console-port
        port: 8081
        targetPort: 8081
      - name: rec-20001
        port: 20001
      - name: rec-20002
        port: 20002
   # This service will be run against any pods named qie
   selector:
      app: qie