# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
apiVersion: nuvolaris.org/v1
kind: Whisk
metadata:
  name: controller
  namespace: nuvolaris
spec:
  nuvolaris:
      password: $SECRET_NUVOLARIS_METADATA
      kube: ${NUVOLARIS_KUBE:-auto}
      apihost: ${NUVOLARIS_APIHOST}
      storageclass: ${NUVOLARIS_STORAGECLASS:-auto}
      provisioner: ${NUVOLARIS_PROVISIONER:-auto}
      ingressclass: ${NUVOLARIS_INGRESSCLASS:-auto}
      ingresslb: ${NUVOLARIS_INGRESSLB:-auto}
      protocol: ${NUVOLARIS_HOST_PROTOCOL:-auto}
  controller:
    image: "$IMAGES_CONTROLLER" 
  components:
    # start openwhisk controller
    openwhisk: true
    # start openwhisk invoker
    invoker: false    
    # start couchdb
    couchdb: true
    # start kafka
    kafka: false
    # start mongodb
    mongodb: ${NUVOLARIS_MONGODB}
    # start redis
    redis: ${NUVOLARIS_REDIS}
    # start cron based action parser
    cron: ${NUVOLARIS_CRON}
    # enable TLS
    tls: ${NUVOLARIS_TLS}
    # minio enabled or not
    minio: ${NUVOLARIS_MINIO}
    # minio static enabled or not
    static: ${NUVOLARIS_STATIC} 
    # postgres enabled or not
    postgres: ${NUVOLARIS_POSTGRES}           
  tls:
    acme-registered-email: ${NUVOLARIS_TLSEMAIL}
    acme-server-url: https://acme-v02.api.letsencrypt.org/directory
  openwhisk:
    namespaces:
      whisk-system: $SECRET_OPENWHISK_SYSTEM
      nuvolaris: $SECRET_OPENWHISK_NUVOLARIS
  couchdb:
    host: couchdb
    volume-size: 10
    admin:
      user: whisk_admin
      password: $SECRET_COUCHDB_ADMIN
    controller:
      user: invoker_admin
      password: $SECRET_COUCHDB_INVOKER
    invoker:
      user: controller_admin
      password: $SECRET_COUCHDB_CONTROLLER
  kafka:
    host: kafka
    volume-size: 10
  scheduler:
    schedule: "* * * * *"
  configs:
    limits:
      activations:
        max_allowed_payload: ${OPENWHISK_ACTIVATION_MAX_ALLOWED_PAYLOAD:-1048576}
      actions:
        sequence-maxLength: 50
        invokes-perMinute: 999
        invokes-concurrent: 250
      triggers: 
        fires-perMinute: 999
      time:
        limit-min: "${OPENWHISK_TIME_LIMIT_MIN:-100ms}"
        limit-std: "${OPENWHISK_TIME_LIMIT_STD:-1min}"
        limit-max: "${OPENWHISK_TIME_LIMIT_STD:-5min}"
    controller:
      javaOpts: "$OPENWHISK_CONTROLLER_JAVA_OPTS"
      loggingLevel: "INFO"
      resources:
        cpu-req: "500m"
        cpu-lim: "1"
        mem-req: "$OPENWHISK_CONTROLLER_RES_MIN_MEM"
        mem-lim: "$OPENWHISK_CONTROLLER_RES_MAX_MEM"      
    invoker:
      loggingLevel: "INFO"
      containerPool:
        userMemory: "$OPENWHISK_CONTROLLER_CONTAINER_POOL_MEMORY"
  redis:
    persistence-enabled: ${REDIS_PERSISTENCE_ENABLED:-true}
    max-memory: ${REDIS_MAX_MEMORY:-1000mb}
    volume-size: 10
    default:
      password: $SECRET_REDIS_DEFAULT
    nuvolaris:
      prefix: nuvolaris
      password: $SECRET_REDIS_NUVOLARIS
  mongodb:
    host: mongodb
    volume-size: 10
    admin: 
      user: whisk_admin
      password: $SECRET_MONGODB_ADMIN
    nuvolaris:
      user: nuvolaris
      password: $SECRET_MONGODB_NUVOLARIS
    exposedExternally: False
    useOperator: False
  minio:
    volume-size: 2
    admin:
      user: minioadmin
      password: $SECRET_MINIO_ADMIN    
    nuvolaris:
      user: nuvolaris
      password: $SECRET_MINIO_NUVOLARIS
  postgres:    
    volume-size: 5
    replicas: 2
    admin:      
      password: $SECRET_POSTGRES_ADMIN
      replica-password: $SECRET_POSTGRES_REPLICA
    nuvolaris:
      password: $SECRET_POSTGRES_NUVOLARIS                   
