Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,29 @@ writeCredentialProviderConfig() {
done
fi

if [ -n "$AKS_CUSTOM_CLOUD_CONTAINER_REGISTRY_DNS_SUFFIX" ]; then
if [ -n "$AKS_CUSTOM_CLOUD_CONTAINER_REGISTRY_DNS_SUFFIX" ] && [ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]; then
echo "configure credential provider for custom cloud network isolated cluster"
MCR_REPOSITORY_BASE="${MCR_REPOSITORY_BASE:=mcr.microsoft.com}"
MCR_REPOSITORY_BASE="${MCR_REPOSITORY_BASE%/}"
tee "${config_file_path}" > /dev/null <<EOF
apiVersion: kubelet.config.k8s.io/v1
kind: CredentialProviderConfig
providers:
- name: acr-credential-provider
matchImages:
- "*.azurecr.io"
- "*.azurecr.cn"
- "*.azurecr.de"
- "*.azurecr.us"
- "*$AKS_CUSTOM_CLOUD_CONTAINER_REGISTRY_DNS_SUFFIX"
- "${MCR_REPOSITORY_BASE}"
defaultCacheDuration: "10m"
apiVersion: credentialprovider.kubelet.k8s.io/v1${ib_token_attributes}
args:
- /etc/kubernetes/azure.json
- --registry-mirror=${MCR_REPOSITORY_BASE}:$BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER${ib_args}
EOF
elif [ -n "$AKS_CUSTOM_CLOUD_CONTAINER_REGISTRY_DNS_SUFFIX" ]; then
echo "configure credential provider for custom cloud"
tee "${config_file_path}" > /dev/null <<EOF
apiVersion: kubelet.config.k8s.io/v1
Expand Down
24 changes: 24 additions & 0 deletions spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,30 @@ providers:
The contents of file "$TMP_DIR/credential-provider-config.yaml" should equal "$expected_config"
End

It 'should configure credential provider for custom cloud network isolated cluster'
AKS_CUSTOM_CLOUD_CONTAINER_REGISTRY_DNS_SUFFIX=".custom.registry.io"
BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER="test.azurecr.io"
expected_config='apiVersion: kubelet.config.k8s.io/v1
kind: CredentialProviderConfig
providers:
- name: acr-credential-provider
matchImages:
- "*.azurecr.io"
- "*.azurecr.cn"
- "*.azurecr.de"
- "*.azurecr.us"
- "*.custom.registry.io"
- "mcr.microsoft.com"
defaultCacheDuration: "10m"
apiVersion: credentialprovider.kubelet.k8s.io/v1
args:
- /etc/kubernetes/azure.json
- --registry-mirror=mcr.microsoft.com:test.azurecr.io'
When call writeCredentialProviderConfig "$TMP_DIR/credential-provider-config.yaml"
The output should include "configure credential provider for custom cloud network isolated cluster"
The contents of file "$TMP_DIR/credential-provider-config.yaml" should equal "$expected_config"
End

It 'should configure credential provider with identity binding enabled and all args'
SERVICE_ACCOUNT_IMAGE_PULL_ENABLED="true"
IDENTITY_BINDINGS_LOCAL_AUTHORITY_SNI="test.sni.local"
Expand Down
Loading