| # Licensed to the Apache Software Foundation (ASF) under one or more contributor |
| # license agreements; and to You under the Apache License, Version 2.0. |
| |
| {{- if eq .Values.invoker.containerFactory.impl "docker" }} |
| apiVersion: apps/v1 |
| kind: DaemonSet |
| {{- else if eq .Values.invoker.containerFactory.impl "kubernetes" }} |
| apiVersion: apps/v1 |
| kind: StatefulSet |
| {{- end }} |
| metadata: |
| name: {{ .Release.Name }}-invoker |
| labels: |
| name: {{ .Release.Name }}-invoker |
| {{ include "openwhisk.label_boilerplate" . | indent 4 }} |
| spec: |
| {{- if eq .Values.invoker.containerFactory.impl "kubernetes" }} |
| podManagementPolicy: "Parallel" |
| replicas: {{ .Values.invoker.containerFactory.kubernetes.replicaCount }} |
| {{- end }} |
| selector: |
| matchLabels: |
| name: {{ .Release.Name }}-invoker |
| template: |
| metadata: |
| labels: |
| name: {{ .Release.Name }}-invoker |
| {{ include "openwhisk.label_boilerplate" . | indent 8 }} |
| spec: |
| {{- if eq .Values.invoker.containerFactory.impl "kubernetes" }} |
| serviceAccountName: {{ .Release.Name }}-invoker |
| {{- end }} |
| restartPolicy: {{ .Values.invoker.restartPolicy }} |
| |
| affinity: |
| {{ include "openwhisk.affinity.invoker" . | indent 8 }} |
| {{- if eq .Values.invoker.containerFactory.impl "kubernetes" }} |
| {{ include "openwhisk.affinity.selfAntiAffinity" ( printf "%s-invoker" .Release.Name ) | indent 8 }} |
| {{- end }} |
| |
| {{- if eq .Values.invoker.containerFactory.impl "docker" }} |
| volumes: |
| {{ include "openwhisk.docker_volumes" . | indent 6 }} |
| - name: scripts-dir |
| configMap: |
| name: {{ .Release.Name }}-invoker-scripts |
| {{- end }} |
| |
| initContainers: |
| {{- if eq .Values.invoker.containerFactory.impl "docker" }} |
| # Pull images for all default runtimes before starting invoker |
| {{ include "openwhisk.docker_pull_runtimes" . | indent 6 }} |
| {{- end }} |
| # Wait for a controller to be up (which implies kafka, zookeeper, couchdb are all up as well). |
| {{ include "openwhisk.readiness.waitForController" . | indent 6 }} |
| |
| containers: |
| - name: invoker |
| image: "{{- .Values.invoker.imageName -}}:{{- .Values.invoker.imageTag -}}" |
| imagePullPolicy: {{ .Values.invoker.imagePullPolicy | quote }} |
| {{- if and (eq .Values.invoker.containerFactory.impl "docker") .Values.invoker.containerFactory.networkConfig.dns.inheritInvokerConfig }} |
| command: [ "/bin/bash", "-c", ". /invoker-scripts/configureDNS.sh && /init.sh --uniqueName $INVOKER_NAME" ] |
| {{- else }} |
| command: [ "/bin/bash", "-c", "/init.sh --uniqueName $INVOKER_NAME" ] |
| {{- end }} |
| env: |
| - name: "PORT" |
| value: {{ .Values.invoker.port | quote }} |
| |
| # Needed by invoker to set the environment variable __OW_API_HOST in action containers |
| - name: "WHISK_API_HOST_PROTO" |
| valueFrom: |
| configMapKeyRef: |
| name: {{ .Release.Name }}-whisk.config |
| key: whisk_api_host_proto |
| - name: "WHISK_API_HOST_PORT" |
| valueFrom: |
| configMapKeyRef: |
| name: {{ .Release.Name }}-whisk.config |
| key: whisk_api_host_port |
| - name: "WHISK_API_HOST_NAME" |
| valueFrom: |
| configMapKeyRef: |
| name: {{ .Release.Name }}-whisk.config |
| key: whisk_api_host_name |
| |
| - name: "CONFIG_whisk_docker_containerFactory_useRunc" |
| value: {{ .Values.invoker.containerFactory.useRunc | quote }} |
| |
| - name: "CONFIG_whisk_containerPool_userMemory" |
| value: {{ .Values.whisk.containerPool.userMemory | quote }} |
| |
| {{- if not .Values.invoker.containerFactory.networkConfig.dns.inheritInvokerConfig }} |
| {{- if ne .Values.invoker.containerFactory.networkConfig.dns.overrides.nameservers "" }} |
| # DNS Server(s) to be used by action containers |
| {{- range $index, $element := splitList " " .Values.invoker.containerFactory.networkConfig.dns.overrides.nameservers }} |
| - name: "CONFIG_whisk_containerFactory_containerArgs_dnsServers_{{ $index }}" |
| value: {{ $element | quote }} |
| {{- end }} |
| {{- end }} |
| {{- if ne .Values.invoker.containerFactory.networkConfig.dns.overrides.search "" }} |
| # DNS search path to be used by action containers |
| {{- range $index, $element := splitList " " .Values.invoker.containerFactory.networkConfig.dns.overrides.search }} |
| - name: "CONFIG_whisk_containerFactory_containerArgs_dnsSearch_{{ $index }}" |
| value: {{ $element | quote }} |
| {{- end }} |
| {{- end }} |
| {{- if ne .Values.invoker.containerFactory.networkConfig.dns.overrides.options "" }} |
| # DNS options to be used by action containers |
| {{- range $index, $element := splitList " " .Values.invoker.containerFactory.networkConfig.dns.overrides.options }} |
| - name: "CONFIG_whisk_containerFactory_containerArgs_dnsOptions_{{ $index }}" |
| value: {{ $element | quote }} |
| {{- end }} |
| {{- end }} |
| {{- end }} |
| - name: "CONFIG_whisk_docker_containerFactory_containerArgs_network" |
| value: {{ .Values.invoker.containerFactory.networkConfig.name | quote }} |
| |
| # Invoker name is the name of the node (DaemonSet) or pod (StatefulSet) |
| - name: "INVOKER_NAME" |
| valueFrom: |
| fieldRef: |
| fieldPath: {{ if eq .Values.invoker.containerFactory.impl "docker" }} spec.nodeName {{ else }} metadata.name {{ end }} |
| |
| # Java options |
| - name: "JAVA_OPTS" |
| value: "-Xmx{{- .Values.invoker.jvmHeapMB -}}M {{ .Values.invoker.jvmOptions }}" |
| |
| # Invoker options |
| - name: "INVOKER_OPTS" |
| value: "{{ .Values.invoker.options }} {{ if eq .Values.invoker.containerFactory.impl "docker" }} -Dwhisk.spi.ContainerFactoryProvider=org.apache.openwhisk.core.containerpool.docker.DockerContainerFactoryProvider {{ else }} -Dkubernetes.master=https://$KUBERNETES_SERVICE_HOST -Dwhisk.spi.ContainerFactoryProvider=org.apache.openwhisk.core.containerpool.kubernetes.KubernetesContainerFactoryProvider {{ end }}" |
| |
| {{ if .Values.invoker.containerFactory.kubernetes.agent.enabled }} |
| - name: "CONFIG_whisk_kubernetes_invokerAgent_enabled" |
| value: "TRUE" |
| - name: "CONFIG_whisk_kubernetes_invokerAgent_port" |
| value: {{ .Values.invoker.containerFactory.kubernetes.agent.port | quote }} |
| {{ end }} |
| |
| # action runtimes |
| - name: "RUNTIMES_MANIFEST" |
| value: {{ template "openwhisk.runtimes_manifest" . }} |
| |
| # Action limits |
| {{ include "openwhisk.limitsEnvVars" . | indent 10 }} |
| |
| # Default to empty logs dir. This is because logs should go to stdout |
| - name: "WHISK_LOGS_DIR" |
| value: "" |
| |
| # this version is the day it is deployed, |
| - name: "CONFIG_whisk_info_date" |
| valueFrom: |
| configMapKeyRef: |
| name: {{ .Release.Name }}-whisk.config |
| key: whisk_info_date |
| |
| # properties for DB connection |
| {{ include "openwhisk.dbEnvVars" . | indent 10 }} |
| |
| # properties for kafka connection |
| - name: "KAFKA_HOSTS" |
| value: "{{ include "openwhisk.kafka_host" . }}:{{ .Values.kafka.port }}" |
| {{ include "openwhisk.kafkaConfigEnvVars" . | indent 10 }} |
| |
| # properties for zookeeper connection |
| - name: "ZOOKEEPER_HOSTS" |
| value: "{{ include "openwhisk.zookeeper_connect" . }}" |
| |
| ports: |
| - name: invoker |
| containerPort: {{ .Values.invoker.port }} |
| {{- if eq .Values.invoker.containerFactory.impl "docker" }} |
| volumeMounts: |
| {{ include "openwhisk.docker_volume_mounts" . | indent 8 }} |
| {{- if .Values.invoker.containerFactory.networkConfig.dns.inheritInvokerConfig }} |
| - name: scripts-dir |
| mountPath: "/invoker-scripts/configureDNS.sh" |
| subPath: "configureDNS.sh" |
| {{- end }} |
| {{- end }} |