HiveBrain v1.2.0
Get Started
← Back to all entries
patternkubernetesMinor

What is the way to update images in a configuration git repository when doing gitops?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
theupdatewhatwaydoinggitrepositorywhenimagesconfiguration

Problem

i'm trying to do gitops

I have a Configuration repo containing k8 manifests and different app repos.

1) App repo's CI build docker images and pushes into registry.

2) App repo's CI commits into Configuration repo with newly built image tags.

A gitops CD like ArgoCD is listening to configuration repo and deploys(manual/automatic) it to kubernetes.

Is this the right way to do it ?

Solution


  • App repo's CI commits into Configuration repo with newly built image tags.



Yes, this makes sense. Instead of using image tags you can use image digest, since the digest is generated from content, it is immutable, while tags may be updated (intentionally or unintentionally).

This manifest update can be done with multiple tools:

Using yq

yq write \
  --inplace deployment.yaml \
  'spec.template.spec.containers(name==myappname).image' \
  gcr.io/my-image-repository/myappname:labelOrDigest


Or using a newer tool; kpt with the kpt set command.

Code Snippets

yq write \
  --inplace deployment.yaml \
  'spec.template.spec.containers(name==myappname).image' \
  gcr.io/my-image-repository/myappname:labelOrDigest

Context

StackExchange DevOps Q#11574, answer score: 3

Revisions (0)

No revisions yet.