apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: telemeter-server
  namespace: telemeter
spec:
  podManagementPolicy: Parallel
  replicas: 10
  selector:
    matchLabels:
      k8s-app: telemeter-server
  serviceName: telemeter-server
  template:
    metadata:
      labels:
        k8s-app: telemeter-server
    spec:
      containers:
      - command:
        - /usr/bin/telemeter-server
        - --join=telemeter-server
        - --name=$(NAME)
        - --listen=0.0.0.0:8443
        - --listen-internal=0.0.0.0:8081
        - --listen-cluster=0.0.0.0:8082
        - --shared-key=/etc/pki/service/tls.key
        - --tls-key=/etc/pki/service/tls.key
        - --tls-crt=/etc/pki/service/tls.crt
        - --internal-tls-key=/etc/pki/service/tls.key
        - --internal-tls-crt=/etc/pki/service/tls.crt
        - --authorize=https://api.openshift.com/api/accounts_mgmt/v1/cluster_registrations
        - --authorize-issuer-url=$(RHD_URL)
        - --authorize-client-id=$(RHD_CLIENT_ID)
        - --authorize-username=$(RHD_USERNAME)
        - --authorize-password=$(RHD_PASSWORD)
        - --whitelist={__name__="up"}
        - --whitelist={__name__="cluster_version"}
        - --whitelist={__name__="cluster_version_available_updates"}
        - --whitelist={__name__="cluster_operator_up"}
        - --whitelist={__name__="cluster_operator_conditions"}
        - --whitelist={__name__="cluster_version_payload"}
        - --whitelist={__name__="cluster_version_payload_errors"}
        - --whitelist={__name__="cluster_installer"}
        - --whitelist={__name__="cluster_infrastructure_provider"}
        - --whitelist={__name__="cluster_feature_set"}
        - --whitelist={__name__="instance:etcd_object_counts:sum"}
        - --whitelist={__name__="alerts",alertstate="firing"}
        - --whitelist={__name__="code:apiserver_request_count:rate:sum"}
        - --whitelist={__name__="kube_pod_status_ready:etcd:sum"}
        - --whitelist={__name__="kube_pod_status_ready:image_registry:sum"}
        - --whitelist={__name__="cluster:capacity_cpu_cores:sum"}
        - --whitelist={__name__="cluster:capacity_memory_bytes:sum"}
        - --whitelist={__name__="cluster:cpu_usage_cores:sum"}
        - --whitelist={__name__="cluster:memory_usage_bytes:sum"}
        - --whitelist={__name__="openshift:cpu_usage_cores:sum"}
        - --whitelist={__name__="openshift:memory_usage_bytes:sum"}
        - --whitelist={__name__="workload:cpu_usage_cores:sum"}
        - --whitelist={__name__="workload:memory_usage_bytes:sum"}
        - --whitelist={__name__="cluster:node_instance_type_count:sum"}
        - --whitelist={__name__="node_role_os_version_machine:cpu_capacity_cores:sum"}
        - --whitelist={__name__="subscription_sync_total"}
        - --elide-label=prometheus_replica
        env:
        - name: NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: RHD_URL
          valueFrom:
            secretKeyRef:
              key: rhd.url
              name: telemeter-server
        - name: RHD_USERNAME
          valueFrom:
            secretKeyRef:
              key: rhd.username
              name: telemeter-server
        - name: RHD_PASSWORD
          valueFrom:
            secretKeyRef:
              key: rhd.password
              name: telemeter-server
        - name: RHD_CLIENT_ID
          valueFrom:
            secretKeyRef:
              key: rhd.client_id
              name: telemeter-server
        image: quay.io/openshift/origin-telemeter:v4.0
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8443
            scheme: HTTPS
        name: telemeter-server
        ports:
        - containerPort: 8443
          name: external
        - containerPort: 8081
          name: internal
        - containerPort: 8082
          name: cluster
        readinessProbe:
          httpGet:
            path: /healthz/ready
            port: 8443
            scheme: HTTPS
        resources:
          limits: {}
          requests: {}
        volumeMounts:
        - mountPath: /etc/pki/service
          name: telemeter-server-tls
          readOnly: false
      serviceAccountName: telemeter-server
      volumes:
      - name: secret-telemeter-server
        secret:
          secretName: telemeter-server
      - name: telemeter-server-tls
        secret:
          secretName: telemeter-server-shared
