Difference between revisions of "Orchestrating Telstar with Kubernetes"

From Telstar Wiki
Jump to navigation Jump to search
(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": {...")
 
Line 1: Line 1:
# Using Kubernetes
== 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 Balancer.


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 ===
 
## Telstar Namspace


     {
     {
Line 18: Line 16:
     }
     }
      
      
## Telstar Server
=== Telstar Server ===


     apiVersion: v1
     apiVersion: v1
Line 79: Line 77:
           containers:
           containers:
           - name: telstar-server
           - name: telstar-server
             image: johnnewcombe/telstar:0.3
             image: johnnewcombe/telstar
             args: ["server", "--install", "--init", "--port", "25232"]
             args: ["server", "--init", "--port", "25232"]
             ports:
             ports:
             - containerPort: 25232
             - containerPort: 25232
Line 96: Line 94:
                 claimName: telstar-pvc
                 claimName: telstar-pvc


## Mongob
=== Mongob ===


     apiVersion: v1
     apiVersion: v1
Line 145: Line 143:
               - name: MONGO_INITDB_ROOT_PASSWORD
               - name: MONGO_INITDB_ROOT_PASSWORD
                 value: "secret"
                 value: "secret"
## 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

Revision as of 20:57, 9 April 2022

Using Kubernetes

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 Balancer.

Telstar Namspace

   {
     "apiVersion": "v1",
     "kind": "Namespace",
     "metadata": {
       "name": "telstar",
       "labels": {
         "name": "telstar"
       }
     }
   }
   

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
           args: ["server", "--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

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"