forked from kubernetes-sigs/cluster-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working vsphere clusterctl example (kubernetes-sigs#263)
- Loading branch information
0 parents
commit e6f34c9
Showing
6 changed files
with
575 additions
and
0 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
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 |
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,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. | ||
|
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,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: "" |
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,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= | ||
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 |
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,57 @@ | ||
items: | ||
- 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 |
Oops, something went wrong.