Environment Variable
Set environment variables on Fission environment pods via PodSpec, including exposing Kubernetes Secrets and ConfigMaps to your function.
A pod in Kubernetes is basic unit of deployment. Like every Kubernetes resource the pod consists of the basic declaration, metadata, spec & status.
apiVersion: v1
kind: Pod
metadata:
labels:
svc-name: svc-name
name: podname
spec:
containers:
The spec in a pod, also known as PodSpec, defines the specifications of many behaviors in a declarative manner. A PodSpec defines the containers, environment variables for the container and other properties such as the scheduler name, security context etc.
spec:
containers:
env:
- name: ENV_NAME
value: ENV_VALUE
image: image_url
imagePullPolicy: IfNotPresent
dnsPolicy: ClusterFirst
nodeName: nodename
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: fission-svc
In this section we will look at various use cases that are possible with PodSpec support in Fission. To learn more about specs, check the spec documentation.
Security: PodSpec fields are validated and hardened (since v1.25.0). Because the executor and builder service accounts can create Pods and Deployments, Fission rejects PodSpec fields that would let a function tenant escape the container sandbox or reach node-level state. A user- or environment-supplied (init)container may add only theNET_BIND_SERVICELinux capability throughsecurityContext.capabilities.add; every other capability is rejected by the allowlist, and the executor forcessecurityContext.capabilities.drop: ["ALL"]when it merges the pod. The following are also rejected:hostNetwork,hostPID,hostIPC,hostPathvolumes,serviceAccountName/serviceAccountoverrides,privileged: true, andallowPrivilegeEscalation: true. Keep your PodSpec additions within these bounds, orfission spec apply(and the admission webhook) will reject the Environment or Function.
Here are some ideas for how you can use PodSpec to enhance your function pods:
Set environment variables on Fission environment pods via PodSpec, including exposing Kubernetes Secrets and ConfigMaps to your function.
Add init containers and sidecar containers to a Fission environment’s PodSpec to run setup or auxiliary processes alongside functions.
Define and mount Kubernetes volumes on Fission function containers through PodSpec so stateful functions can access attached data.
Add tolerations to a Fission environment’s PodSpec so functions schedule onto tainted nodes reserved for specific hardware or workloads.