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

Skip local registry use for vclusters on local kubernetes clusters #2390

Merged
merged 1 commit into from
Oct 24, 2022

Conversation

lizardruss
Copy link
Collaborator

What issue type does this pull request address?
/kind bugfix

What does this pull request do? Which issues does it resolve?

  • Resolves an issue where the local registry was used for vclusters on Minikube, Docker Desktop, and KinD clusters
  • Refactored a few locations that were checking for Minikube that would have failed for vcluster & minikube
  • Allow local registry to be used with Minikube when explicitly enabled

Please provide a short message that should be published in the DevSpace release notes
Fixed an issue where DevSpace local registry was incorrectly used for virtual clusters on local Kubernetes clusters

What else do we need to know?
Previously the local registry could never be used with minikube. These changes allow the user to opt in to the local registry with Minikube, and makes it consistent with the other local kubernetes options (KinD & Docker Desktop). There isn't a practical reason to do this, but using localRegistry.enabled=true in the config, and not having the local registry used was unexpected to some during testing.

There is also a KinD issue where --force-build creates a new tag, but kind load docker-image fails to re-tag the image in the KinD cluster, leading to an ImagePullBackoff. I've verified this issue exists in DevSpace version before the local registry feature was added. Using the local registry works as a workaround for this issue.

Copy link
Collaborator Author

@lizardruss lizardruss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FabianKramm added some additional context to these changes. Let me know if you'd like anything changed.

@@ -106,10 +101,7 @@ func (c *controller) Build(ctx devspacecontext.Context, images []string, options

// Determine whether the local registry is required / enabled
isLocalReqistryRequired := !registry.HasPushPermission(imageConf)
useMinikubeDocker := registry.UseMinikubeDocker(ctx, imageConf)
if useMinikubeDocker {
ctx.Log().Warnf("Using Minikube for image %s, skipping local registry", imageConf.Image)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can bring back this edge case if desired, but it was somewhat unexpected to have localRegistry.enabled = true and it still not be used because of minikube.

This did require using a docker client configured for the minikube environment to work, see later comments.

ref, err := name.ParseReference(imageName)
if err != nil {
return err
}

image, err := daemon.Image(ref, daemon.WithContext(ctx))
image, err := daemon.Image(ref, daemon.WithContext(ctx), daemon.WithClient(client.DockerAPIClient()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update allows the local registry push to work with either the local docker daemon, or the Minikube docker daemon.

@@ -107,7 +109,7 @@ func newDockerClientFromEnvironment() (Client, error) {
}

func newDockerClientFromMinikube(ctx context.Context, currentKubeContext string) (Client, error) {
if currentKubeContext != "minikube" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also miss vcluster + Minikube contexts

@lizardruss lizardruss changed the title fix: skip local registry use for vclusters on local kubernetes clusters Skip local registry use for vclusters on local kubernetes clusters Oct 21, 2022
@FabianKramm FabianKramm merged commit b1f5e08 into devspace-sh:main Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants