Kubernetes Deployment

The preferred deployment mechanism is to use Docker Containers. Kubernetes provides a mechanism to schedule these containers and expose the underlying services to external users and services.

Statefulset

A SwimOS application needs to have an understanding of the underlying pods that make up the service. This means an understanding of what other hosts are part of the cluster. A StatefulSet helps us accomplish this by giving us a consistent set of hostnames based on the StatefulSet name and the number of replicas.

This is an example that is used to deploy our Cellular demo. This launches the pods that hosts our application.

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: demo-cellular
  namespace: demo-cellular
spec:
  replicas: 1
  selector:
    matchLabels:
      demo: cellular
  serviceName: demo
  template:
    metadata:
      labels:
        demo: cellular
    spec:
      containers:
        - image: DOCKER_IMAGE
          imagePullPolicy: Always
          name: demo
          ports:
            - containerPort: 9001
              protocol: TCP
          resources:
            limits:
              cpu: "2"
              memory: 12Gi
            requests:
              cpu: "2"
              memory: 12Gi

Service

Each of the endpoints that are hosting a SwimOS application need to be exposed on the cluster. This allows data to flow to the pod where the WebAgent is hosted.

apiVersion: v1
kind: Service
metadata:
  name: demo-cellular
  namespace: demo-cellular
spec:
  ports:
  - port: 9001
    protocol: TCP
    targetPort: 9001
  selector:
    demo: cellular
  sessionAffinity: None
  type: ClusterIP

Ingress

Now that the pods have been created and the services exposed for our application we need to expose it to the outside world.

Ingress can be fun...

Our example is for Nginx ingress, but you might be running something different in your environment. Reach out to your administrator to determine which ingress you should be using.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-cellular
  namespace: demo-cellular
spec:
  defaultBackend:
    service:
      name: demo-cellular
      port:
        number: 9001
  ingressClassName: nginx
  rules:
  - host: cellular.services.nstream-demo.io
    http:
      paths:
      - backend:
          service:
            name: demo-cellular
            port:
              number: 9001
        path: /
        pathType: ImplementationSpecific
  - host: cellular.origins.nstream-demo.io
    http:
      paths:
      - backend:
          service:
            name: demo-cellular
            port:
              number: 9001
        path: /
        pathType: ImplementationSpecific

Nstream is licensed under the Redis Source Available License 2.0 (RSALv2).