I build and push docker image into JFrog Artifactory by using Azure DevOps build pipeline. And then using the below yaml file to deploy the image into Azure AKS environment using Kubectl task in the release definition.
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: webapplication-jfrog-deployment
name: webapplication-jfrog-deployment
spec:
replicas: 2
selector:
matchLabels:
app: webapplication-jfrog
template:
metadata:
labels:
app: webapplication-jfrog
spec:
containers:
-
image: #{JFrog_Login_Server_Name}#/webapplication:#{Version}#
imagePullPolicy: Always
name: webapplication-jfrog
ports:
-
containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: webapplication-jfrog-service
spec:
ports:
-
port: 80
selector:
app: webapplication-jfrog
type: LoadBalancer
After deploying the above yaml file, I am getting the below error in the pods:
Failed to pull image "xxxx-poc.jfrog.io/webapplication:xx": rpc error: code = Unknown desc = Error response from daemon: Get https://xxxx-poc.jfrog.io/v2/webapplication/manifests/xx: unknown: Authentication is required
This error occurred might be the authentication issue, while pulling the image from JFrog Artifactory into Azure AKS environment.
So, can anyone suggest me how to deploy the image from JFrog Artifactory into Azure Kubernetes service.
For any private registry, you need to create a docker-registry
secret and specify that when pulling images using imagePullSecrets
.
kubectl create secret docker-registry artifactorycred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
apiVersion: v1
kind: Pod
metadata:
name: private-reg
spec:
containers:
- name: private-reg-container
image: <your-private-image>
imagePullSecrets:
- name: artifactorycred
See the following document for more details: