Orchestrating Telstar with Kubernetes

From Telstar Wiki
Revision as of 22:59, 2 April 2022 by John (talk | contribs) (Created page with "# Using Kubernetes __*** Please note TELSTAR as an application is still under development and subject to change. ***__ Telstar can be managed by Kubernetes if required and the following configuration files present an example of how this could be achieved using either Node ports or a cloud providers Load Balancers. ## Telstar Namspace { "apiVersion": "v1", "kind": "Namespace", "metadata": { "name": "telstar", "labels": {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. Using Kubernetes

__*** Please note TELSTAR as an application is still under development and subject to change. ***__

Telstar can be managed by Kubernetes if required and the following configuration files present an example of how this could be achieved using either Node ports or a cloud providers Load Balancers.

    1. Telstar Namspace
   {
     "apiVersion": "v1",
     "kind": "Namespace",
     "metadata": {
       "name": "telstar",
       "labels": {
         "name": "telstar"
       }
     }
   }
   
    1. Telstar Server
   apiVersion: v1
   kind: Service
   metadata:
     name: telstar-server
     namespace: telstar
     labels:
       app: telstar-server
   spec:
     type: NodePort
     ports:
     - port: 25232
       nodePort: 30000
       protocol: TCP
     selector:
       app: telstar-server
   #spec:
   #  type: LoadBalancer
   #  ports:
   #    - port: 6502
   #      name: load-balancer
   #  selector:
   #    app: telstar-server
   ---
   apiVersion: v1
   kind: PersistentVolumeClaim
   metadata:
     name: telstar-pvc
     namespace: telstar
   spec:
     accessModes:
     - ReadWriteOnce
     resources:
       requests:
         storage: 1Gi
     storageClassName: do-block-storage
   ---
   apiVersion: apps/v1
   kind: Deployment
   metadata:
     name: telstar-server
     namespace: telstar
   spec:
     replicas: 1
     selector:
       matchLabels:
         app: telstar-server
     minReadySeconds: 10
     strategy:
       type: RollingUpdate
       rollingUpdate:
         maxUnavailable: 1
         maxSurge: 1
     template:
       metadata:
         labels:
           app: telstar-server # this label matches the services label selector
       spec:
         containers:
         - name: telstar-server
           image: johnnewcombe/telstar:0.3
           args: ["server", "--install", "--init", "--port", "25232"]
           ports:
           - containerPort: 25232
           env:
             - name: TELSTAR_SERVER
               value: "KEATS"
             - name: TELSTAR_DBCOLLECTION
               value: "primary"
           volumeMounts:
           - mountPath: "/opt/telstar/volume"
             name: telstar-volume
         volumes:
           - name: telstar-volume
             persistentVolumeClaim:
               claimName: telstar-pvc
    1. Mongob
   apiVersion: v1
   kind: Service
   metadata:
     name: telstar-mongo
     namespace: telstar
     labels:
       app: telstar-mongo
   spec:
     type: NodePort
     ports:
     - port: 27017
       nodePort: 30001
       protocol: TCP
     selector:
       app: telstar-mongo
   ---
   apiVersion: apps/v1
   kind: Deployment
   metadata:
     name: telstar-mongo
     namespace: telstar
   spec:
     replicas: 1
     selector:
       matchLabels:
         app: telstar-mongo
     minReadySeconds: 10
     strategy:
       type: RollingUpdate
       rollingUpdate:
         maxUnavailable: 1
         maxSurge: 1
     template:
       metadata:
         labels:
           app: telstar-mongo # this label matches the services label selector
       spec:
         containers:
         - name: telstar-mongo
           image: mongo
           ports:
           - containerPort: 27017
           env:
             - name: MONGO_INITDB_ROOT_USERNAME
               value: "mongoadmin"
             - name: MONGO_INITDB_ROOT_PASSWORD
               value: "secret"
    1. Cronjob
   apiVersion: batch/v1beta1
   kind: CronJob
   metadata:
     name: telstar-cron
     namespace: telstar
   spec:
     # At minute 30 past hours 0, 4, 8, 12, 16, and 20.
     schedule: "30 0,4,8,12,16,20 * * *"
     jobTemplate:
       spec:
         template:
           spec:
             containers:
             - name: telstar-cron
               image: johnnewcombe/telstar:0.3
               args: ["cron"]
               env:
                 - name: TELSTAR_DBCOLLECTION
                   value: "primary"
               volumeMounts:
                 - mountPath: "/opt/telstar/volume"
                   name: telstar-volume
             volumes:
               - name: telstar-volume
                 persistentVolumeClaim:
                   claimName: telstar-pvc
             restartPolicy: Never
     concurrencyPolicy: Forbid