sgammon/GUST

View on GitHub
samples/todolist/src/config/99-todolist.k8s.local.yaml

Summary

Maintainability
Test Coverage
##
# Copyright © 2020, The Gust Framework Authors. All rights reserved.
#
# The Gust/Elide framework and tools, and all associated source or object computer code, except where otherwise noted,
# are licensed under the Zero Prosperity license, which is enclosed in this repository, in the file LICENSE.txt. Use of
# this code in object or source form requires and implies consent and agreement to that license in principle and
# practice. Source or object code not listing this header, or unless specified otherwise, remain the property of
# Elide LLC and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to
# Elide LLC and its suppliers and may be covered by U.S. and Foreign Patents, or patents in process, and are protected
# by trade secret and copyright law. Dissemination of this information, or reproduction of this material, in any form,
# is strictly forbidden except in adherence with assigned license requirements.
##

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: todolist-hpa
  namespace: todolist
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: todolist
  minReplicas: 1
  maxReplicas: 3
  targetCPUUtilizationPercentage: 50
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: todolist
  namespace: todolist
  labels:
    app: todolist
    environment: production
  annotations:
    rules-k8s.bazel.io/gust: |
      ---
      app: todolist
      framework: gust
      engine: jvm
spec:
  # -- Replication ----------------------------------------------------------- #
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: todolist
      role: server
      environment: production

  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: "30%"

  # -- Timeouts -------------------------------------------------------------- #
  minReadySeconds: 10
  progressDeadlineSeconds: 300

  template:
    metadata:
      labels:
        app: todolist
        engine: jvm
        role: server
        environment: production

    spec:
      # -- Networking --------------------------------------------------------- #
      dnsPolicy: ClusterFirst

      # -- Placement ---------------------------------------------------------- #
      tolerations:
        - key: role
          operator: Equal
          value: app
        - key: sandbox.gke.io/runtime
          operator: Equal
          value: gvisor

      affinity:
        # Schedule away from other todolist pods.
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 50
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: name
                      operator: In
                      values:
                        - todolist
                topologyKey: kubernetes.io/hostname

        # Schedule close to cache pods.
        podAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 40
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: name
                      operator: In
                      values:
                        - fcache
                topologyKey: kubernetes.io/hostname

      # -- Containers --------------------------------------------------------- #
      containers:
        ## Container: Todolist Server
        - name: todolist-server
          image: us.gcr.io/elide-ai/sample/todolist/jvm
          imagePullPolicy: Never
          resources:
            requests:
              cpu: "0.2"
              memory: "400Mi"
            limits:
              cpu: "0.6"
              memory: "512Mi"
          volumeMounts:
            - name: tls
              mountPath: /etc/ssl/todolist
          ports:
            - name: app
              containerPort: 8080
            - name: api
              containerPort: 8083
          env:
            - name: GUST_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: GUST_ENVIRONMENT
              value: production
          readinessProbe:
            initialDelaySeconds: 10
            successThreshold: 1
            timeoutSeconds: 20
            periodSeconds: 10
            httpGet:
              path: /health
              port: 8080
          livenessProbe:
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 10
            httpGet:
              path: /health
              port: 8080
      volumes:
        - name: tls
          secret:
            secretName: tls