-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support insecure-registries for container runtime running inside of kind container #110
Comments
SGTM, looks like both cri-o and containerd support this as well so if we want to use those inside the container in the future this can still be supported. We can add a config option to specify a list of insecure registries and write it through to the daemon config before we start the daemon. One thought though, specifically for the case of using a registry running on the host where kind is running, probably we can avoid the user needing to know what IP kind will see the host as, otherwise this config will be brittle / non-portable. https://dev.to/bufferings/access-host-from-a-docker-container-4099 looks like an option for that. perhaps we can have config like: insecureLocalRegistryPort: 5000 and then images can be at cc @munnerz This also seems related to #28 |
Please, take in account also that there is the possibility of using a private registry with self signed certificates, and to use this you need also put the corresponding CA certificate in place. Also take in account that we can use a private registry as a proxy, and that must be configured in daemon.json too. {
"insecure-registries": [
"<registry-ip>"
],
"registry-mirrors": [
"https://<registry-mirror-ip>"
]
} We are using two private registries, both use self signed certificates (mostly to avoid using :5000 in the image label), one for our own created images and the other as proxy due that we are in a restricted network. |
I think certs can be injected using #62 |
We're injecting a dockerd systemd dropin for proxy settings now, I think we can look at something similar for insecure registries. Something like kind config containing a list of these registries -> write dropins on the nodes. See also #340 |
fyi, federation folks are using this right now https://github.com/kubernetes-sigs/federation-v2/blob/master/scripts/create-clusters.sh |
Alternatively you can also do something like this: ➜ ~ cat test.sh
#!/bin/bash
TEMP_DIR=$(mktemp -d /tmp/cluster-api.XXXX)
cat << EOF > ${TEMP_DIR}/kind-config.json
kind: Config
apiVersion: kind.sigs.k8s.io/v1alpha2
nodes:
- role: control-plane
extraMounts:
- containerPath: /etc/docker/daemon.json
hostPath: ${TEMP_DIR}/docker-daemon.json
readOnly: true
EOF
cat << EOF > ${TEMP_DIR}/docker-daemon.json
{
"insecure-registries": ["http://172.17.0.1:5000"]
}
EOF
kind create cluster --config ${TEMP_DIR}/kind-config.json |
note that overwriting the entire daemon.json is not ideal as we move off the docker-shim: #425 (comment) I think we will need a first class option in kind to configure insecure registries. this should be easier to add to v1alpha3 config now. |
Hi, I'm trying to add a registry as insecure but it seems that my control-plane does not have the This is what I'm executing:
Am I doing something wrong? :) Cheers, |
@fspaniol the control plane switched to containerd since this issue was first open 😅 |
Updated the title to be more generic. 😄 |
Ah haha, that explains it. Btw, my use case was that I was trying to follow the tutorial from kubebuilder using kind and I was using a private registry to push my images and when a pod tried to fetch any image, it was getting the The guide can be found here. ps: thanks so much for kind, it makes kubernetes usage so much easier <3 |
@font thanks :-) @fspaniol Thanks for the feedback, I appreciate it and I'm sure others will find those links very useful. If anyone's interested in this issue, ideally I'd like to find a way to patch .toml files similar to kustomizing kubernetes yaml, that way we can just add the insecure registries we need on top of whatever existing config we have composably. I suspect people are typically writing this config file by hand currently... |
kind started using containerd and none of the solutions here work anymore, how do I go about adding an insecure registry now? |
@TrentonAdams the guide mentioned in #110 (comment) is one option for now. |
@BenTheElder Thanks. |
I've got an external insecure registry and deploying it within kind is not an option for me. Is there a way to bring it to work? |
yup, just submitted as #1119 |
Thanks for catching these and the PR
…On Thu, Nov 21, 2019, 00:36 Bright Zheng ***@***.***> wrote:
yup, just submitted as #1119
<#1119>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#110?email_source=notifications&email_token=AAHADK5G43GFITYY3D6DEF3QUZCBBA5CNFSM4GDZ5OUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEZM2OY#issuecomment-556977467>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHADK3RET3X6VJJKTZDWITQUZCBBANCNFSM4GDZ5OUA>
.
|
Hi I follow your step but find there is no pid like dockerd and so how can I restart docker to reload the daemon.json. Thank you very much |
These steps are outdated. |
It concerns private registry, not insecure registry, isn't it ? |
The same mechanisms / patch type are used to configure all registries.
…On Thu, Jun 25, 2020, 01:13 FredericLeroy ***@***.***> wrote:
It concerns private registry, not insecure registry, isn't it ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#110 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHADK6UHTBEYVDTHAYYGOTRYMBLJANCNFSM4GDZ5OUA>
.
|
Thank you very much I accpect your advice in my helm chart
and it work well there is no more error when pull image from insecure registry Thanks again |
Another way is to run your your registry as a pod inside the cluster , with a manifest similar to the following :
Note the following points :
In addition to the above the following must be done : 1 - Add the following configuration to the Kind config file :
2- After installing the kind cluster add the hosts file entry "127.0.0.1 registry.registry.svc" to all worker nodes in order for kind to resolve the in-cluster private registry; the following is a one-liner that achieves this :
Hope this helps :) |
I hope this saves some time and hair for the next guy. I needed to deploy an app at work on Kubernetes and either of the solutions "insecure registries" and "deploying the registry inside the cluster" were not options because I couldn't do them in production. I also didn't want to port-forward to the registry every time I had to push an image. I could finally nail this after a few days, and I have recorded my steps in a script that you can use. The script will do the following:
https://github.com/hamidsafdari/kind-private-registry I've also described all the steps in the README in case something doesn't work, and you want to debug. I've done this on Arch Linux and I had |
See also: https://kind.sigs.k8s.io/docs/user/local-registry/ Yes -- KIND should probably not be exposed to the internet in production, see the config docs. You can try for example kubeadm directly instead. |
I did try that and I believe this thread is about the problems with that
approach. The instructions in that link set up an insecure registry.
…On Mon, 7 Nov 2022, 20:00 Benjamin Elder, ***@***.***> wrote:
See also: https://kind.sigs.k8s.io/docs/user/local-registry/
Yes -- KIND should probably not be exposed to the internet in production,
see the config docs. You can try for example kubeadm directly instead.
—
Reply to this email directly, view it on GitHub
<#110 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHLI5VNENCXQ3YGPKVGQCTWHEN7RANCNFSM4GDZ5OUA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Er ... The title of this issue is:
With this in the issue description:
This issue is not about setting up a secure registry, because as you noted KIND is not meant to be used in that sort of situation. This issue was about setting up the local insecure registry to be usable within the cluster. The linked local registry guide is what closed this issue. Conversation about remote secure registries is off-topic for the original issue filed here. This other guide: |
You're right. I'm sorry. I just got so desperate trying to make this work I didn't read the title of the issue. I've used all the links you have shared, using a certificate and KinD's local registry setup. I guess the only thing I could have done was figure out how to make k8s use the insecure registry. My assumption was that it wouldn't. Partly because I read somewhere that KinD has moved away from using docker and I didn't bother to see how to make the new container runtime pull from the insecure registry. I also thought k8s uses https as a security measure and there's no way to make it use http. Also, everything else I found online mentioned setting up a secure registry that I thought that's how it should be done. Like docker's guide on how to set up a secure registry, including the generation of a certificate: I would probably use an insecure registry next time for faster set up. I also found that k3d accepts an argument during cluster creation for setting up a local registry but k3d was very resource heavy for my laptop. Sticking with KinD for now. |
Hi @BenTheElder, I followed the doc Local Registry, which is using plugins."io.containerd.grpc.v1.cri", and when deploy image, it is still not working .. Could you have a look and give some suggestion, please? Error in deployment:
config yaml looks like
|
you may be using podman without dns service enable? it fails to resolve the container by name 🤔 |
no issue on DNS, can lookup dns record in pods. |
@maomaoliu I met the same issue, and I had to modify the script to make it work. Here are my changes:
As you can see, I changed the host of the registry, this way the images are pulled using the HTTP protocol instead of HTTPS. I don't know if what I'm doing is a misuse but at least it helped me to fix my problem. |
No that's fine. |
@BenTheElder Shall I submit a PR to update the script before the future changes or it is not needed? |
I think switching the script to http is a reasonable change 👍 We can still do this in the future but the way we plumb the config through will be different, and eventually it will require breaking changes to that aspect I think. |
@BenTheElder here is the related PR #3161, let me know if it is good enough |
For the record: we're already pulling with HTTP inside of the cluster:
|
Hi @BenTheElder, When I use kind-registry:5000 in my cluster application, it simply doesn't work, here is the error log:
I think this is because kubelet has no idea that this is an insecure registry, so I add a mapping in /etc/containerd/certs.d/kind-registry:5000/hosts.toml to tell containerd to use http for kind-registry:
And my application pulls off the image successfuly. Do you think this change is needed? If so I could submit a PR to fix the script. |
When kubelet is pulling an image and not some in-cluster application itself reaching an image you should use localhost:5001 and the registry config will remap it to http on the registry container to match the way you name and push it from the host please see the current registry docs for a sample of pushing and deploying a container correctly |
Kubelet doesn't know about any of this, but you need to use localhost:5001 because that's what we told containerd to remap to match the host. |
Thanks for the info, Ben. Let me provide more context, I followed the local registry doc to set up kind and local registry. I plan to install Istio in that cluster using the local registry, here is the yaml file for Istioctl:
I tried with localhost:5001 but connection to this registry failed in starting istiod pod. Then I switched to kind-registry:5000 and got "http: server gave HTTP response to HTTPS client" error I mentioned before. This is why I have to add an entry in containerd registry to map kind-registry:5000 to http. So I think for cases to use kind-registry, a http registry mirror is needed. |
The host that is running
kind
to set up kind clusters may want to create container images to be pulled by the container runtime (docker/containerd daemons) running inside of thekind-<name>-control-plane
containers e.g.kind-1-control-plane
. To simplify this, it would be great to have a way to easily configure the container runtime running inside the kind containers withinsecure-registries
in order to pull images from the host's insecure registry. This would simplify the local registry setup on the host to not require TLS.For now, I have used the following workaround:
daemon.json
inside of the kind container via docker exec:SIGHUP
to docker daemon in kind container in order to reload config:This works for now and then any container image to be pulled needs to be specified like so:
The text was updated successfully, but these errors were encountered: