Box 1: DeploymentTo deploy Azure Functions to Kubernetes use the func kubernetes deploy command has several attributes that directly control how our app scales, once it is deployed to Kubernetes. Box 2: ScaledObjectWith --polling-interval, we can control the interval used by KEDA to check Azure Service Bus Queue for messages. Example of ScaledObject with polling interval apiVersion: keda.k8s.io/v1alpha1kind: ScaledObjectmetadata: name: transformer-fn namespace: tt labels: deploymentName: transformer-fnspec: scaleTargetRef: deploymentName: transformer-fn pollingInterval: 5 minReplicaCount: 0 maxReplicaCount: 100Box 3: SecretStore connection strings in Kubernetes Secrets. Example: to create the Secret in our demo Namespace:# create the k8s demo namespace kubectl create namespace tt # grab connection string from Azure Service Bus KEDA_SCALER_CONNECTION_STRING=$(az servicebus queue authorization-rule keys list \ -g $RG_NAME \ --namespace-name $SBN_NAME \ --queue-name inbound \ -n keda-scaler \ --query "primaryConnectionString" \ -o tsv) # create the kubernetes secret kubectl create secret generic tt-keda-auth \ --from-literal KedaScaler=$KEDA_SCALER_CONNECTION_STRING \ --namespace tt Reference:https://www.thinktecture.com/en/kubernetes/serverless-workloads-with-keda/
Box 1: Deployment
To deploy Azure Functions to Kubernetes use the func kubernetes deploy command has several attributes that directly control how our app scales, once it is deployed to Kubernetes.
Box 2: ScaledObject
With --polling-interval, we can control the interval used by KEDA to check Azure Service Bus Queue for messages.
Example of ScaledObject with polling interval
apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
name: transformer-fn
namespace: tt
labels:
deploymentName: transformer-fn
spec:
scaleTargetRef:
deploymentName: transformer-fn
pollingInterval: 5
minReplicaCount: 0
maxReplicaCount: 100
Box 3: Secret
Store connection strings in Kubernetes Secrets.
Example: to create the Secret in our demo Namespace:
# create the k8s demo namespace
kubectl create namespace tt
# grab connection string from Azure Service Bus
KEDA_SCALER_CONNECTION_STRING=$(az servicebus queue authorization-rule keys list \
-g $RG_NAME \
--namespace-name $SBN_NAME \
--queue-name inbound \
-n keda-scaler \
--query "primaryConnectionString" \
-o tsv)
# create the kubernetes secret
kubectl create secret generic tt-keda-auth \
--from-literal KedaScaler=$KEDA_SCALER_CONNECTION_STRING \
--namespace tt
Reference:
https://www.thinktecture.com/en/kubernetes/serverless-workloads-with-keda/