# Written by Mutlu Polatcan
# 21.11.2019
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: hadoop-secondarynamenode
  labels:
    app: hadoop
    unit: secondarynamenode
spec:
  serviceName: hadoop
  replicas: 1
  selector:
    matchLabels:
      app: hadoop
      unit: secondarynamenode
  template:
    metadata:
      labels:
        app: hadoop
        unit: secondarynamenode
    spec:
      initContainers:
        - name: hadoop-init
          image: mpolatcan/hadoop:3.2.1-java8
          imagePullPolicy: Always
          command:
            - /bin/bash
          args:
            - -c
            - $(INIT_SCRIPT)
          envFrom:
            - configMapRef:
                name: hadoop-init
          volumeMounts:
            - mountPath: /hadoop-state
              name: hadoop-snm-volume
      containers:
        - name: hadoop-secondarynamenode
          image: mpolatcan/hadoop:3.2.1-java8
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: hadoop-secondarynamenode
          volumeMounts:
            - mountPath: /home/hduser
              name: hadoop-snm-volume
          livenessProbe:
            tcpSocket:
              port: 9868
            initialDelaySeconds: 15
            periodSeconds: 2
            failureThreshold: 3
          readinessProbe:
            tcpSocket:
              port: 9868
            initialDelaySeconds: 15
            periodSeconds: 2
            failureThreshold: 3
      securityContext:
        fsGroup: 1000
      restartPolicy: Always
  volumeClaimTemplates:
    - metadata:
        name: hadoop-snm-volume
      spec:
        accessModes:
          - ReadWriteOnce
        storageClassName: gce-pd-hdd
        resources:
          requests:
            storage: 50Gi