This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move creating kind control plane into public function
- Loading branch information
Showing
2 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package controlplane | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
"sigs.k8s.io/cluster-api-provider-docker/kind/actions" | ||
"sigs.k8s.io/kind/pkg/cluster/nodes" | ||
"sigs.k8s.io/kind/pkg/container/cri" | ||
) | ||
|
||
func CreateKindCluster(image, clusterName string) error { | ||
lb, err := actions.SetUpLoadBalancer(clusterName) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to create load balancer") | ||
} | ||
|
||
lbipv4, _, err := lb.IP() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to get ELB IP") | ||
} | ||
|
||
cpMounts := []cri.Mount{ | ||
{ | ||
ContainerPath: "/var/run/docker.sock", | ||
HostPath: "/var/run/docker.sock", | ||
}, | ||
} | ||
|
||
cp, err := actions.CreateControlPlane(clusterName, fmt.Sprintf("%s-control-plane", clusterName), lbipv4, "v1.14.2", cpMounts) | ||
if err != nil { | ||
return errors.Wrap(err, "couldn't create control plane") | ||
} | ||
|
||
if !nodes.WaitForReady(cp, time.Now().Add(5*time.Minute)) { | ||
return errors.New("control plane was not ready in 5 minutes") | ||
} | ||
|
||
return nil | ||
} |