---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: server
  labels:
    app.kubernetes.io/name: server
    app.kubernetes.io/app: server
spec:
  replicas: 1
  revisionHistoryLimit: 2
  strategy:
    rollingUpdate:
      maxSurge: "100%"
      maxUnavailable: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: server
  template:
    metadata:
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8080"
      labels:
        app.kubernetes.io/name: server
    spec:
      containers:
        - name: server
          image: docker.io/saidsef/node-webserver:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
              protocol: TCP
              name: http
          env:
            - name: HOST_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
          livenessProbe:
            exec:
              command:
                - pgrep
                - node
            initialDelaySeconds: 5
            failureThreshold: 3
            timeoutSeconds: 3
            successThreshold: 1
            periodSeconds: 10
          readinessProbe:
            httpGet:
              port: 8080
              path: /healthz
              scheme: "HTTP"
            initialDelaySeconds: 5
            failureThreshold: 3
            timeoutSeconds: 3
            successThreshold: 1
            periodSeconds: 10
          resources:
            requests:
              cpu: 40m
              memory: 128Mi
            limits:
              cpu: 50m
              memory: 512Mi
          securityContext:
            allowPrivilegeEscalation: false
            privileged: false
            runAsNonRoot: true
            readOnlyRootFilesystem: true
            # user/group: nobody
            runAsGroup: 65534
            runAsUser: 65534
            capabilities:
              drop:
                - ALL
              add:
                - NET_BIND_SERVICE
