Inject Environment Variables
Injecting environment variables into the VJB pods is a feature that allows users to inject environment variables into the VJB pods using a Kubernetes ConfigMap.
Injecting Environment Variables During vJailbreak VM Provisioning
-
Cloud-init populates environment variables
Users must provide environment variables in the
/etc/pf9/envfile during provisioning, typically using a cloud-init script.Example cloud-init configuration using
write_files:write_files:- path: /etc/pf9/envcontent: |http_proxy=http://<proxy-server>:<proxy-port>https_proxy=http://<proxy-server>:<proxy-port>no_proxy=localhost,127.0.0.1permissions: '0644' -
ConfigMap creation from /etc/pf9/env
A helper script or manual command reads
/etc/pf9/envand creates a Kubernetes ConfigMap namedpf9-env. This is done while the vjailbreak VM is being provisioned.Terminal window kubectl create configmap pf9-env --from-env-file=/etc/pf9/env -n migration-systemYou can either populate the
/etc/pf9/envfile via cloud-init or manually.If done manually please follow the steps mentioned in Injecting Environment Variables Post-Provisioning:
Now this will be picked up by the v2v-helper pod and the proxy variables will be available in the pod and it would be respected by the v2v-helper pod.
Injecting Environment Variables Post-Provisioning
If you would like to inject environment variables after the vjailbreak VM has been provisioned, follow these steps:
-
Delete the existing ConfigMap
Terminal window kubectl delete configmap pf9-env -n migration-system -
Populate the
/etc/pf9/envfile with whatever env variables neededTerminal window echo "http_proxy=http://<proxy-server>:<proxy-port>" >> /etc/pf9/envecho "https_proxy=http://<proxy-server>:<proxy-port>" >> /etc/pf9/envecho "no_proxy=localhost,127.0.0.1" >> /etc/pf9/env -
Create a new ConfigMap
Terminal window kubectl create configmap pf9-env --from-env-file=/etc/pf9/env -n migration-system -
Restart the controller manager deployment
Terminal window kubectl rollout restart deployment migration-controller-manager -n migration-system -
Trigger a new migration for the envs to be reflected in the pod
Trigger via UI or via api.