Skip to content

Files

Latest commit

 

History

History
107 lines (88 loc) · 2.35 KB

deploytoK8s.md

File metadata and controls

107 lines (88 loc) · 2.35 KB

Deploy to Kubernetes

This guide will help you deploy your application to Kubernetes using Secrets, Services, and Deployments.

Step 1: Create Secret

First, create a Secret to store sensitive information such as CLIENT_ID and CLIENT_SECRET.

# Generated by Copilot
apiVersion: v1
kind: Secret
metadata:
  name: function-calling-extension-secret
type: Opaque
data:
  # Base64 encoded CLIENT_ID
  CLIENT_ID: {yourbase64Client_ID}
  # Base64 encoded CLIENT_SECRET
  CLIENT_SECRET: {yourbase64Client_SECRET}

Apply the Secret using the following command:

kubectl apply -f secret.yaml

Step 2: Create Service

Next, create a Service to expose your application.

# Generated by Copilot
apiVersion: v1
kind: Service
metadata:
  name: function-calling-extension-service
spec:
  type: LoadBalancer
  selector:
    app: function-calling-extension
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

Apply the Service using the following command:

kubectl apply -f service.yaml

Step 3: Create Deployment

Finally, create a Deployment to manage your application's pods.

# Generated by Copilot
apiVersion: apps/v1
kind: Deployment
metadata:
  name: function-calling-extension-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: function-calling-extension
  template:
    metadata:
      labels:
        app: function-calling-extension
    spec:
      containers:
      - name: function-calling-extension
        image: copilotx.azurecr.io/copilot/extensions/function-calling-extension:20241226
        ports:
        - containerPort: 8080
        env:
        - name: PORT
          value: "8080"
        - name: CLIENT_ID
          valueFrom:
            secretKeyRef:
              name: function-calling-extension-secret
              key: CLIENT_ID
        - name: CLIENT_SECRET
          valueFrom:
            secretKeyRef:
              name: function-calling-extension-secret
              key: CLIENT_SECRET
        - name: FQDN
          value: "http://<public-ip-address>"

Apply the Deployment using the following command:

kubectl apply -f deployment.yaml

Notes

  • Ensure that the CLIENT_ID and CLIENT_SECRET values in the Secret are Base64 encoded.
  • Replace <public-ip-address> in the Deployment YAML with the actual public IP address of the Service once it is available.