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

Ensures that images are pulled from the insecure registry with http #3161

Closed
wants to merge 1 commit into from
Closed

Ensures that images are pulled from the insecure registry with http #3161

wants to merge 1 commit into from

Conversation

essobedo
Copy link

@essobedo essobedo commented Apr 7, 2023

Related to #110

Motivation

Inside k8s, the images are pulled from the insecure registry using HTTPS while they should be pulled with HTTP.

Modifications:

  • Modifies the registry mirrors' configuration to ensure that images pulled from kind-registry are pulled using HTTP
  • Defines the value of hostFromClusterNetwork of the localRegistryHosting
  • Updates the documentation consequently

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 7, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: essobedo / name: Nicolas Filotto (8b67b61)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 7, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: essobedo
Once this PR has been reviewed and has the lgtm label, please assign bentheelder for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from aojea and neolit123 April 7, 2023 16:05
@k8s-ci-robot
Copy link
Contributor

Welcome @essobedo!

It looks like this is your first PR to kubernetes-sigs/kind 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kind has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 7, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @essobedo. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 7, 2023
@@ -36,6 +36,7 @@ metadata:
data:
localRegistryHosting.v1: |
host: "localhost:${reg_port}"
hostFromClusterNetwork: "${reg_name}:5000"
Copy link
Member

Choose a reason for hiding this comment

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

neat!

@BenTheElder
Copy link
Member

Catching up after being on vacation for a week and some other kubernetes priorities ... Thanks for the PR!

Unfortunately we can't merge anything without the CNCF's CLA 😅

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 24, 2023
@essobedo
Copy link
Author

@BenTheElder The CLA is signed now, it took me some time

@aojea
Copy link
Contributor

aojea commented Apr 24, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 24, 2023
@@ -25,7 +25,7 @@ The registry can be used like this.
1. First we'll pull an image `docker pull gcr.io/google-samples/hello-app:1.0`
2. Then we'll tag the image to use the local registry `docker tag gcr.io/google-samples/hello-app:1.0 localhost:5001/hello-app:1.0`
3. Then we'll push it to the registry `docker push localhost:5001/hello-app:1.0`
4. And now we can use the image `kubectl create deployment hello-server --image=localhost:5001/hello-app:1.0`
4. And now we can use the image `kubectl create deployment hello-server --image=kind-registry:5000/hello-app:1.0`
Copy link
Member

Choose a reason for hiding this comment

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

this change is unrelated and localhost:5001 should work.

the goal is to ensure that a consistent name is used for the images across hosts to avoid confusion for users.

@@ -16,7 +16,7 @@ kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."${reg_name}:5000"]
Copy link
Member

Choose a reason for hiding this comment

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

this change is wrong

Copy link
Member

Choose a reason for hiding this comment

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

this configuration as-is allows us to remap pulls for images at localhost:$registry_port to the registry container, for a consistent reference between host and nodes

you can remap anything to anything, this is remapping is performed in the image resolution code in containerd.

Copy link
Member

Choose a reason for hiding this comment

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

so containerd sees localhost:5001/foo and instead it pulls from the endpoint we specify here.


If you build your own image and tag it like `localhost:5001/image:foo` and then use
it in kubernetes as `localhost:5001/image:foo`. And use it from inside of your cluster application as `kind-registry:5000`.
it in kubernetes as `kind-registry:5000/image:foo`. And use it from inside of your cluster application as `kind-registry:5000`.
Copy link
Member

Choose a reason for hiding this comment

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

same here: this doesn't need to change. the only time you need to use kind-registry instead is if you're in the docker network and not using the node container runtime

@BenTheElder
Copy link
Member

Inside k8s, the images are pulled from the insecure registry using HTTPS while they should be pulled with HTTP.

looking at the config again now, they are not, it is configured as http

endpoint = ["http://${reg_name}:5000"]

I think there may be some confusion here either about how the containerd feature works or about pulling images from something other than the node runtimes.

@essobedo
Copy link
Author

I confirm that the current code works for the use case provided in the article https://kind.sigs.k8s.io/docs/user/local-registry/ but not in my use case where I need to be able to push an image from a pod with this approach we can access the local registry in the exact same manner inside the k8s cluster but I understand that it is probably too specific.

@essobedo essobedo closed this Apr 25, 2023
@essobedo essobedo deleted the fix-insecure-registry-script branch April 25, 2023 09:08
@BenTheElder
Copy link
Member

To push from a pod you have to use kind-registry:$port and the docs mention this? That line may need clarifying, but doing that doesn't require altering the containerd configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants