---
# Source: xweather-lightning/templates/xweather-lightning/xweather-lightning-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: xweather-lightning-configmap
  namespace: vaisala-focus-lightning
  labels:
    app: xweather-lightning-configmap
data:
  application-kubernetes.yaml: |-
    spring:
      cloud:
        config:
          enabled: false
        kubernetes:
          enabled: true
          discovery:
            enabled: true
            all-namespaces: true
            include-not-ready-addresses: true
          config:
            enabled: true
            namespace: vaisala-focus-lightning
            sources:
              - name: xweather-lightning-configmap
              - name: application-configmap
          reload:
            enabled: true
            monitoring-config-maps: true
            monitoring-secrets: true

    logging:
      level:
        root: INFO
        # Kafka is pretty verbose, so we set it to WARN
        org.apache.kafka: WARN
        # Vaisala software logging
        com.vaisala: INFO
        # com.vaisala.services.kafkacopy: DEBUG

    # Kafka Topic Copy Configuration
    kafka-topic-copy:
      # Consumer group ID for tracking offsets on the source cluster
      consumer-group-id: XWEATHER_LIGHTNING_USER
      # Maximum number of records to poll at once from source
      max-poll-records: 500
      # Source Kafka cluster configuration (read-only access)
      source:
        bootstrap-servers: 3.19.98.132:9095
        properties:
          ssl:
            endpoint:
              identification:
                algorithm: ""
          security:
            protocol: SASL_PLAINTEXT
          sasl:
            mechanism: PLAIN
            jaas:
              config: |-
                org.apache.kafka.common.security.scram.ScramLoginModule required
                  username="XWEATHER_LIGHTNING_USER" password="XWEATHER_LIGHTNING_PASS";

      # Target Kafka cluster configuration (write access)
      target:
        bootstrap-servers: kafka.vaisala-focus-external-services:9095
        properties:
          ssl:
            endpoint:
              identification:
                algorithm: ""
          security:
            protocol: SASL_PLAINTEXT
          sasl:
            mechanism: SCRAM-SHA-512
            jaas:
              config: |-
                org.apache.kafka.common.security.scram.ScramLoginModule required
                  username="focus-kafka" password="REPLACE_WITH_KAFKA_CLIENT_AUTH_TOKEN";

      # List of topic mappings to copy
      # To enable sequential checks, set 'sequential-check' to the appropriate value
      # KEY_LONG - If there is a key associated with each message that is in the form of an increment
      #    integer string that fit in a 64 bit long (keys like "138882038")
      # DATA_LD - If the topic contains binary serialized form of protobuf3 lightning data
      #    (com.vaisala.protobuf.ltg.ld.LdOuterClass.Ld Java Objects)
      # DATA_LDBATCH - If the topic contains binary serialized form of protobuf3 lightning data
      #    (com.vaisala.protobuf.ltg.ld.LdOuterClass.LdBatch Java Objects)
      # DATA_REGIONSTATUSREPORT - If the topic contains binary serialized form of protobuf3 lightning data
      #    (com.vaisala.protobuf.ltg.regionstatus.RegionStatusReportOuterClass.RegionStatusReport Java Objects)

      topics:
        - source-topic-name: stream.lightning.XWEATHER_LIGHTNING_USER.locations
          target-topic-name: stream.lightning.locations
          enabled: true
          sequential-check: DATA_LD
        # Network health is not available for GLD360 feeds as of 2025-11-17 (leave enabled as false)
        - source-topic-name: stream.lightning.XWEATHER_LIGHTNING_USER.region_status
          target-topic-name: stream.lightning.region_status
          enabled: false
          sequential-check: DATA_REGIONSTATUSREPORT
---
# Source: xweather-lightning/templates/xweather-lightning/xweather-lightning-deployment.yaml
# management-service (spring-boot actuator)
apiVersion: v1
kind: Service
metadata:
  name: xweather-lightning-management
  namespace: vaisala-focus-lightning
  labels:
    app: xweather-lightning-management
  annotations:
    # This is for prometheus' service-endpoint metrics URL.
    prometheus.io/should_be_scraped: "true"
    prometheus.io/scrape_port: "8080"
    prometheus.io/metric_path: /actuator/prometheus
spec:
  type: ClusterIP
  selector:
    app: xweather-lightning
  ports:
    - name: management
      port: 8080
      targetPort: 8080
      protocol: TCP
---
# Source: xweather-lightning/templates/xweather-lightning/xweather-lightning-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: xweather-lightning
  namespace: vaisala-focus-lightning
  labels:
    app: xweather-lightning
spec:
  replicas: 1
  selector:
    matchLabels:
      app: xweather-lightning
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: xweather-lightning
    spec:
      initContainers:
        - name: wait-dependencies
          securityContext:
            runAsNonRoot: true
            runAsGroup: 1000
            runAsUser: 1000
          image: "alpine:3.6"
          command:
            - sh
            - -c
            - |
              until nc -vz -w 2 kafka.vaisala-focus-external-services 9095; do
                echo "Waiting for kafka.vaisala-focus-external-services:9095 ..."
                sleep 2
              done
      containers:
      - name: xweather-lightning
        securityContext:
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsGroup: 1000
          runAsUser: 1000
        image: "com.vaisala.focus/kafka-topic-copy:8.0.20251117-SNAPSHOT"
        imagePullPolicy: IfNotPresent
        tty: false
        stdin: false
        env:
        # For color and unicode, the LANG needs to be set
        - name: LANG
          value: "en_US.UTF-8"
        - name: SPRING_PROFILES_ACTIVE
          value: "kubernetes"
        envFrom:
        - configMapRef:
            name: xweather-lightning-configmap
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: config-files
          mountPath: /app/resources/application-kubernetes.yaml
          subPath: application-kubernetes.yaml
          readOnly: true
        - name: tmp-volume
          mountPath: /tmp
      terminationGracePeriodSeconds: 3
      volumes:
      - name: config-files
        configMap:
          name: xweather-lightning-configmap
          items:
          - key: application-kubernetes.yaml
            path: application-kubernetes.yaml
      - name: tmp-volume
        emptyDir: {}
