Share this page

# Sample YAML files for Kubernetes

This topic contains samples YAML files used with the Kubernetes integration.

In this topic:

## postgresdb.yaml

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: postgres-db-pvc1
      labels:
        app: sv-postgres-db1
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 4Gi
      storageClassName: manual
    ---
    kind: PersistentVolume
    apiVersion: v1
    metadata:
      name: postgres-db-pv
      labels:
        type: local
        app: sv-postges-db
    spec:
      storageClassName: manual
      capacity:
        storage: 4Gi
      accessModes:
        - ReadWriteOnce
      hostPath:
        path: "/mnt/data"
    ---
    apiVersion: apps/v1beta1
    kind: Deployment
    metadata:
      name: sv-postgres-db
      labels:
        app: sv-postgres-db
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            name: sv-postgres-db
        spec:
          securityContext:
            runAsUser: 0
          containers:
          - name: sv-postgres-db
            image: postgres
            env:
            - name: POSTGRES_PASSWORD
              value: "postgres"
            ports:
            - containerPort: 5432
            volumeMounts:
            - name: postgres-data
              mountPath: /var/lib/postgresql/data
              readOnly: false
          volumes:
          - name: postgres-data
            persistentVolumeClaim:
              claimName: postgres-db-pvc
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: sv-postgres-db-service
    spec:
      ports:
      - name: postgres-db-port
        port: 5432
        targetPort: 5432
      selector:
        name: sv-postgres-db
      type: LoadBalancer

Back to top

## sv-server.yaml

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: sv-work-pvc
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 100k
      storageClassName: manual
    ---
    kind: PersistentVolume
    apiVersion: v1
    metadata:
      name: sv-work-pv
      labels:
        type: local
    spec:
      storageClassName: manual
      capacity:
        storage: 100k
      accessModes:
        - ReadWriteOnce
      hostPath:
        path: "/mnt/sv/work"
    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: sv-logs-pvc
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 20M
      storageClassName: manual
    ---
    kind: PersistentVolume
    apiVersion: v1
    metadata:
      name: sv-logs-pv
      labels:
        type: local
    spec:
      storageClassName: manual
      capacity:
        storage: 20M
      accessModes:
        - ReadWriteOnce
      hostPath:
        path: "/mnt/sv/logs"
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: sv-server
      name: sv-server
    spec:
      replicas: 1
      strategy:
        rollingUpdate:
          maxUnavailable: 33%
          maxSurge: 100%
        type: RollingUpdate
      selector:
        matchLabels:
          app: sv-service
      template:
        metadata:
          labels:
            app: sv-service
        spec:
          securityContext:
            runAsUser: 0
          volumes:
          - name: sv-storage-work
            persistentVolumeClaim:
              claimName: sv-work-pvc
          - name: sv-storage-logs
            persistentVolumeClaim:
              claimName: sv-logs-pvc
          terminationGracePeriodSeconds: 120
          containers:
          - name: sv-server
            image: virtualization/sv-server:5.1.1
            tty: true
            lifecycle:
              preStop:
                exec:
                  command:
                    - /bin/bash
                    - -c
                    - pkill -15 -f dotnet; while kill -0 1; do sleep 5; done && rm /opt/microfocus/sv-server/work/lock
            command: ["/bin/bash","-c"]
    #                  wait until lock file exists or timeout
    #                  create lock file
    #                  if persistent configuration doesn't exist, move it to the persistent volume
    #                  link the original location to the persistent volume directory
    #                  start sv server
    #                  remove lock file
            args: ["i=0
                      && while [ \"$i\" -lt 60 -a -f /opt/microfocus/sv-server/work/lock ]; do  i=$((i+1)); sleep 1; done
                      && echo sv>/opt/microfocus/sv-server/work/lock
                      && /opt/microfocus/sv-server/bin/start-server.sh && rm /opt/microfocus/sv-server/work/lock"]
            resources:
              requests:
                cpu: 2
            env:
            - name: SV_LICENSE_SERVER_URL
              value: "https://autopass.example.com:5814"
            - name: MONO_TLS_PROVIDER
              value: "legacy"
            - name: SV_DB_TYPE
              value: "postgresql"
            - name: SV_DB_USERNAME
              value: "postgres"
            - name: SV_DB_PASSWORD
              value: "postgres"
            - name : SV_DB_DATASOURCE
              value: ";Host=sv-postgres-db-service;Database=postgres"
            - name: SV_SERVER_AGENT_PORTS
              value: "7000-7019"
            - name: SV_USER
              value: "demo"
            - name : SV_PASSWORD
              value: "changeit"
            - name : SV_GROUPS
              value: "SVM Users,SV Server Administrators"
            volumeMounts:
            - name: sv-storage-work
              mountPath: /opt/microfocus/sv-server/work
              readOnly: false
            - name: sv-storage-logs
              mountPath: /opt/microfocus/sv-server/logs
              readOnly: false
            imagePullSecrets:
            - name: regcred
            imagePullPolicy: Always
            ports:
            - containerPort: 6085
              name: https
            - containerPort: 7000
              name: service

    apiVersion: v1
    kind: Service
    metadata:
      name: sv-service
    spec:
      ports:
      - name: sv-mgmt
        port: 6085
        targetPort: 6085
      - name: sv-http-agent
        port: 7000
        targetPort: 7000
      selector:
        app: sv-service
      type: NodePort

Back to top

See also:

- Running the SV Server in Kubernetes
- Docker installations

https://admhelp.microfocus.com Service Virtualization 8942
Tips to improve your search results... Service Virtualization Help Center SV Help 5.4-5.4.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: