Creating the YAML manifest files

You can create a deployment by defining a manifest file in the YAML format. The manifest file defines a cluster’s desired state, like which container images to run.

To create all the necessary pods, ingress, and services for running a PowerBuilder installable cloud app, you will need the following manifest files:

  • deployment-pscloudapp.yml: This file defines a deployment of the pod that runs the client app.

  • deployment-pswebapi.yml: This file defines a deployment of the pod that runs the PowerServer Web APIs.

  • ingress-pscloudapp-appeon.com.yml: This file defines an ingress that sends the HTTP/HTTPS requests of the client app to the service.

  • ingress-pswebapi-appeon.com.yml: This file defines an ingress that sends the HTTP/HTTPS requests of the PowerServer Web APIs to the service.

  • service-pscloudapp.yml: This file exposes the pod running the client app as a Kubernetes service.

  • service-pswebapi.yml: This file exposes the pod running the PowerServer Web APIs as a Kubernetes service.

  • secret-env-connectstrings.yml: This file defines a secret that contains the sensitive data, environment variables etc. that can be used by the deployments.

You can use Visual Studio Code or a text editor to create and edit the YAML file.

The following sample files only provide the minimal required settings; you can modify the files according to your needs. You can change the file name as you like but keep the file extension as yaml or yml.

Create a manifest file named deployment-pscloudapp.yml and copy in the following example YAML:

  • It defines a pod named deployment-pscloudapp.

  • The pod runs the container of the client app and it pulls the container image from the Azure container registry: pscloudapp.azurecr.io/powerservercloudapp:001.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-pscloudapp
spec:
  selector:
    matchLabels:
      app: pscloudapp
  template:
    metadata:
      labels:
        app: pscloudapp
    spec:
      containers:
      - name: pscloudapp
        image: pscloudapp.azurecr.io/powerservercloudapp:001
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 80

Create a manifest file named deployment-pswebapi.yml and copy in the following example YAML:

  • It defines a pod named deployment-pswebapi.

  • The pod runs the container for the PowerServer Web APIs and it pulls the container image from the Azure container registry: pscloudapp.azurecr.io/powerserverwebapi:001.

  • It uses the PowerServer license key and code from the secret secret-env-connectionstrings.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-pswebapi
spec:
  replicas: 3
  selector:
    matchLabels:
      app: pswebapi
  template:
    metadata:
      labels:
        app: pswebapi
    spec:
      containers:
      - name: pswebapi
        image: pscloudapp.azurecr.io/powerserverwebapi:001
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 9005
        env:
         - name: PowerServer__LicenseKey
           valueFrom:
             secretKeyRef:
               key: PowerServer__LicenseKey
               name: secret-env-connectionstrings
         - name: PowerServer__LicenseCode
           valueFrom:
             secretKeyRef:
               key: PowerServer__LicenseCode
               name: secret-env-connectionstrings

Create a manifest file named ingress-pscloudapp-appeon.com.yml and copy in the following example YAML:

  • It defines an ingress named ingress-pscloudapp-appeon.com and a list of rules that match against the incoming requests and route the requests to the service.

    In the following example, requests to the host pbexam.appeon.com is routed to the service named service-pscloudapp (listening on port 80).

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-pscloudapp-appeon.com
  labels:
    name: ingress-pscloudapp-appeon.com
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: pbexam.appeon.com
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: service-pscloudapp
            port: 
              number: 80

Create a manifest file named ingress-pswebapi-appeon.com.yml and copy in the following example YAML:

  • It defines an ingress named ingress-pswebapi-appeon.com and a list of rules that match against the incoming requests and route the requests to the service.

    In the following example, requests to the host demok8s.appeon.com is routed to the service named service-pswebapi (listening on port 9005).

  • The port number must be the same one used by the Web API URL (in this tutorial, 9005).

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-pswebapi-appeon.com
  labels:
    name: ingress-pswebapi-appeon.com
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: demok8s.appeon.com
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: service-pswebapi
            port: 
              number: 9005

Create a manifest file named service-pscloudapp.yml and copy in the following example YAML:

  • It exposes the pod running the client app as a service so that it can be accessible from the public internet.

apiVersion: v1
kind: Service
metadata:
  name: service-pscloudapp
spec:
  selector:
    app: pscloudapp
  ports:
  - port: 80
    targetPort: 80

Create a manifest file named service-pswebapi.yml and copy in the following example YAML:

  • It exposes the pod running the PowerServer Web APIs as a service so that it can be accessible from the public internet.

apiVersion: v1
kind: Service
metadata:
  name: service-pswebapi
spec:
  selector:
    app: pswebapi
  ports:
  - port: 9005
    targetPort: 9005

Create a manifest file named secret-env-connectstrings.yml and copy in the following example YAML:

  • It defines the environment variables for the PowerServer license key and code, which makes it possible for you to update the PowerServer license key and code whenever necessary.

apiVersion: v1
stringData:
  PowerServer__LicenseKey: $YOURLICENSEKEY
  PowerServer__LicenseCode: $YOURLICENSECODE
kind: Secret
metadata:
  name: secret-env-connectionstrings
  namespace: default
type: Opaque