Install - .NET Agent on a Containerized App running a Linux image using Sidecars


Installation Wizard

To help with the installation process, vFunction offers an Installation Wizard. This Wizard provides additional information about the Prerequisites as well as the Required and Optional Settings for installing the vFunction Server and Agents. This Wizard also walks you through each step in the Installation process.


Overview

Docker Sidecars can be used for the vFunction Controller installation to separate the vFunction components from the main application so that each component is running in a separate Container.

The vFunction Docker Sidecar Installation does the following:

  1. In the Build process of the Init Container, move the vFunction Controller Installation TGZ onto the Container
  2. In the Build process of the Init Container, unpack the vFunction Controller TGZ and install the Agent to the /shared/ directory
  3. In a confipMap, add the vFunction Agent parameters as environmental variables
  4. In the Deployment Manifest, create a Shared Volume accessible by the Init and Application Containers
  5. In the Deployment Manifest, add the Environment Variables to the Application Container

Configuring the Init Container

  1. Download the latest vFunction Sudoless Controller Installation TGZ
  2. Create a folder for vFunction artifacts in the Artifact Repository accessible by the Docker Build
  3. Add the vFunction Sudoless Controller Installation TGZ to the Artifact Repository
  4. Create a vFunction specific branch to add the vFunction artificats to the Init Container’s Dockerfile
  5. Download or create the Init Container’s Dockerfile
FROM almalinux:9          

### Add the User to this Container that Runs the Application on the Application Container
RUN adduser -l -u "APP_ID" "APP_USER"

############ vFunction COPY workflow ############

### Find-and-replace ARTIFACT_REPOSITORY with the actual location
COPY /ARTIFACT_REPOSITORY/vfunction/vfunction-controller-sudo-less-installation*.tgz /shared/vfunction-controller-sudo-less-installation.tgz

############ vFunction Environment Variables ############

### Modify the value to be this Application's Identifier for the VF Server UI, e.g. qa-container
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_NAME=CHANGE_ME

### Modify the value to be the URL of the vFunction Server
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_HOST=CHANGE_ME

### Gather this value from the vFunction Server UI's Learning > Select Controllers > Installation Instructions
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_ORG_ID=CHANGE_ME

### Gather this value from the vFunction Server UI's Learning > Select Controllers > Installation Instructions
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_APP_ID=CHANGE_ME

### Gather this value from the vFunction Server UI's Learning > Select Controllers > Installation Instructions
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_CLIENT_ID=CHANGE_ME

### Gather this value from the vFunction Server UI's Learning > Select Controllers > Installation Instructions
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_CLIENT_SECRET=CHANGE_ME

### Use a unique string for this value, e.g. Containerized, to help the vFunction Server manage when this Container goes up and down
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_INSTANCE_ID=CHANGE_ME

### Use Tags to organize Agents by functionality, environment or other logical groupings
ENV VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_TAGS="CHANGE_ME,CHANGE_ME"

############ vFunction RUN workflow ############

RUN cd /shared && tar -xvzf ./vfunction-controller-sudo-less-installation.tgz      && \
 rm -rf /shared/vfunction-controller-sudo-less-installation.tgz  && \
 bash /shared/vfunction/opt/vfunction/controller-installation/install.sh -i default-dotnet -n && \
 chmod -R 777 /shared/vfunction   && \
 ### Replace APP_USER:APP_GROUP with the user and user's group that runs the Application
 chown -R APP_USER:APP_GROUP /shared/vfunction                                             

### Replace USER_ID with the user that runs the Application
USER USER_ID

ENTRYPOINT ["/bin/sh"]
CMD ["sleep 5"]
  1. Build the Init Dockerfile

Create the configMap with vFunction Agent Environment Variables

  1. Download or create the vf-agent-env-vars.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: vf-agent-env-vars
data:
  VF_AGENT_CONF_LOCATION: "/shared/vfunction/etc/sysconfig/vfunction/agent/instances/default-dotnet/conf.json"
  CORECLR_PROFILER_PATH_64: "/shared/vfunction/opt/vfunction/agent/libvfagent.net.so"
  CORECLR_ENABLE_PROFILING: "1"
  DOTNET_TailCallOpt: "0"
  1. Apply the configMap to the Cluster
kubectl apply -f vf-agent-env-vars.yaml

Configuring the Deployment Manifest

  1. Download or copy-and-paste, then modify the manifest for the environment to ensure that the Volumes are created and accessible for each Container
apiVersion: apps/v1
kind: Deployment
metadata:
 name: application-with-vfunction
 namespace: vfunction
 labels:
   app: application-with-vfunction
spec:
 replicas: 1
 selector:
   matchLabels:
     app: application-with-vfunction
 template:
   metadata:
   labels:
     app: application-with-vfunction
   spec:
     initContainers:
     ### Replace INIT_IMAGE with the name of the Built Init Container Image
     - image: INIT_IMAGE
       imagePullPolicy: IfNotPresent
       name: init
       securityContext:
         runAsNonRoot: true
         ### Replace USER_ID with the user who runs the Application in the Application Container
         runAsUser: USER_ID
       volumeMounts:
       - mountPath: /shared/
         name: shared
     containers:
     - name: application
       ### Replace APPLICATION_IMAGE with the name of the Built Init Container Image
       image: APPLICATION_IMAGE
       env:
       - name: CORECLR_ENABLE_PROFILING
         valueFrom:
           configMapKeyRef:
             name: vf-agent-env-vars
             key: CORECLR_ENABLE_PROFILING
       - name: CORECLR_PROFILER
         valueFrom:
           configMapKeyRef:
             name: vf-agent-env-vars
             key: CORECLR_PROFILER
       - name: CORECLR_PROFILER_PATH_64
         valueFrom:
           configMapKeyRef:
             name: vf-agent-env-vars
             key: CORECLR_PROFILER_PATH_64
       - name: DOTNET_TailCallOpt
         valueFrom:
           configMapKeyRef:
             name: vf-agent-env-vars
             key: DOTNET_TailCallOpt
       - name: VF_AGENT_CONF_LOCATION
         valueFrom:
           configMapKeyRef:
             name: vf-agent-env-vars
             key: VF_AGENT_CONF_LOCATION
       imagePullPolicy: Always
       ports:
       - containerPort: 8080
         protocol: TCP
       securityContext:
         runAsNonRoot: true
         ### Replace USER_ID with the user who runs the Application in the Application Container
         runAsUser: USER_ID
       volumeMounts:
       - mountPath: /shared/
         name: shared
     volumes:
     - emptyDir: {}
       name: shared
  1. Apply the Deployment Manifest to the Cluster

Deploy the Application and vFunction Init Container

  1. Apply the Deployment Manifest in the Cluster
  2. Confirm that the Application comes up and functions as expected
  3. If any issues arise: