Wait for OCI CLI and Fn CLI to be installed
You need to provide details on the OCI tenancy you will work in and the OCI user you will work as. Please edit these two files:
Paste the contents provided by the workshop instructor into these two files.
Do not continue until you see the file
/root/allSetInBackground appear. If it appears, then the OCI CLI has been installed and you can continue.
Try out the following command to get a list of all namespaces you currently have access to - based on the OCI Configuration defined above.
oci os ns get
If you get a proper response, the OCI is configured correctly and you can proceed. If you run into an error, ask for help from your instructor.
Fn Client and Context
Now Check the installed version of Fn CLI. Note: we do not need the Fn server at this stage.
Configure and set remote context
List the currently available Fn contexts
fn list contexts
Create an appropriate Fn context for working with OCI as provider (see OCI Docs on Functions).
fn create context lab-fn-context --provider oracle
fn use context lab-fn-context
Prepare a number of environment variables. Note: the assumptions here are a compartment called lab-compartment, a VCN called vcn-lab and a subnet in that VCN called Public Subnet-vcn-lab. We need to get references to these three resources in order to create Functions and Applications in the right place.
cs=$(oci iam compartment list) export compartmentId=$(echo $cs | jq -r --arg display_name "lab-compartment" '.data | map(select(."name" == $display_name)) | . | .id') vcns=$(oci network vcn list -c $compartmentId) vcnId=$(echo $vcns | jq -r --arg display_name "vcn-lab" '.data | map(select(."display-name" == $display_name)) | . | .id') subnets=$(oci network subnet list -c $compartmentId --vcn-id $vcnId) export subnetId=$(echo $subnets | jq -r --arg display_name "Public Subnet-vcn-lab" '.data | map(select(."display-name" == $display_name)) | . | .id') nss=$(oci os ns get) export ns=$(echo $nss | jq -r '.data')
Update the fn context with the settings relevant for this workshop. Note: the compartment used here is the lab-compartment
fn update context oracle.compartment-id $compartmentId fn update context api-url https://functions.us-ashburn-1.oci.oraclecloud.com r=$(fn update context registry iad.ocir.io/$ns/cloudlab-repo) fn update context oracle.profile FN
You can list the currently available Fn contexts again and see whether your changes had an effect (of course they did)
fn list contexts
Next and finally, login to the private Docker Registry that is prepared for you on OCI.
docker login iad.ocir.io
The username you have to provide is composed of
<tenancy-namespace>/<username>. The password is an Authentication Token generated for the specified user. Both these values are provided by your workshop instructor.
And now we are finally ready to create functions and deploy them to the Oracle Cloud Infrastructure instead of to the locally running Fn Server.