apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: te-agent-statefulset
spec:
  selector:
    matchLabels:
      app: te-agent-statefulset
  replicas: 1
  serviceName: "te-agent-statefulset"
  template:
    metadata:
      labels:
        app: te-agent-statefulset
    spec:
      containers:
      - name: te-agent-statefulset
        image: thousandeyes/enterprise-agent:latest
        command: ["/sbin/my_init"]
        securityContext:
          capabilities:
            add:
              - NET_ADMIN
        env:
        # Account token can be set here explicitly or pulled from secrets
          - name: TEAGENT_ACCOUNT_TOKEN
            # value: "<ThousandEyes Account Token>"
            valueFrom:
              secretKeyRef:
                name: te-credentials
                key: ACCOUNT_TOKEN
          - name: TEAGENT_INET
            value: "4"
          - name: KUBERNETES
            value: "true"
        resources:
          requests:
            memory: "2Gi"
            cpu: "100m"
          limits:
            memory: "2Gi"
            cpu: "200m"
        tty: true
        volumeMounts:
          - name: agent-data
            mountPath: /var/lib/te-agent
            subPath: te-agent
          - name: agent-data
            mountPath: /var/lib/te-browserbot
            subPath: te-browserbot
          - name: agent-data
            mountPath: /var/log/agent
            subPath: log
      terminationGracePeriodSeconds: 10
      restartPolicy: Always
  # The volumeClaimnTemplate will dynamically provision the required
  # persistent storage. The backing storage that is provisioned 
  # will depend on your provider, ex GCE PersistentDisk, AWS EBS, Azure Disk.
  volumeClaimTemplates:
  - metadata:
      name: agent-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 2Gi
# Optional Service
# ---
# apiVersion: v1
# kind: Service
# metadata:
#   name: te-agent-statefulset
#   labels:
#     app: te-agent-statefulset
# spec:
#   ports:
#   - port: 80
#     name: web
#   - port: 443
#     name: https
#   clusterIP: None
#   selector:
#     app: te-agent-statefulset
