Skip to content

Commit

Permalink
vsphere generate-yaml usability changes, timeout for clusterctl (#302)
Browse files Browse the repository at this point in the history
* vsphere generate-yaml usability changes

* Change timeouts, copy ssh keys if they dontexist
  • Loading branch information
karan authored and k8s-ci-robot committed Jun 7, 2018
1 parent 578ec1b commit 982993b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions clusterctl/clusterdeployer/clusterclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const (
ApiServerPort = 443
RetryIntervalKubectlApply = 5 * time.Second
RetryIntervalResourceReady = 5 * time.Second
TimeoutKubectlApply = 2 * time.Minute
TimeoutResourceReady = 2 * time.Minute
TimeoutMachineReady = 5 * time.Minute
TimeoutKubectlApply = 5 * time.Minute
TimeoutResourceReady = 5 * time.Minute
TimeoutMachineReady = 10 * time.Minute
)

type clusterClient struct {
Expand Down
2 changes: 1 addition & 1 deletion clusterctl/clusterdeployer/clusterdeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (d *ClusterDeployer) writeKubeconfig(kubeconfig string) error {

func waitForKubeconfigReady(provider ProviderDeployer, cluster *clusterv1.Cluster, machine *clusterv1.Machine) (string, error) {
kubeconfig := ""
err := util.Poll(500*time.Millisecond, 120*time.Second, func() (bool, error) {
err := util.Poll(5*time.Second, 10*time.Minute, func() (bool, error) {
glog.V(2).Infof("Waiting for kubeconfig on %v to become ready...", machine.Name)
k, err := provider.GetKubeConfig(cluster, machine)
if err != nil {
Expand Down
33 changes: 21 additions & 12 deletions clusterctl/examples/vsphere/generate-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,33 @@ while test $# -gt 0; do
done

if [ $OVERWRITE -ne 1 ] && [ -f $PROVIDERCOMPONENT_GENERATED_FILE ]; then
echo File $PROVIDERCOMPONENT_GENERATED_FILE already exists. Delete it manually before running this script.
echo "File $PROVIDERCOMPONENT_GENERATED_FILE already exists. Delete it manually before running this script."
exit 1
fi

if [ ! -f $MACHINE_CONTROLLER_SSH_PRIVATE_FILE ]; then
echo Generate SSH key files fo machine controller
ssh-keygen -t rsa -f $MACHINE_CONTROLLER_SSH_PRIVATE_FILE -N ""
# Check if the ssh key already exists. If not, generate and copy to the .ssh dir.
if [ ! -f $MACHINE_CONTROLLER_SSH_HOME$MACHINE_CONTROLLER_SSH_PRIVATE_FILE ]; then
echo "Generating SSH key files for machine controller."
# This is needed because GetKubeConfig assumes the key in the home .ssh dir.
ssh-keygen -t rsa -f $MACHINE_CONTROLLER_SSH_HOME$MACHINE_CONTROLLER_SSH_PRIVATE_FILE -N ""
fi

# Copy file to home ssh directory till using vsphere GetIP logic that
# does not assume the file at this location
cp $MACHINE_CONTROLLER_SSH_PUBLIC_FILE $MACHINE_CONTROLLER_SSH_HOME
cp $MACHINE_CONTROLLER_SSH_PRIVATE_FILE $MACHINE_CONTROLLER_SSH_HOME

MACHINE_CONTROLLER_SSH_PUBLIC=$(cat $MACHINE_CONTROLLER_SSH_PUBLIC_FILE|base64 -w0)
MACHINE_CONTROLLER_SSH_PRIVATE=$(cat $MACHINE_CONTROLLER_SSH_PRIVATE_FILE|base64 -w0)
OS=$(uname)
if [[ "$OS" =~ "Linux" ]]; then
MACHINE_CONTROLLER_SSH_PUBLIC=$(cat $MACHINE_CONTROLLER_SSH_HOME$MACHINE_CONTROLLER_SSH_PUBLIC_FILE|base64 -w0)
MACHINE_CONTROLLER_SSH_PRIVATE=$(cat $MACHINE_CONTROLLER_SSH_HOME$MACHINE_CONTROLLER_SSH_PRIVATE_FILE|base64 -w0)
elif [[ "$OS" =~ "Darwin" ]]; then
MACHINE_CONTROLLER_SSH_PUBLIC=$(cat $MACHINE_CONTROLLER_SSH_HOME$MACHINE_CONTROLLER_SSH_PUBLIC_FILE|base64)
MACHINE_CONTROLLER_SSH_PRIVATE=$(cat $MACHINE_CONTROLLER_SSH_HOME$MACHINE_CONTROLLER_SSH_PRIVATE_FILE|base64)
else
echo "Unrecognized OS : $OS"
exit 1
fi

cat $PROVIDERCOMPONENT_TEMPLATE_FILE \
| sed -e "s/\$MACHINE_CONTROLLER_SSH_PUBLIC/$MACHINE_CONTROLLER_SSH_PUBLIC/" \
| sed -e "s/\$MACHINE_CONTROLLER_SSH_PRIVATE/$MACHINE_CONTROLLER_SSH_PRIVATE/" \
> $PROVIDERCOMPONENT_GENERATED_FILE
> $PROVIDERCOMPONENT_GENERATED_FILE

echo "Done generating $PROVIDERCOMPONENT_GENERATED_FILE"
echo "You will still need to generate the cluster.yaml and machines.yaml"

0 comments on commit 982993b

Please sign in to comment.