Skip to main content

Connect ArgoCD deployment to image

This guide aims to demonstrate how to connect an ArgoCD deployment to an image blueprint in Port. By linking your ArgoCD deployment to a specific container image, you gain visibility into the images used by each ArgoCD application.

Prerequisites

  1. Create an ArgoCD deployment blueprint to represent a deployment:
ArgoCD deployment blueprint (click to expand)
{
"identifier": "argocdDeployment",
"description": "This blueprint represents an ArgoCD deployment",
"title": "ArgoCD Deployment",
"icon": "Argo",
"schema": {
"properties": {},
"required": []
},
"mirrorProperties": {
"health_status": {
"title": "Health Status",
"path": "application.healthStatus"
},
"sync_status": {
"title": "Sync Status",
"path": "application.syncStatus"
}
},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"image": {
"title": "Deployed Image",
"target": "image",
"required": false,
"many": false
},
"application": {
"title": "Application",
"target": "argocdApplication",
"required": false,
"many": false
}
}
}
  1. Add a new managed-resource kind to the ArgoCD integration to map the deployment to the image entities using the following YAML block. Then click Save & Resync:
ArgoCD managed resources configuration (click to expand)
  - kind: managed-resource
selector:
query: .kind == "Deployment"
port:
entity:
mappings:
identifier: .name
title: .name
blueprint: '"argocdDeployment"'
properties: {}
relations:
image: .liveState | fromjson | .spec.template.spec.containers[0].image
application: .__application.uid

Configuration details

The managed-resource kind contains information about all the kubernetes resources managed by the ArgoCD application. The configuration above uses the selector.query property to filter all kubernetes deployment resources. It then uses the jq code .liveState | fromjson | .spec.template.spec.containers[0].image to parse the liveState property of the managed resources and extract the container image attached to the deployment. It finally links each deployment to the ArgoCD application using the .__application metadata object, and in this case, the uid.

Below is an example showing a successful linkage of ArgoCD deployment to image:

More relevant guides and examples​