# nodejs-app.yml --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nodejs-app-deployment namespace: default labels: app: nodejs-app spec: revisionHistoryLimit: 2 replicas: 2 selector: matchLabels: app: nodejs-app # destroy all before creating new pods #strategy: # type: Recreate strategy: # better for stateless services, no outage type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 1 template: metadata: labels: app: nodejs-app tier: frontend spec: containers: - name: nodejs-app image: igoratencompass/nodejs-app imagePullPolicy: IfNotPresent ports: - containerPort: 8080 name: nodejs-app resources: limits: cpu: "100m" memory: 128Mi requests: cpu: "10m" memory: 64Mi readinessProbe: successThreshold: 1 failureThreshold: 2 periodSeconds: 5 # Important so that the container doesn't get traffic too soon initialDelaySeconds: 5 httpGet: path: / port: 8080 scheme: HTTP livenessProbe: successThreshold: 1 failureThreshold: 2 periodSeconds: 5 initialDelaySeconds: 5 timeoutSeconds: 1 httpGet: path: /health port: 8080 scheme: HTTP # Needed for no-downtime deployments with IngressController lifecycle: preStop: exec: command: ["sleep", "5"] dnsPolicy: ClusterFirst restartPolicy: Always securityContext: {} terminationGracePeriodSeconds: 30 tolerations: - key: node-role.kubernetes.io/master operator: "Equal" value: "" effect: NoSchedule --- apiVersion: v1 kind: Service metadata: name: nodejs-app-svc namespace: default labels: name: nodejs-app annotations: service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0 spec: type: ClusterIP ports: - port: 80 targetPort: 8080 protocol: TCP selector: # This needs to match the selector in the RC/Deployment app: nodejs-app --- apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: name: nodejs-app-autoscaler namespace: default spec: scaleTargetRef: apiVersion: extensions/v1beta1 kind: Deployment name: nodejs-app-deployment minReplicas: 1 maxReplicas: 3 targetCPUUtilizationPercentage: 80