Skip to content

Commit f98871d

Browse files
authored
Merge pull request #88 from xunpan/id
IBM specific ssh key name and clean generate.sh
2 parents 6d1acec + a6a1bd3 commit f98871d

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

cmd/clusterctl/example/ibmcloud/generate-yaml.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if [[ -n "$1" ]] && [[ $1 != -* ]] && [[ $1 != --* ]];then
3838
CLOUDS_PATH="$1"
3939
else
4040
echo "Error: No clouds.yaml provided"
41-
echo "You must provide a valid clouds.yaml script to genereate a cloud.conf"
41+
echo "You must provide a valid clouds.yaml"
4242
echo ""
4343
print_help
4444
exit 1
@@ -70,21 +70,6 @@ if test -z "$PROVIDER_OS"; then
7070
exit 1
7171
fi
7272

73-
if ! hash yq 2>/dev/null; then
74-
echo "'yq' is not available, please install it. (https://github.com/mikefarah/yq)"
75-
echo ""
76-
print_help
77-
exit 1
78-
fi
79-
80-
yq_type=$(file $(which yq))
81-
if [[ $yq_type == *"Python script"* ]]; then
82-
echo "Wrong version of 'yq' installed, please install the one from https://github.com/mikefarah/yq"
83-
echo ""
84-
print_help
85-
exit 1
86-
fi
87-
8873
if [ -e out/provider-components.yaml ] && [ "$OVERWRITE" != "1" ]; then
8974
echo "Can't overwrite provider-components.yaml without user permission. Either run the script again"
9075
echo "with -f or --force-overwrite, or delete the file in the out/ directory."
@@ -96,25 +81,34 @@ fi
9681

9782
# Define global variables
9883
PWD=$(cd `dirname $0`; pwd)
99-
TEMPLATES_PATH=${TEMPLATES_PATH:-$PWD/$SUPPORTED_PROVIDER_OS}
10084
CONFIG_DIR=$PWD/provider-component/clouds-secrets/configs
10185
OVERWRITE=${OVERWRITE:-0}
10286
CLOUDS_PATH=${CLOUDS_PATH:-""}
10387
USERDATA=$PWD/provider-component/user-data
10488
MASTER_USER_DATA=$USERDATA/$PROVIDER_OS/templates/master-user-data.sh
10589
WORKER_USER_DATA=$USERDATA/$PROVIDER_OS/templates/worker-user-data.sh
10690

107-
# Set up the output dir if it does not yet exist
108-
mkdir -p $PWD/out
109-
cp -n $PWD/cluster.yaml.template $PWD/out/cluster.yaml
110-
cp -n $PWD/machines.yaml.template $PWD/out/machines.yaml
91+
CLOUD_SSH_PRIVATE_FILE=id_ibmcloud
92+
CLOUD_SSH_HOME=${HOME}/.ssh/
93+
# Create ssh key to access IBM Cloud machines on demand
94+
if [ ! -f ${CLOUD_SSH_HOME}${CLOUD_SSH_PRIVATE_FILE} ]; then
95+
echo "Generating SSH key files for IBM cloud machine access."
96+
# This is needed because GetKubeConfig assumes the key in the home .ssh dir.
97+
ssh-keygen -t rsa -f ${CLOUD_SSH_HOME}${CLOUD_SSH_PRIVATE_FILE} -N ""
98+
fi
11199

100+
# Prepare dependecies for kustomize
112101
mkdir -p $CONFIG_DIR
113102
cat $PWD/$CLOUDS_PATH > $CONFIG_DIR/clouds.yaml
114103

115104
cat "$MASTER_USER_DATA" > $USERDATA/$PROVIDER_OS/master-user-data.sh
116105
cat "$WORKER_USER_DATA" > $USERDATA/$PROVIDER_OS/worker-user-data.sh
117106

107+
# Set up the output dir if it does not yet exist
108+
mkdir -p $PWD/out
109+
cp -n $PWD/cluster.yaml.template $PWD/out/cluster.yaml
110+
cp -n $PWD/machines.yaml.template $PWD/out/machines.yaml
111+
118112
# Build provider-components.yaml with kustomize
119113
kustomize build ../../../../config -o out/provider-components.yaml
120114

pkg/cloud/ibmcloud/deployer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ func (d *DeploymentClient) GetKubeConfig(cluster *clusterv1.Cluster, master *clu
7575
}
7676
sshUserName := providerSpec.SshUserName
7777

78-
// TODO: generate IBM Cloud specific keys
79-
privateKey := "id_rsa"
78+
privateKey := "id_ibmcloud"
8079

8180
result := strings.TrimSpace(util.ExecCommand(
8281
"ssh", "-i", homeDir+"/.ssh/"+privateKey,

0 commit comments

Comments
 (0)