Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Why is image not updated? #1504

Closed
montyz opened this issue Nov 10, 2018 · 6 comments · Fixed by #1507
Closed

Why is image not updated? #1504

montyz opened this issue Nov 10, 2018 · 6 comments · Fixed by #1507

Comments

@montyz
Copy link
Contributor

montyz commented Nov 10, 2018

I set up a pod with a deployement yaml file like so:

    annotations:
        flux.weave.works/automated: "true"
        flux.weave.works/tag.container-name: "master-*"
    spec:
      containers:
      - name: k8s-mon
        image: index.docker.io/larktech/k8s-mon:latest

I don't need to do anything more than deploy with the annotations to get it to update when a new docker image appears with a name like master-*, right?

Is it a problem that I'm starting from the latest tag? If I put in master-nonexistent and push that to the git repo, will it fail at first and then see that it's not the latest and update it appropriately? Or do I have to create a master-latest tag for that first installation?

@whereismyjetpack
Copy link

whereismyjetpack commented Nov 10, 2018

Hi! Try this:

      annotations:
        flux.weave.works/automated: "true"
        flux.weave.works/tag.k8s-mon: "glob:master-*"
    spec:
      containers:
      - name: k8s-mon
        image: index.docker.io/larktech/k8s-mon:latest

The container name is the name field in the pod spec, and I think you have to specify glob, other semver automation types

@montyz
Copy link
Contributor Author

montyz commented Nov 10, 2018

OK my first problem was that I didn't understand to replace container-name with the actual name of the container. And maybe latest isn't the right place to start either. So now with this:

unfortunately that didn't work. I now have this:

    metadata:
      labels:
        app: k8s-mon
      annotations:
        flux.weave.works/automated: "true"
        flux.weave.works/tag.k8s-mon: "glob:master-*"
    spec:
      containers:
      - name: k8s-mon
        image: index.docker.io/larktech/k8s-mon:master-c00edf01

And I have a number of master-xxx tags in docker hub that are later than master-c00edf01, however when I deploy it stays at master-c00edf01 and even if I make a change and build a new image after the container started, it doesn't pick it up.

I see in the log of flux:

ts=2018-11-10T16:25:17.550224723Z caller=warming.go:268 component=warmer info="refreshing image" image=index.docker.io/larktech/k8s-mon tag_count=87 to_update=1 of_which_refresh=0 of_which_missing=1
ts=2018-11-10T16:25:17.639791796Z caller=warming.go:350 component=warmer updated=index.docker.io/larktech/k8s-mon successful=1 attempted=1
ts=2018-11-10T16:25:17.640073973Z caller=images.go:17 component=sync-loop msg="polling images"
ts=2018-11-10T16:25:17.67724718Z caller=images.go:27 component=sync-loop msg="no automated services"

so it looks like it wants to update the docker tag, but is reporting "no automated services", so maybe this annotation is incorrect?

      annotations:
        flux.weave.works/automated: "true"

@squaremo
Copy link
Member

What kind of resource does the YAML describe, just to check? You say "pod" and also "deployment".

@montyz
Copy link
Contributor Author

montyz commented Nov 12, 2018

Here's the full yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: k8s-mon
  namespace: admin
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 50%
  template:
    metadata:
      labels:
        app: k8s-mon
      annotations:
        flux.weave.works/automated: "true"
        flux.weave.works/tag.k8s-mon: "glob:master-*"
    spec:
      volumes:
      - name: secret-volume
        gitRepo:
          repository: https://larkbuildmachine:[email protected]/larktech/dev8a-cluster.git

      containers:
      - name: k8s-mon
        image: index.docker.io/larktech/k8s-mon:master-c00edf01
        volumeMounts:
        - name: secret-volume
          mountPath: /secrets/kube
          subPath: k8s-dev/dev8a-specs/admin/config/kube
          readOnly: true

        - name: secret-volume
          mountPath: /secrets/aws
          subPath: k8s-dev/dev8a-specs/admin/config/aws
          readOnly: true

        - name: secret-volume
          mountPath: /secrets/env
          subPath: k8s-dev/dev8a-specs/admin/config/k8s-mon
          readOnly: true

        ports:
        - name: http-port
          containerPort: 8000
        - name: file-port
          containerPort: 8080

        readinessProbe:
          httpGet:
            path: /status
            port: http-port
          initialDelaySeconds: 3
          periodSeconds: 3
        resources:
          requests:
            memory: 512Mi
          limits:
            memory: 512Mi

      imagePullSecrets:
      - name: myregistrykey

@montyz
Copy link
Contributor Author

montyz commented Nov 12, 2018

Now that I got fluxctl working I see that my annotations were in the wrong place. I had them in spec.template.metadata.annotations but they need to be in metadata.annotations. Would be nice to have a full yaml file example.

@montyz montyz closed this as completed Nov 12, 2018
@squaremo
Copy link
Member

I had them in spec.template.metadata.annotations but they need to be in metadata.annotations. Would be nice to have a full yaml file example.

That's a good idea; there's only a small section on how to use annotations, which could be its own document.

montyz pushed a commit to montyz/flux that referenced this issue Nov 13, 2018
squaremo pushed a commit that referenced this issue Dec 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants