question

UdayKiranReddyureddy-2664 avatar image
0 Votes"
UdayKiranReddyureddy-2664 asked shivapatpi-MSFT answered

Front slash not working in image name for kubernetes, how to use this?

We have an azure container registry where the imagename is in this format.

image: <acr_name>//:

Earlier with only <acr_name>/: it worked.

But with /<branch_name> added, I am getting error as

 NAME                           READY   STATUS             RESTARTS   AGE
 frontend-7c96f879c5-45nsx      1/2     InvalidImageName   0          9m5s

How to use this now in kubernetes environment?

The image is there in the acr.

161272-ssss.png


azure-kubernetes-serviceazure-container-registry
ssss.png (4.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered UdayKiranReddyureddy-2664 commented

Hello @UdayKiranReddyureddy-2664 ,
I just tried with below sample image format in ACR and it went through successfully
kubectl run httpd --image=acrrepositoryname.azurecr.io/server/httpd:2.4

161335-image.png


161276-image.png


161344-image.png




Let me know if that helps !

Regards,
Shiva.


image.png (19.8 KiB)
image.png (41.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

it seems the issue is with case of image name.
I have kept $(Build.SourceBranchName) during the image creation in azure devops.
ACR is converting to lowercase to save.

But, during deployment, it used the original name with capital letters and getting this error, now I checked in pod description.
invalid reference format: repository name must be lowercase

Is there any way you suggest to get the lowercase version there?

Or in the yaml file of kubernetes to read as lowercase?

I am trying the below code but it is not working in pipeline.

 $branchname=$(echo $(Build.SourceBranchName) | tr '[:upper:]' '[:lower:]')



 /home/vsts/work/_temp/19a1b6fa-920a-4cfc-b70d-1da559ac17f9.sh: line 1: =cloudlayer1_azuredevopstesting: command not found
 ##[error]Bash wrote one or more lines to the standard error stream.
 ##[error]/home/vsts/work/_temp/19a1b6fa-920a-4cfc-b70d-1da559ac17f9.sh: line 1: =cloudlayer1_azuredevopstesting: command not found



0 Votes 0 ·
shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered

For the latest issue in Devops variable , can you try to use lower function to convert the variable value to all lowercase
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#lower

Check out the below articles if that helps:
https://stackoverflow.com/questions/58268287/how-to-lowercase-azure-devops-pipeline-variables-names

If the lower function is not working for you , if you are using some dependent variables , try the alternative options mentioned here:
https://stackoverflow.com/questions/63669006/lower-function-does-not-seem-to-work-in-azure-devops-yaml-pipeline

Regards,
Shiva.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.