Skip to content

Commit 8ff4f56

Browse files
committed
Optional imagePullSecret
1 parent b34bd34 commit 8ff4f56

File tree

6 files changed

+64
-6
lines changed

6 files changed

+64
-6
lines changed

INSTALLATION.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ Confirm that your `kubectl` is configured to use your AKS cluster by running `ku
6464

6565
To pull container images during installation and upgrades, your Azure tenant must be able to pull images from Cleanlab's container registry.
6666

67-
To do this, follow the instructions [here](https://learn.microsoft.com/en-us/azure/container-registry/authenticate-aks-cross-tenant) as Tenant A (steps 1 and 4). After step 1, ensure that you send your application client ID to Cleanlab to enable us to grant the necessary registry permissions.
67+
To do this, follow the instructions [here](https://learn.microsoft.com/en-us/azure/container-registry/authenticate-aks-cross-tenant) as Tenant A. Only do step 1. After step 1, ensure that you send your application client ID to Cleanlab to enable us to grant the necessary registry permissions.
68+
69+
Ensure you save the service principal ID and password for later use.
6870

6971
#### Configuring model access
7072

@@ -96,13 +98,10 @@ Run through the following scripts to install the TLM app:
9698
```
9799
./scripts/aks/0_prerequisites.sh
98100
./scripts/aks/1_secrets.sh
99-
./scripts/aks/2_app.sh
101+
./scripts/aks/2_registry.sh
102+
./scripts/aks/3_app.sh
100103
```
101104

102-
Things to note:
103-
- To allow the TLM to access models and provide it with other secrets, you must go through the Azure Key Vault secret flow
104-
- You only need to do this once per installation (or when you want to update the secrets)
105-
106105
### Upgrading the TLM app
107106

108107
To upgrade the TLM app, you can run the following command:

deploy/helm/tlm/templates/chat/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ spec:
6161
port: {{ .Values.chat_backend.container.port }}
6262
resources:
6363
{{- toYaml .Values.chat_backend.resources | nindent 12 }}
64+
{{- if .Values.imagePullSecret.enabled }}
65+
imagePullSecrets:
66+
- name: {{ .Values.imagePullSecret.name }}
67+
{{- end }}

deploy/helm/tlm/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
replicaCount: 1
66

7+
imagePullSecret:
8+
enabled: false
9+
name: ""
10+
711
chat_backend:
812
master_api_key: ""
913

scripts/aks/2_registry.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
3+
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
5+
. "$BASEDIR/../utils/registry.sh"
6+
. "$BASEDIR/../utils/prompt.sh"
7+
8+
print_header "2. Setting up registry login credentials"
9+
10+
read -p "Enter the service principal ID: " service_principal_id
11+
read -sp "Enter the service principal password: " service_principal_password
12+
13+
create_registry_secret $service_principal_id $service_principal_password
14+
15+
echo "Registry login credentials setup successfully"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ flags="$flags --set image.repository=cleanlabtlm.azurecr.io/tlm/chat-backend"
2323
api_key=$(openssl rand -base64 16)
2424
flags="$flags --set chat_backend.master_api_key=$api_key"
2525

26+
# Check if registry secret exists
27+
if check_registry_secret_exists; then
28+
flags="$flags --set imagePullSecret.enabled=true --set imagePullSecret.name=$REGISTRY_CREDENTIALS_SECRET_NAME"
29+
else
30+
echo "Registry secret does not exist. Skipping image pull secret setup."
31+
fi
32+
2633
# Login to Azure Container Registry
2734
USERNAME="00000000-0000-0000-0000-000000000000"
2835
az acr login --name cleanlabtlm --expose-token --output tsv --query accessToken | \

scripts/utils/registry.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/bash
2+
3+
set -e # Exit immediately if any command fails
4+
set -u # Treat unset variables as errors
5+
set -o pipefail # Ensure pipeline failures are caught
6+
7+
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
9+
. "$BASEDIR/../utils/kubernetes.sh"
10+
11+
REGISTRY_NAME="cleanlabtlm"
12+
REGISTRY_CREDENTIALS_SECRET_NAME="$REGISTRY_NAME-login-credentials"
13+
14+
15+
function create_registry_secret() {
16+
service_principal_id=$1
17+
service_principal_password=$2
18+
19+
kubectl create secret docker-registry $REGISTRY_CREDENTIALS_SECRET_NAME \
20+
--namespace $TLM_NAMESPACE \
21+
--docker-server=$REGISTRY_NAME.azurecr.io \
22+
--docker-username=$service_principal_id \
23+
--docker-password=$service_principal_password
24+
}
25+
26+
27+
function check_registry_secret_exists() {
28+
kubectl get secret $REGISTRY_CREDENTIALS_SECRET_NAME --namespace $NAMESPACE &> /dev/null
29+
}

0 commit comments

Comments
 (0)