Skip to content

Commit 0d51b08

Browse files
committed
fix: add insecure registry configuration to containerd; refs #555
1 parent b64e9a5 commit 0d51b08

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pkg/kind/kind.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func recreateCluster(registry bool, extraMountHostPath string, extraMountContain
342342
if err := deleteContainerRegistry(dcli); err != nil {
343343
return fmt.Errorf("delete container registry: %w", err)
344344
}
345-
if err := createNewCluster(extraMountHostPath, extraMountContainerPath); err != nil {
345+
if err := createNewCluster(registry, extraMountHostPath, extraMountContainerPath); err != nil {
346346
return fmt.Errorf("new cluster: %w", err)
347347
}
348348
if registry {
@@ -357,7 +357,18 @@ func recreateCluster(registry bool, extraMountHostPath string, extraMountContain
357357
}
358358

359359
// createNewCluster creates a new Kind cluster
360-
func createNewCluster(extraMountHostPath string, extraMountContainerPath string) error {
360+
func createNewCluster(registry bool, extraMountHostPath string, extraMountContainerPath string) error {
361+
insecureRegistry := ""
362+
if registry {
363+
insecureRegistry = `
364+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
365+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."kind-registry:5000"]
366+
endpoint = ["http://kind-registry:5000"]
367+
[plugins."io.containerd.grpc.v1.cri".registry.configs]
368+
[plugins."io.containerd.grpc.v1.cri".registry.configs."kind-registry:5000".tls]
369+
insecure_skip_verify = true`
370+
}
371+
361372
extraMount := ""
362373
if extraMountHostPath != "" && extraMountContainerPath != "" {
363374
extraMount = fmt.Sprintf(`
@@ -379,14 +390,14 @@ name: %s
379390
containerdConfigPatches:
380391
- |-
381392
[plugins."io.containerd.grpc.v1.cri".registry]
382-
config_path = "/etc/containerd/certs.d/"
393+
config_path = "/etc/containerd/certs.d/" %s
383394
nodes:
384395
- role: control-plane
385396
image: %s %s
386397
extraPortMappings:
387398
- containerPort: 31080
388399
listenAddress: 0.0.0.0
389-
hostPort: 80`, clusterName, kubernetesVersion, extraMount)
400+
hostPort: 80`, clusterName, insecureRegistry, kubernetesVersion, extraMount)
390401

391402
createCluster := exec.Command("kind", "create", "cluster", "--wait=120s", "--config=-")
392403
createCluster.Stdin = strings.NewReader(config)

0 commit comments

Comments
 (0)