Kubernetes
Deploy your Stoma gateway to Kubernetes.
Deployment
Section titled “Deployment”apiVersion: apps/v1kind: Deploymentmetadata: name: stoma-gateway labels: app: stoma-gatewayspec: replicas: 3 selector: matchLabels: app: stoma-gateway template: metadata: labels: app: stoma-gateway spec: containers: - name: gateway image: stoma-gateway:latest ports: - containerPort: 3000 env: - name: NODE_ENV value: "production" - name: UPSTREAM_URL valueFrom: secretKeyRef: name: gateway-secrets key: upstream-url resources: requests: memory: "128Mi" cpu: "100m" limits: memory: "256Mi" cpu: "500m" livenessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 5 periodSeconds: 10 readinessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 5 periodSeconds: 5Service
Section titled “Service”apiVersion: v1kind: Servicemetadata: name: stoma-gatewayspec: selector: app: stoma-gateway ports: - port: 80 targetPort: 3000 type: ClusterIPIngress
Section titled “Ingress”apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: stoma-gateway annotations: nginx.ingress.kubernetes.io/rewrite-target: /spec: rules: - host: api.example.com http: paths: - path: / pathType: Prefix backend: service: name: stoma-gateway port: number: 80Horizontal Pod Autoscaler
Section titled “Horizontal Pod Autoscaler”apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata: name: stoma-gatewayspec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: stoma-gateway minReplicas: 3 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70Apply Resources
Section titled “Apply Resources”kubectl apply -f deployment.yamlkubectl apply -f service.yamlkubectl apply -f ingress.yamlCheck Status
Section titled “Check Status”kubectl get pods -l app=stoma-gatewaykubectl get svc stoma-gatewaykubectl describe ingress stoma-gateway