You can add environment variables in FEPCluster and its containers. This makes it possible, for example, to define HTTP_PROXY and use cloud services on the Internet via a proxy server from a closed network.
Environment variables are defined in key/value format for any secret. Environment variables are applied in the constructed container by defining a Secret name with environment variables defined in the custom resource.
You can define global environment variables that are common to all containers in a Pod, and local environment variables that are unique to each container.
If you define a global environment variable and a local environment variable with the same name, the value of the local environment variable takes precedence.
Here is an example of defining an environment variable with Secret:
Specify the name of the environment variable as key and the base64 encoded value as value.
The following is an example of a global environment variable definition that applies to all containers in the FEPCluster Pod. Secret "global-env-secret" defines two environment variables: HTTP_PROXY and MY_API_SERVER_KEY.
Value is defined as the base64 encoded value of the value written after #.
The name of the Secret is optional and is specified for the custom resource described in the "2.3.16.2 Custom Resource Definition Example" section.
The Secret Namespace specifies the Namespace to which the custom resource is applied.
kind: Secret apiVersion: v1 metadata: name: global-env-secret namespace: my-namespace data: HTTP_PROXY: aHR0cDovL215LnByb3h5LnNlcnZlci5pcDo4MDgwCg== # http://my.proxy.server.ip:8080 MY_API_SERVER_KEY: NjBjZDgzMmMtNDNjZC00ZTI5LWE0N2QtZGI2MjU1MDNkYzJjCg== # 60cd832c-43cd-4e29-a47d-db625503dc2c type: Opaque
The following is an example of an environment variable to be specified locally in a container on the FEP server. Secret "local-env-secret" has a different MY_API_SERVER_KEY than global-env-secret.
kind: Secret apiVersion: v1 metadata: name: local-env-secret namespace: my-namespace data: HTTP_PROXY: aHR0cDovL215LnByb3h5LnNlcnZlci5pcDo4MDgwCg== # http://my.proxy.server.ip:8080 MY_API_SERVER_KEY: BjBjZDgzMmMtNDNjZC00ZTI5LWE0N2QtZGI2MjU1MDNkYzJjCg== # 0cd832c-43cd-4e29-a47d-db625503dc2c type: Opaque
Provide an example of specifying global and local environment variables when building an FEPCluster custom resource.
Specify the Secret "global-env-secret" in spec.globalEnvSec that defines the global environment variables that apply to all pods in common.
Specify Secret "local-env-secret" in spec.fep.fepEnvSec, which defines the environment variable to be applied to the FEP server container.
kind: FEPCluster
apiVersion: fep.fujitsu.io/v2
metadata:
name: my-cluster
namespace: my-namespace
spec:
globalEnvSec: global-env-secret
fep:
fepEnvSec: local-env-secretAt this time, the environment variable MY_API_SERVER_KEY is defined in global-env-secret and local-env-secret with different values, but the value “0cd832c-43cd-4e29-a47d-db625503dc2c”defined in local-env-secret is applied in the FEP server container.
Refer to the Reference for parameters for applying environment variables to other containers.
Specifying a Secret with an environment variable defined can only be defined when creating a custom resource. Secrets cannot be added or modified after custom resource creation.
After you update the contents of the Secret with environment variables defined, you can restart the Pod to reflect the latest environment variables in the container.
Pod reboots can be performed by specifying restart for spec.fepAction.type in the FEPAction custom resource.
Refer to the "FEPAction Custom Resource Parameters" in the Reference for more information.