apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: geonames-cron
  namespace: airfllow-tls
  labels:
    name: geonames
    instance: geonames-cron
    version: "1.0.0"
    component: batch
    part-of: jobs
spec:
  concurrencyPolicy: Forbid
  schedule: "*/15 * * * *"
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  jobTemplate:
    metadata:
      labels:
        name: geonames
        instance: geonames-cron
        version: "1.0.0"
        component: batch
        part-of: jobs
    spec:
      activeDeadlineSeconds: 1800
      ttlSecondsAfterFinished: 180
      backoffLimit: 3
      completions: 1
      parallelism: 1
      template:
        metadata:
          labels:
            name: geonames
            instance: geonames-cron
            version: "1.0.0"
            component: batch
            part-of: jobs
        spec:
          restartPolicy: Never  # OnFailure
          nodeSelector:
            "beta.kubernetes.io/os": linux
          containers:
            - name: geonames
              image: rkoH1pVL.azurecr.io/geonames:latest
              imagePullPolicy: Always  # IfNotPresent
              env:
                - name: APP_LOG_KEY
                  value: "rko.aks.geonames2lake.dev"
                - name: LOG_LEVEL
                  value: "DEBUG"
                - name: ON_QUEUE
                  value: "False"
                - name: CENSUS_STATES_URI
                  value: "https://www2.census.gov/programs-surveys/popest/geographies/2019/state-geocodes-v2019.xlsx"
                - name: CENSUS_COUNTIES_URI
                  value: "https://www2.census.gov/geo/docs/maps-data/data/gazetteer/2019_Gazetteer/2019_Gaz_counties_national.zip"
                - name: GEONAMES_ZIPCODES_URI
                  value: "http://download.geonames.org/export/zip/US.zip"
                - name: CENSUS_STATE_NAME
                  value: "MasterData.StateTerritory"
                - name: CENSUS_COUNTY_NAME
                  value: "MasterData.CountyProvince"
                - name: GEONAMES_ZIPCODE_NAME
                  value: "MasterData.ZipCode"
                - name: LAKE_ACCOUNT_NAME
                  value: "airflowstoragesandbox"
                - name: LAKE_ACCOUNT_KEY
                  valueFrom:
                    secretKeyRef:
                      name: az-file-secret
                      key: azurestorageaccountkey
                - name: LAKE_CONTAINER_NAME
                  value: "enterprisedata"
                - name: LAKE_BASE_PATH
                  value: "Raw/MasterData/Geography/Brightspring"
              resources:
                requests:
                  cpu: "250m"
                  memory: "250Mi"
                limits:
                  cpu: "1000m"
                  memory: "1Gi"
