-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working vsphere clusterctl example #263
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
machines.yaml | ||
cluster.yaml | ||
provider-components.yaml | ||
vsphere_tmp | ||
vsphere_tmp.pub |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Vsphere Example Files | ||
## Contents | ||
* *.yaml files - concrete example files that can be used as is. | ||
* *.yaml.template files - template example files that need values filled in before use. | ||
|
||
## Generation | ||
For convenience, a generation script which populates templates where possible. | ||
|
||
1. Run the generation script. This wil produce ```provider-components.yaml``` | ||
``` | ||
./generate-yaml.sh | ||
``` | ||
2. Copy machines.yaml.template to machines.yaml and | ||
Manually edit ```terraformVariables``` for machines in machines.yaml | ||
``` | ||
cp machines.yaml.template machines.yaml | ||
``` | ||
|
||
3. Copy cluster.yaml.template to cluster.yaml and | ||
Manually edit ```providerConfig``` for the cluster in cluster.yaml | ||
``` | ||
cp cluster.yaml.template cluster.yaml | ||
``` | ||
|
||
## Manual Modification | ||
You may always manually curate files based on the examples provided. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: "cluster.k8s.io/v1alpha1" | ||
kind: Cluster | ||
metadata: | ||
name: test1 | ||
spec: | ||
clusterNetwork: | ||
services: | ||
cidrBlocks: ["10.96.0.0/12"] | ||
pods: | ||
cidrBlocks: ["192.168.0.0/16"] | ||
serviceDomain: "cluster.local" | ||
providerConfig: | ||
value: | ||
apiVersion: "vsphereproviderconfig/v1alpha1" | ||
kind: "VsphereClusterProviderConfig" | ||
vsphereUser: "" | ||
vspherePassword: "" | ||
vsphereServer: "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
PROVIDERCOMPONENT_TEMPLATE_FILE=provider-components.yaml.template | ||
PROVIDERCOMPONENT_GENERATED_FILE=provider-components.yaml | ||
|
||
MACHINE_CONTROLLER_SSH_PUBLIC_FILE=vsphere_tmp.pub | ||
MACHINE_CONTROLLER_SSH_PUBLIC= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. It is the contents of the file. Will be populated after generation. |
||
MACHINE_CONTROLLER_SSH_PRIVATE_FILE=vsphere_tmp | ||
MACHINE_CONTROLLER_SSH_PRIVATE= | ||
MACHINE_CONTROLLER_SSH_HOME=~/.ssh/ | ||
|
||
OVERWRITE=0 | ||
|
||
SCRIPT=$(basename $0) | ||
while test $# -gt 0; do | ||
case "$1" in | ||
-h|--help) | ||
echo "$SCRIPT - generates input yaml files for Cluster API on vSphere" | ||
echo " " | ||
echo "$SCRIPT [options]" | ||
echo " " | ||
echo "options:" | ||
echo "-h, --help show brief help" | ||
echo "-f, --force-overwrite if file to be generated already exists, force script to overwrite it" | ||
exit 0 | ||
;; | ||
-f) | ||
OVERWRITE=1 | ||
shift | ||
;; | ||
--force-overwrite) | ||
OVERWRITE=1 | ||
shift | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
done | ||
|
||
if [ $OVERWRITE -ne 1 ] && [ -f $PROVIDERCOMPONENT_GENERATED_FILE ]; then | ||
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 "" | ||
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) | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
items: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you are using the vsphere client, this may need to updated based on PR #257. The apiVersion will be vsphereproviderconfig and the kind is either VsphereClusterProviderConfig or VsphereMachineProviderConfig. The username/password/server fields moved from the machine to the cluster providerConfig. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
- apiVersion: "cluster.k8s.io/v1alpha1" | ||
kind: Machine | ||
metadata: | ||
generateName: tf-master- | ||
labels: | ||
set: master | ||
spec: | ||
providerConfig: | ||
value: | ||
apiVersion: "vsphereproviderconfig/v1alpha1" | ||
kind: "VsphereMachineProviderConfig" | ||
vsphereMachine: "standard-master" | ||
terraformVariables: [ | ||
"datacenter = \"\"", | ||
"datastore = \"\"", | ||
"resource_pool = \"\"", | ||
"network = \"\"", | ||
"num_cpus = \"2\"", | ||
"memory = \"2048\"", | ||
"vm_template = \"\"", | ||
"disk_label = \"\"", | ||
"disk_size = \"\"", | ||
"virtual_machine_domain = \"\"", | ||
] | ||
versions: | ||
kubelet: 1.10.1 | ||
controlPlane: 1.10.1 | ||
roles: | ||
- Master | ||
- apiVersion: "cluster.k8s.io/v1alpha1" | ||
kind: Machine | ||
metadata: | ||
generateName: tf-node- | ||
spec: | ||
providerConfig: | ||
value: | ||
apiVersion: "vsphereproviderconfig/v1alpha1" | ||
kind: "VsphereMachineProviderConfig" | ||
vsphereMachine: "standard-node" | ||
terraformVariables: [ | ||
"datacenter = \"\"", | ||
"datastore = \"\"", | ||
"resource_pool = \"\"", | ||
"network = \"\"", | ||
"num_cpus = \"2\"", | ||
"memory = \"2048\"", | ||
"vm_template = \"\"", | ||
"disk_label = \"\"", | ||
"disk_size = \"\"", | ||
"virtual_machine_domain = \"\"", | ||
] | ||
versions: | ||
kubelet: 1.10.1 | ||
controlPlane: 1.10.1 | ||
roles: | ||
- Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we mark the required flags using things like:
createClusterCmd.MarkFlagRequired("provider")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is a good idea for a different PR.