{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (ne .Values.omsagent.env.clusterName "<your_cluster_name>")}}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
 name: omsagent-rs
 namespace: kube-system
 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
 release: {{ .Release.Name }}
 heritage: {{ .Release.Service }}
spec:
 replicas: 1
 selector:
  matchLabels:
   rsName: "omsagent-rs"
 strategy:
  type: RollingUpdate
 template:
  metadata:
   labels:
    rsName: "omsagent-rs"
   annotations:
    agentVersion: {{ .Values.omsagent.image.tag }}
    dockerProviderVersion: {{ .Values.omsagent.image.dockerProviderVersion }}
  spec:
  {{- if .Values.omsagent.rbac }}
   serviceAccountName: omsagent
  {{- end }}
   containers:
     - name: omsagent 
       image: "microsoft/oms:{{ .Values.omsagent.image.tag }}"
       imagePullPolicy: IfNotPresent
       resources:
{{ toYaml .Values.omsagent.resources.deployment | indent 9 }}
       env:
       - name: ACS_RESOURCE_NAME
         value: {{ .Values.omsagent.env.clusterName | quote }}
       - name: DISABLE_KUBE_SYSTEM_LOG_COLLECTION
         value: {{ .Values.omsagent.env.doNotCollectKubeSystemLogs | quote }}
       - name: NODE_IP
         valueFrom:
            fieldRef:
              fieldPath: status.hostIP  
       securityContext:
         privileged: true
       ports:
       - containerPort: 25225
         protocol: TCP 
       - containerPort: 25224
         protocol: UDP
       volumeMounts:
        - mountPath: /var/run/docker.sock
          name: docker-sock
        - mountPath: /var/log 
          name: host-log
        - mountPath: /var/lib/docker/containers 
          name: containerlog-path
        - mountPath: /etc/omsagent-secret
          name: omsagent-secret
          readOnly: true
        - mountPath : /etc/config
          name: omsagent-rs-config
       livenessProbe:
        exec:
         command:
         - /bin/bash
         - -c
         - ps -ef | grep omsagent | grep -v "grep"
        initialDelaySeconds: 60
        periodSeconds: 60
   nodeSelector:
    beta.kubernetes.io/os: linux
    kubernetes.io/role: agent
   volumes:
    - name: docker-sock 
      hostPath:
       path: /var/run/docker.sock
    - name: container-hostname
      hostPath:
       path: /etc/hostname
    - name: host-log
      hostPath:
       path: /var/log
    - name: containerlog-path
      hostPath:
       path: /var/lib/docker/containers
    - name: omsagent-secret
      secret:
       secretName: omsagent-secret
    - name: omsagent-rs-config
      configMap:
        name: omsagent-rs-config
{{- end }} 