apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ .Values.agent.name }}
  labels:
    app: {{ template "weave-cloud.name" . }}
    chart: {{ template "weave-cloud.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  minReadySeconds: 30
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: {{ template "weave-cloud.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "weave-cloud.name" . }}
        release: {{ .Release.Name }}
    spec:
      {{- if .Values.serviceAccount.create }}
      serviceAccountName: {{ template "weave-cloud.serviceAccountName" . }}
      {{- end }}
      terminationGracePeriodSeconds: 30
      containers:
      - name: agent
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        args:
        - -agent.poll-url=https://get.weave.works/k8s/agent.yaml?instanceID={{"{{.InstanceID}}"}}
        - -wc.hostname=cloud.weave.works
        - -wc.token=$(WEAVE_CLOUD_TOKEN)
        env:
        - name: WEAVE_CLOUD_TOKEN
          valueFrom:
            secretKeyRef:
              key: token
              name: weave-cloud
