Skip to content

Getting NOT_FOUND error while uploading helm chart to GitHub Container Registry #2417

@rohanKanojia

Description

@rohanKanojia

Describe the bug

Related to #2377

While uploading a helm chart to GitHub Container Registry, I keep getting 404 /Not found error like this:

[ERROR] k8s: Error performing helm push: java.lang.IllegalStateException: Failure in initiating upload request: Not Found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.065 s
[INFO] Finished at: 2023-10-11T10:45:21+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.14.0:helm-push (default-cli) on project jkube-helm-chart-upload-ghcr-demo: Failure in initiating upload request: Not Found

Upon closer inspection, I think it's due to passing an invalid Host header while doing OCI upload request. For a Url like ghcr.io, host is computed as ghcr.io:-1:
https://github.com/eclipse/jkube/blob/cc6d239259aab437655a8bfdb76f0328f1170a95/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java#L128

We should only add port value if registry URL contains a valid port.

Eclipse JKube version

SNAPSHOT

Component

Kubernetes Maven Plugin

Apache Maven version

None

Gradle version

None

Steps to reproduce

Set up GitHub Container Registry and try pushing with this configuration:

      <plugin>
        <groupId>org.eclipse.jkube</groupId>
        <artifactId>kubernetes-maven-plugin</artifactId>
        <version>${jkube.version}</version>
        <configuration>
          <helm>
            <snapshotRepository>
              <name>GitHub</name>
              <url>https://ghcr.io/r0haaaan/helm</url>
              <type>OCI</type>
              <username>r0haaaan</username>
              <password>${env.GHCR_PASSWORD}</password>
            </snapshotRepository>
          </helm>
        </configuration>
      </plugin>

Expected behavior

Plugin should push to GitHub Container Registry without any problems

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.25.3

Environment

Linux

Eclipse JKube Logs

No response

Sample Reproducer Project

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions