Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic App Discovery and Image Updates #2118

Closed
pieterv-icloud-com opened this issue Sep 18, 2023 · 8 comments
Closed

Automatic App Discovery and Image Updates #2118

pieterv-icloud-com opened this issue Sep 18, 2023 · 8 comments
Labels
question Further information is requested

Comments

@pieterv-icloud-com
Copy link

We use the ArgoCD Image Updater to automatically update container images from a container registry.

In v0.8.1 the toolkit would pick these changes up and create the keptn objects in the cluster. This kind of worked but had some issues as I reported here.

I tried to test this functionality with v0.8.2, but it does not appear to be working at all.

Any plans to reintroduce this?

@odubajDT
Copy link
Contributor

Hello @pieterv-icloud-com, thank you for the issue! We are not aware that any functionality was removed in 0.8.2, can you please describe your use-case in more details? Hopefully afterwards we will be able to support you

@RealAnna RealAnna added help wanted Extra attention is needed question Further information is requested and removed help wanted Extra attention is needed labels Sep 18, 2023
@pieterv-icloud-com
Copy link
Author

pieterv-icloud-com commented Sep 18, 2023

Hi in my test case I create a ArgoCD Application as follows:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    argocd-image-updater.argoproj.io/container.platforms: linux/amd64,linux/arm64
    argocd-image-updater.argoproj.io/container.update-strategy: semver
    argocd-image-updater.argoproj.io/dex.helm.image-name: container.image.repository
    argocd-image-updater.argoproj.io/dex.helm.image-tag: container.image.tag
    argocd-image-updater.argoproj.io/image-list: container=localhost:5000/node-web-app
    argocd-image-updater.argoproj.io/write-back-method: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
  name: node-web-app
  namespace: argocd
spec:
  project: klt-project
  destination:
    namespace: myapp
    server: https://kubernetes.default.svc
  source:
    path: charts/generic
    repoURL: https://gitlab.com/klt.git
    targetRevision: HEAD
    helm:
      releaseName: node-web-app
      valueFiles:
        - ../../environments/overlays/base/node-web-app-values.yaml
  syncPolicy:
    automated:
      selfHeal: true
    managedNamespaceMetadata:
      annotations:
        keptn.sh/lifecycle-toolkit: enabled      
    syncOptions:
      - CreateNamespace=true
    retry:
      limit: -1
  ignoreDifferences:
    - group: apps
      kind: Deployment
      jsonPointers:
        - /spec/replicas
    - group: autoscaling
      kind: HorizontalPodAutoscaler
      jsonPointers:
        - /spec/metrics

With the image updater annotations the ArgoCD Imatge Updater will scan the container registry and determine if any new images are published to the localhost:5000/node-web-app registry.

The image would typically be in the format: localhost:5000/node-web-app:0.1.28

Which is the name of the workload and the tag is the version of the workload.

If a new image is detected the ArgoCD Application will be updated with the new container image

The problem is that this is not detected by the current version of the toolkit.

Let me know if you require additional information

@odubajDT
Copy link
Contributor

Thank you for the info, you do please have also the following annotation in your Deployment?

app.kubernetes.io/version or keptn.sh/version

if yes, does the image-updater bump also the version in the annotation?

If it's possible, it would help us if you can show us the Deployment that is applied to the cluster

@pieterv-icloud-com
Copy link
Author

Here is the deployment:

Name:                   node-web-app
Namespace:              myapp
CreationTimestamp:      Mon, 18 Sep 2023 09:39:55 +0000
Labels:                 [app.kubernetes.io/instance=node-web-app](http://app.kubernetes.io/instance=node-web-app)
                        [app.kubernetes.io/managed-by=Helm](http://app.kubernetes.io/managed-by=Helm)
                        [app.kubernetes.io/name=node-web-app](http://app.kubernetes.io/name=node-web-app)
                        [app.kubernetes.io/part-of=myapp](http://app.kubernetes.io/part-of=myapp)
                        [app.kubernetes.io/version=0.1.20](http://app.kubernetes.io/version=0.1.20)
                        helm.sh/chart=generic-0.1.9
Annotations:            [deployment.kubernetes.io/revision](http://deployment.kubernetes.io/revision): 1
Selector:               [app.kubernetes.io/instance=node-web-app,app.kubernetes.io/name=node-web-app](http://app.kubernetes.io/instance=node-web-app,app.kubernetes.io/name=node-web-app)
Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:           [app.kubernetes.io/instance=node-web-app](http://app.kubernetes.io/instance=node-web-app)
                    [app.kubernetes.io/managed-by=Helm](http://app.kubernetes.io/managed-by=Helm)
                    [app.kubernetes.io/name=node-web-app](http://app.kubernetes.io/name=node-web-app)
                    [app.kubernetes.io/part-of=myapp](http://app.kubernetes.io/part-of=myapp)
                    [app.kubernetes.io/version=0.1.20](http://app.kubernetes.io/version=0.1.20)
                    helm.sh/chart=generic-0.1.9
  Annotations:      [instrumentation.opentelemetry.io/inject-nodejs](http://instrumentation.opentelemetry.io/inject-nodejs): observability/intrumentation
                    keptn.sh/post-deployment-tasks: post-deployment
                    keptn.sh/pre-deployment-evaluations: pre-deploy-eval
                    keptn.sh/pre-deployment-tasks: pre-deployment
  Service Account:  node-web-app
  Containers:
   node-web-app:
    Image:      localhost:5000/node-web-app:0.1.25
    Port:       8081/TCP
    Host Port:  0/TCP
    Command:
      npm
      start
    Liveness:   http-get http://:8081/healthz delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:  http-get http://:8081/healthz delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment Variables from:
      node-web-app-env  ConfigMap  Optional: false
    Environment:        <none>
    Mounts:             <none>
  Volumes:              <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    True    ReplicaSetUpdated
OldReplicaSets:  <none>
NewReplicaSet:   node-web-app-7b7c8fd649 (1/1 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  6m22s  deployment-controller  Scaled up replica set node-web-app-7b7c8fd649 to 1

The image updater can only update the image and the tag, not the version labels

@odubajDT
Copy link
Contributor

Ok, we see the problem now. You have the following label in your deployment:

app.kubernetes.io/version=0.1.20

The version value is took as the version of Workload and therefore if you update the image of the Deployment and do not update the version in the label, the change is not picked up.

A solution would be that you completely remove the label app.kubernetes.io/version=0.1.20 from your deployment.

If the label will not be present, the version of the Workload will be determied from the tag of the image. therefore changing of the tag of the image will start a deployment of a Workload with a new version

@pieterv-icloud-com
Copy link
Author

Thanks, let me give that a try

@pieterv-icloud-com
Copy link
Author

Looks like it's working.

So the secret is to not specifiy the version then.

@pieterv-icloud-com
Copy link
Author

Thx for the help, will close it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Archived in project
Development

No branches or pull requests

3 participants