kots icon indicating copy to clipboard operation
kots copied to clipboard

Private images cannot be used in troubleshoot/preflight collectors

Open divolgin opened this issue 6 years ago • 8 comments

Preflight checks that use images don't work in these scenarios:

  • when proxyPublicImages flag is specified
  • when the image used is private
  • in airgapped installs (where all images are private). These images are also not included in airgap bundles.

divolgin avatar May 29 '20 19:05 divolgin

Related: https://github.com/replicatedhq/troubleshoot/issues/247

austinchambers avatar Aug 19 '20 15:08 austinchambers

Ran into this. I partially worked around it by setting the image using LocalImageName, but didn't have a way to set the image pull secret. It looks like that's been fixed in KOTS 1.19.0. Has this issue also been fixed for 1.19.0?

MikaelSmith avatar Sep 17 '20 18:09 MikaelSmith

Yes, this is fixed in 1.19.0!

markpundsack avatar Sep 21 '20 21:09 markpundsack

Really? I'll have to test it out, I didn't see anything patching the imageName or imagePullSecret.

MikaelSmith avatar Sep 21 '20 21:09 MikaelSmith

Yeah, I think this is still an issue. Troubleshoot was updated so you can reference an imagePullSecret, but KOTS doesn't automatically pull from the local registry and configure an image pull secret if a local registry is configured.

MikaelSmith avatar Sep 21 '20 23:09 MikaelSmith

@MikaelSmith We tested airgap with Preflight checks with Private images and it’s working as expected, here are some instructions. You need the latest version of kots 1.19.x.

Step 1: First you need to add the image to additionalImages in Application kots kind.

kind: Application
spec:
  additionalImages:
    - "registry.replicated.com/aj-kots-collie/busybox:1"

https://kots.io/vendor/operators/additional-images/

Step 2: Define the run collector with LocalImageName and LocalRegistryImagePullSecret in the collector and define the analyzer as usual, here is an example

kind: Preflight
metadata:
  name: example-preflight-checks
spec:
  collectors:
    - run:
        collectorName: "kotsadm-ping"
        image: 'repl{{ LocalImageName "registry.replicated.com/aj-kots-collie/busybox:1" }}'
        namespace: default
        name: ping.txt
        imagePullSecret:
          name: aj-secret
          data: 
            .dockerconfigjson: '{{repl LocalRegistryImagePullSecret }}'
          type: kubernetes.io/dockerconfigjson
        command: ["ping"]
        args: ["-w", "10", "-c", "10", "-i", "0.3", "kotsadm"]
        imagePullPolicy: IfNotPresent
  analyzers:
    - textAnalyze:
        checkName: "kotsadm-ping"
        fileName: ping.txt/kotsadm-ping.log
        regexGroups: '(?PTransmitted\d+) packets? transmitted, (?PReceived\d+) packets? received, (?PLoss\d+)(\.\d+)?% packet loss'
        outcomes:
          - pass:
              when: "Loss < 5"
              message: Solid connection to kotsadm
          - fail:
              message: High packet loss

https://kots.io/vendor/operators/referencing-images/

Let me know if you guys have any questions.

aj-jester avatar Sep 22 '20 13:09 aj-jester

Yes, that's what I'm doing. But it's not what I expected the outcome of this issue to be, I would have expected the preflight check not to need any modifications to work in an airgap environment.

MikaelSmith avatar Sep 22 '20 15:09 MikaelSmith

Thanks for confirming. Consider this a workaround for now. I've created an internal ticket to exploring doing it automatically. (https://app.clubhouse.io/replicated/story/26487/automatically-adjust-private-image-references-in-preflight-and-support-bundles)

markpundsack avatar Sep 22 '20 16:09 markpundsack