apiVersion: apps/v1      # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: nginx            
  labels:
    tier: frontend       
    app:  nginx          
  annotations:
    description: A stateless Nginx SSL Pod deployment
spec:                    
  strategy:
    type: RollingUpdate   
    rollingUpdate:
      maxUnavailable: 25%  
      maxSurge: 25%        
  minReadySeconds: 0                              
  progressDeadlineSeconds: 600 

  selector:              
    matchLabels:         # The spec.selector.matchLabels must match one of the labels in spec.template.metadata.labels.
      tier: frontend
      app: nginx
            
  template:             
    metadata:            
      labels:
        tier: frontend   # Labels must be assigned to the Pod controlled by a Deployment.
        app:  nginx      
    spec:                
      volumes:          
        - name: www-data-share     
          emptyDir: {}
        - name: ssl-files              
          secret:                    
            secretName: ssl-secret     
        - name: nginx-conf-file
          configMap:                   
            name: nginx-conf

      containers:
        - name: nginx                
          image: nginx:1.13.8
          resources:   
            requests:  
              cpu: "1m"      # A HPA requires a resource request such as the CPU or Memory
          volumeMounts:
            - mountPath: /usr/share/nginx/html      
              name: www-data-share                  
              readOnly: true
            - name: ssl-files           
              mountPath: "/ssl"         
              readOnly: true
            - name: nginx-conf-file          
              mountPath: /etc/nginx/conf.d
          readinessProbe:     
            httpGet:          
              path: /
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10                        
          ports:
            - containerPort: 80
            - containerPort: 443
        
        - name: git-sync
          image: openweb/git-sync:0.0.1
          resources:   
            requests:  
              cpu: "1m"  
          volumeMounts:
            - mountPath: /usr/share/nginx/html    
              name: www-data-share                
          env:                       
            - name: GIT_SYNC_REPO    
              value: "https://github.com/naveenjoy/naveenjoy.github.io.git"     
            - name: GIT_SYNC_DEST    
              value: "/usr/share/nginx/html" 
            - name: GIT_SYNC_BRANCH  
              value: "master"
            - name: GIT_SYNC_REV
              value: "FETCH_HEAD"
            - name: GIT_SYNC_WAIT    
              value: "10"