Skip to content

Commit bf3b1a3

Browse files
authored
Merge pull request #12012 from yiannistri/kind-fix
🐛 Stop overwriting ExtraPortMappings if WithDockerSockMount option is used
2 parents 415c32c + 290c76d commit bf3b1a3

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

test/framework/bootstrap/kind_provider.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (k *KindClusterProvider) createKindCluster() {
149149
},
150150
Nodes: []kindv1.Node{
151151
{
152+
Role: kindv1.ControlPlaneRole,
152153
ExtraPortMappings: k.extraPortMappings,
153154
},
154155
},
@@ -163,7 +164,10 @@ func (k *KindClusterProvider) createKindCluster() {
163164
kindv1.SetDefaultsCluster(cfg)
164165

165166
if k.withDockerSock {
166-
setDockerSockConfig(cfg)
167+
cfg.Nodes[0].ExtraMounts = append(cfg.Nodes[0].ExtraMounts, kindv1.Mount{
168+
HostPath: "/var/run/docker.sock",
169+
ContainerPath: "/var/run/docker.sock",
170+
})
167171
}
168172

169173
kindCreateOptions = append(kindCreateOptions, kind.CreateWithV1Alpha4Config(cfg))
@@ -197,21 +201,6 @@ func (k *KindClusterProvider) createKindCluster() {
197201
}
198202
}
199203

200-
// setDockerSockConfig returns a kind config for mounting /var/run/docker.sock into the kind node.
201-
func setDockerSockConfig(cfg *kindv1.Cluster) {
202-
cfg.Nodes = []kindv1.Node{
203-
{
204-
Role: kindv1.ControlPlaneRole,
205-
ExtraMounts: []kindv1.Mount{
206-
{
207-
HostPath: "/var/run/docker.sock",
208-
ContainerPath: "/var/run/docker.sock",
209-
},
210-
},
211-
},
212-
}
213-
}
214-
215204
// GetKubeconfigPath returns the path to the kubeconfig file for the cluster.
216205
func (k *KindClusterProvider) GetKubeconfigPath() string {
217206
return k.kubeconfigPath

0 commit comments

Comments
 (0)