Skip to content

Commit 780ac21

Browse files
authored
feat: support providers with self-signed certificates (#109)
- Updated the operator's CRD to allow the definition of a configMap containing ca-cert data, by configuring fields in a LlamaStackDistribution CR. - Configured llama-stack to trust connections to providers like vLLM using server certificates from that Certificate Authority. - Added an example script to generate generic self-signed certificates in PEM format to use with vLLM. - Added an example configuration file to load the self-signed certs into a secret, mount the secret into the container, and point vLLM to the certs on server startup. Approved-by: VaishnaviHire
1 parent 669f3e4 commit 780ac21

15 files changed

+2105
-136
lines changed

api/v1alpha1/llamastackdistribution_types.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/llamastack.io_llamastackdistributions.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,35 @@ spec:
20012001
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
20022002
x-kubernetes-int-or-string: true
20032003
type: object
2004+
tlsConfig:
2005+
description: TLSConfig defines the TLS configuration for the llama-stack
2006+
server
2007+
properties:
2008+
caBundle:
2009+
description: CABundle defines the CA bundle configuration
2010+
for custom certificates
2011+
properties:
2012+
configMapKeys:
2013+
description: |-
2014+
ConfigMapKeys specifies multiple keys within the ConfigMap containing CA bundle data
2015+
All certificates from these keys will be concatenated into a single CA bundle file
2016+
If not specified, defaults to [DefaultCABundleKey]
2017+
items:
2018+
type: string
2019+
maxItems: 50
2020+
type: array
2021+
configMapName:
2022+
description: ConfigMapName is the name of the ConfigMap
2023+
containing CA bundle certificates
2024+
type: string
2025+
configMapNamespace:
2026+
description: ConfigMapNamespace is the namespace of the
2027+
ConfigMap (defaults to the same namespace as the CR)
2028+
type: string
2029+
required:
2030+
- configMapName
2031+
type: object
2032+
type: object
20042033
userConfig:
20052034
description: UserConfig defines the user configuration for the
20062035
llama-stack server
@@ -2170,6 +2199,8 @@ spec:
21702199
selectableFields:
21712200
- jsonPath: .spec.server.userConfig.configMapName
21722201
- jsonPath: .spec.server.userConfig.configMapNamespace
2202+
- jsonPath: .spec.server.tlsConfig.caBundle.configMapName
2203+
- jsonPath: .spec.server.tlsConfig.caBundle.configMapNamespace
21732204
served: true
21742205
storage: true
21752206
subresources:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: llama-stack-config
5+
data:
6+
run.yaml: |
7+
# Llama Stack Configuration
8+
version: '2'
9+
image_name: remote-vllm
10+
apis:
11+
- inference
12+
providers:
13+
inference:
14+
- provider_id: vllm
15+
provider_type: "remote::vllm"
16+
config:
17+
url: "https://vllm-server.vllm-dist.svc.cluster.local:8000/v1"
18+
models:
19+
- model_id: "meta-llama/Llama-3.2-1B-Instruct"
20+
provider_id: vllm
21+
model_type: llm
22+
server:
23+
port: 8321
24+
---
25+
apiVersion: llamastack.io/v1alpha1
26+
kind: LlamaStackDistribution
27+
metadata:
28+
name: llamastack-with-config
29+
spec:
30+
replicas: 1
31+
server:
32+
distribution:
33+
name: remote-vllm
34+
containerSpec:
35+
port: 8321
36+
env:
37+
- name: INFERENCE_MODEL
38+
value: "meta-llama/Llama-3.2-1B-Instruct"
39+
- name: VLLM_URL
40+
value: "https://vllm-server.vllm-dist.svc.cluster.local:8000/v1"
41+
- name: VLLM_TLS_VERIFY
42+
value: "/etc/ssl/certs/ca-bundle.crt"
43+
userConfig:
44+
configMapName: llama-stack-config
45+
# configMapNamespace: "" # Optional - defaults to the same namespace as the CR
46+
tlsConfig:
47+
caBundle:
48+
configMapName: custom-ca-bundle
49+
# configMapNamespace: "" # Optional - defaults to the same namespace as the CR
50+
# configMapKeys not specified - defaults to ["ca-bundle.crt"]
51+
# configMapKeys: # Specify multiple keys to concatenate into ca-bundle.crt
52+
# - ca-bundle1.crt
53+
# - ca-bundle2.crt
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# --- Configuration ---
4+
5+
# CA Details
6+
CA_KEY="ca.key"
7+
CA_CERT="ca.crt"
8+
CA_SUBJECT="/C=US/ST=California/L=Los Angeles/O=Demo Corp/OU=OpenShift CA/CN=example-ca"
9+
10+
# Security Configuration
11+
KEY_SIZE=4096
12+
CA_VALIDITY_DAYS=365
13+
14+
echo "================================================"
15+
echo "WARNING: This script is for TESTING PURPOSES ONLY"
16+
echo "Do NOT use these certificates in production!"
17+
echo "================================================"
18+
echo
19+
20+
# --- 1. Create the Certificate Authority (CA) ---
21+
22+
echo "Generating CA private key and self-signed certificate..."
23+
24+
# Generate the CA's private key with stronger key size
25+
openssl genrsa -out "${CA_KEY}" ${KEY_SIZE}
26+
27+
# Generate the self-signed CA certificate
28+
openssl req -x509 -new -nodes -key "${CA_KEY}" \
29+
-sha256 -days ${CA_VALIDITY_DAYS} \
30+
-subj "${CA_SUBJECT}" \
31+
-out "${CA_CERT}"
32+
33+
echo "CA created successfully: ${CA_KEY}, ${CA_CERT}"
34+
35+
36+
echo " All files created successfully!"
37+
echo "------------------------------------"
38+
echo " - CA Private Key: ${CA_KEY} (${KEY_SIZE}-bit)"
39+
echo " - CA Certificate: ${CA_CERT} (valid for ${CA_VALIDITY_DAYS} days)"
40+
echo "------------------------------------"
41+
echo
42+
echo "Security Reminders:"
43+
echo "- Keep private keys secure and never commit them to version control"
44+
echo "- Consider using cert-manager for production certificate management"
45+
echo "- Rotate certificates regularly in production environments"
46+
47+
48+
# Get the directory where this script is located
49+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
50+
51+
mkdir -p "${SCRIPT_DIR}/vllm-ca-certs"
52+
53+
# Move to a mock CA bundle file
54+
cp "${CA_CERT}" "${SCRIPT_DIR}/vllm-ca-certs/ca-bundle.crt"

config/samples/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ kind: Kustomization
44
## Append samples you want in your CSV to this file as resources ##
55
resources:
66
- _v1alpha1_llamastackdistribution.yaml
7+
- example-with-configmap.yaml
8+
- example-with-ca-bundle.yaml

0 commit comments

Comments
 (0)