Skip to content
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

[WIP]Support for out-of-tree/external cloud-provider specific drivers #209

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3c3ece3
Add types for MachineClass crd
hardikdr Jan 8, 2019
c26e227
Autogenerated code for machineclass type
hardikdr Jan 8, 2019
9743077
Adapt controllers to work with MachineClass crd
hardikdr Jan 8, 2019
85365bb
Implement grpc based cmi-client for external drivers
hardikdr Jan 8, 2019
c6c537a
Add documentation, sample cluster-role and crd definition for generic…
hardikdr Jan 8, 2019
29078ce
Updated documentation for new provider support
prashanth26 Jan 17, 2019
c8ace63
Update new_cp_support.md (#212)
afritzler Jan 25, 2019
9e21304
Add doc for migration plan to new major version of MCM
hardikdr Feb 13, 2019
1682d75
Updated client and documentation to adapt to new gRPC services (#221)
prashanth26 Feb 13, 2019
a74ea8c
Remove controller code for provider-specific machineclass
hardikdr Feb 14, 2019
4e10edf
Remove APIs for provider-specific machineclasses
hardikdr Feb 14, 2019
8150d2a
Adapt sample files and controller-manager for generic machineclass
hardikdr Feb 14, 2019
98520e1
Auto-generate code after removing provider-specific machineclasses
hardikdr Feb 14, 2019
c05e720
Update vendor after removing the provider-specific machineclass
hardikdr Feb 14, 2019
5082a02
Make gRPC driver configurable via MachineClass
hardikdr Feb 15, 2019
4af8cc3
Fixed empty machineID issue and enhanced print statements (#233)
prashanth26 Mar 4, 2019
9955d0e
Sync with master
hardikdr Jul 1, 2019
9f51d01
Refactored unit tests (#290)
prashanth26 Jul 8, 2019
f7cdab0
Rebase integration test
hardikdr Jul 8, 2019
e51b10e
Updated CI and MCM-CLI client
prashanth26 Jul 9, 2019
a931511
Made additional changes to CI script
prashanth26 Jul 9, 2019
ac4b0c1
CI script has a seperate reference to namespace now
prashanth26 Jul 9, 2019
9f5de17
Updated goModules
prashanth26 Jul 12, 2019
4e1ffc3
Revendored dependencies
prashanth26 Jul 12, 2019
39df213
Refactored to get volume IDs for PVs
prashanth26 Jul 15, 2019
ed93a4c
Fixed checksum issue at vendor
prashanth26 Jul 15, 2019
92a2039
Documentation updated to reflect changes from machine-spec 0.2.0
prashanth26 Jul 24, 2019
1c809dd
Revendored dependency after merge with master
prashanth26 Sep 11, 2019
57dd27a
Renamed driver to CMIClient
prashanth26 Sep 11, 2019
2e9861f
Re-added enqueueSecretAfter method
prashanth26 Sep 11, 2019
3c320c2
Allow machine class secrets to be optional
prashanth26 Sep 12, 2019
86b1a54
Refactor code for machine-spec 0.3.0
prashanth26 Nov 7, 2019
4ed9d65
Realigned Makefile
prashanth26 Nov 7, 2019
f58d861
Merge branch 'master' into cmi-client
prashanth26 Nov 8, 2019
d7bb8e3
Fixed minor issues with unit tests
prashanth26 Nov 8, 2019
490d8c9
Updated machine-spec to version 0.4.0
prashanth26 Nov 25, 2019
6ee7ea1
Updated MachineAPIs to add lastKnownState field
prashanth26 Nov 25, 2019
de94d27
Align implementation to machine-spec 0.4.0
prashanth26 Nov 25, 2019
0c63a1f
Fixed bug in error handling
prashanth26 Nov 26, 2019
ea3aba2
Updated documentation to reflect changes
prashanth26 Nov 27, 2019
5506125
Trying to fix unit-tests
prashanth26 Nov 29, 2019
ae337fb
Refactored code to fix unit tests
prashanth26 Dec 13, 2019
62143e6
Merge branch 'master' into cmi-client
prashanth26 Dec 16, 2019
d13f472
Fixed issues with machineClass periodic re-enqueue
prashanth26 Dec 16, 2019
61ac532
Fixed formatting directive issues
prashanth26 Dec 16, 2019
46ff955
Align implementation to machine-spec 0.5.0
prashanth26 Dec 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 33 additions & 9 deletions .ci/integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ mkdir -p dev
mkdir -p logs

# TODO add support for azure and openstack
declare -a cloud_providers=("aws" "gcp")
declare -a cloud_providers=("aws")
declare failed_logs=""
num_of_existing_nodes=1
namespace="grpc"

if [ -n "$1" ]; then
printf "Local test"
Expand Down Expand Up @@ -90,6 +91,25 @@ function setup_environment() {
printf "Go build Failure\n"
terminate_script
fi

old_WD=$PWD
mkdir -p $GOPATH/src/github.com/gardener
cd $GOPATH/src/github.com/gardener

# TODO: fetch the latest release and not master of aws-provider
printf "\n Download machiine-controller-manager-provider-aws latest release"
git clone https://github.com/gardener/machine-controller-manager-provider-aws.git
printf "\...Done \n"

cd machine-controller-manager-provider-aws
printf "\nBuilding MCM-Provider-AWS binary\n"
if go build -o $old_WD/cmi-plugin -i app/aws/cmi-plugin.go; then
printf "Go build Successful for provider AWS\n"
else
printf "Go build Failure for provider AWS\n"
terminate_script
fi
cd $old_WD
}

# run_controller runs MCM controller in background
Expand All @@ -99,7 +119,7 @@ function run_controller() {
./controller_manager \
--control-kubeconfig=dev/control_kubeconfig_${provider}.yaml \
--target-kubeconfig=dev/target_kubeconfig_${provider}.yaml \
--namespace=${provider} \
--namespace=$namespace \
--port=$1 \
--safety-up=2 \
--safety-down=1 \
Expand All @@ -114,15 +134,19 @@ function run_controller() {
--leader-elect-renew-deadline=30s \
--leader-elect-retry-period=15s \
--v=2 > logs/${provider}-mcm.out 2>&1 &

printf "\nRunning MCM-Provider-AWS in background\n"
./cmi-plugin \
--endpoint=tcp://127.0.0.1:8080 > logs/${provider}-mcm-provider.out 2>&1 &
}

############################################## </Intialization> ##############################################
############################################## <HelperFunction> ##############################################

function hf_object_create() {
output=$(kubectl apply -f "$Objects_path"/"$1" --context=control 2>&1)
outputSucccess=$(echo "$output" | grep created -c)
if [[ outputSucccess -ne 1 ]]; then
outputSuccess=$(echo "$output" | grep created -c)
if [[ outputSuccess -ne 1 ]]; then
printf "\tFailed: To create object. Exiting Test to avoid further conflicts.\n"
printf "\tCreate error message: %s" "$output"
terminate_script
Expand Down Expand Up @@ -156,7 +180,7 @@ function hf_object_delete() {
}

function hf_scale_deploy() {
output=$(kubectl scale deployment "$1" --replicas="$2" --context=control --namespace="$provider" 2>&1)
output=$(kubectl scale deployment "$1" --replicas="$2" --context=control --namespace="$namespace" 2>&1)
outputSucccess=$(echo "$output" | grep scaled -c)
if [[ outputSucccess -ne 1 ]]; then
printf "\tFailed: To scale deployment object. Exiting Test to avoid further conflicts.\n"
Expand All @@ -166,7 +190,7 @@ function hf_scale_deploy() {
}

function hf_num_of_objects() {
output=$(kubectl -n $provider get "$1" --context=control 2>&1)
output=$(kubectl -n $namespace get "$1" --context=control 2>&1)
if [[ $output == *"No resources found."* ]]; then
return 0
fi
Expand Down Expand Up @@ -304,7 +328,7 @@ function clean_up() {
[[ $ret -ne 0 ]]
then
# Delete the machine-deployment
output=$(kubectl delete machdeploy --context=control --namespace="$provider" --all 2>&1)
output=$(kubectl delete machdeploy --context=control --namespace="$namespace" --all 2>&1)
printf "\n\t%s" "$output"
printf "\n\tWaiting 1800s for machine-deployment to be deleted"
hf_wait_on "hf_num_of_objects" machdeploy 0 1800 $5
Expand All @@ -316,7 +340,7 @@ function clean_up() {
[[ $ret -ne 0 ]]
then
# Delete the machine-set
output=$(kubectl delete machset --context=control --namespace="$provider" --all 2>&1)
output=$(kubectl delete machset --context=control --namespace="$namespace" --all 2>&1)
printf "\n\t%s" "$output"
printf "\n\tWaiting 1800s for machine-set to be deleted"
hf_wait_on "hf_num_of_objects" machdeploy 0 1800 $5
Expand All @@ -328,7 +352,7 @@ function clean_up() {
[[ $ret -ne 0 ]]
then
# Delete the machine
output=$(kubectl delete mach --context=control --namespace="$provider" --all 2>&1)
output=$(kubectl delete mach --context=control --namespace="$namespace" --all 2>&1)
printf "\n\t%s" "$output"
printf "\n\tWaiting 1800s for machine to be deleted"
hf_wait_on "hf_num_of_objects" mach 0 1800 $5
Expand Down
5 changes: 3 additions & 2 deletions .ci/sample-objects/aws/machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ apiVersion: machine.sapcloud.io/v1alpha1
kind: Machine
metadata:
name: test-machine # Name of the machine to be created
namespace: aws
namespace: grpc
labels:
test-label: test-label # Label used by machine-set to match (optional)
spec:
class:
kind: AWSMachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
kind: MachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
namespace: grpc
7 changes: 4 additions & 3 deletions .ci/sample-objects/aws/md-scale-down.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: machine.sapcloud.io/v1alpha1
kind: MachineDeployment
metadata:
name: test-md # Name of the machine deploy
namespace: aws
namespace: grpc
spec:
replicas: 2 # Number of healthy replicas that should always be healthy
minReadySeconds: 500 # Minimum time to wait for machine to be ready
Expand All @@ -23,5 +23,6 @@ spec:
test-label: test-label # Label to match with selector (XXXXX)
spec:
class:
kind: AWSMachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
kind: MachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
namespace: grpc
7 changes: 4 additions & 3 deletions .ci/sample-objects/aws/md-scale-up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: machine.sapcloud.io/v1alpha1
kind: MachineDeployment
metadata:
name: test-md # Name of the machine deploy
namespace: aws
namespace: grpc
spec:
replicas: 6 # Number of healthy replicas that should always be healthy
minReadySeconds: 500 # Minimum time to wait for machine to be ready
Expand All @@ -23,5 +23,6 @@ spec:
test-label: test-label # Label to match with selector (XXXXX)
spec:
class:
kind: AWSMachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
kind: MachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
namespace: grpc
7 changes: 4 additions & 3 deletions .ci/sample-objects/aws/md-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: machine.sapcloud.io/v1alpha1
kind: MachineDeployment
metadata:
name: test-md # Name of the machine deploy
namespace: aws
namespace: grpc
spec:
replicas: 4 # Number of healthy replicas that should always be healthy
minReadySeconds: 500 # Minimum time to wait for machine to be ready
Expand All @@ -23,5 +23,6 @@ spec:
test-label: test-label # Label to match with selector (XXXXX)
spec:
class:
kind: AWSMachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v2 # Name of the machine class
kind: MachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v2 # Name of the machine class
namespace: grpc
7 changes: 4 additions & 3 deletions .ci/sample-objects/aws/md.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: machine.sapcloud.io/v1alpha1
kind: MachineDeployment
metadata:
name: test-md # Name of the machine deploy
namespace: aws
namespace: grpc
spec:
replicas: 3 # Number of healthy replicas that should always be healthy
minReadySeconds: 500 # Minimum time to wait for machine to be ready
Expand All @@ -23,5 +23,6 @@ spec:
test-label: test-label # Label to match with selector (XXXXX)
spec:
class:
kind: AWSMachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
kind: MachineClass # Machine class template used to create machine, could be AWS/GCP/Azure/Other-cloud-providers
name: mc-v1 # Name of the machine class
namespace: grpc
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ kubectl
# Binary files of MCM
./machine-controller-manager
./managevm
cmi-plugin

# Output of the go coverage tool, specifically when used with LiteIDE
*coverprofile.out*
43 changes: 10 additions & 33 deletions cmd/machine-controller-manager-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"

"github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1"
"github.com/gardener/machine-controller-manager/pkg/driver"
"github.com/gardener/machine-controller-manager/pkg/cmiclient"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/yaml"
)
Expand Down Expand Up @@ -61,36 +61,10 @@ func main() {
}

switch classKind {
case "OpenStackMachineClass", "openstack":
class := v1alpha1.OpenStackMachineClass{}
case "MachineClass", "machineclass":
class := v1alpha1.MachineClass{}
machineclass = &class
classKind = "OpenStackMachineClass"

case "AWSMachineClass", "aws":
class := v1alpha1.AWSMachineClass{}
machineclass = &class
classKind = "AWSMachineClass"

case "AzureMachineClass", "azure":
class := v1alpha1.AzureMachineClass{}
machineclass = &class
classKind = "AzureMachineClass"

case "GCPMachineClass", "gcp":
class := v1alpha1.GCPMachineClass{}
machineclass = &class
classKind = "GCPMachineClass"

case "AlicloudMachineClass", "alicloud":
class := v1alpha1.AlicloudMachineClass{}
machineclass = &class
classKind = "AlicloudMachineClass"

case "PacketMachineClass", "packet":
class := v1alpha1.PacketMachineClass{}
machineclass = &class
classKind = "PacketMachineClass"

classKind = "MachineClass"
default:
log.Fatalf("Unknown class kind %s", classKind)
}
Expand All @@ -99,17 +73,20 @@ func main() {
log.Fatalf("Could not parse machine class yaml: %s", err)
}

driver := driver.NewDriver(machineID, &secret, classKind, machineclass, machineName)
cmiclient, err := cmiclient.NewCMIPluginClient(machineID, classKind, &secret, machineclass, machineName, "")
if err != nil {
log.Fatalf("Couldn't create CMIDirver client : %s", err)
}

if machineID == "" {
id, name, err := driver.Create()
id, name, _, err := cmiclient.CreateMachine()
if err != nil {
log.Fatalf("Could not create %s : %s", machineName, err)
}
fmt.Printf("Machine id: %s\n", id)
fmt.Printf("Name: %s\n", name)
} else {
err = driver.Delete()
_, err = cmiclient.DeleteMachine()
if err != nil {
log.Fatalf("Could not delete %s : %s", machineID, err)
}
Expand Down
18 changes: 4 additions & 14 deletions cmd/machine-controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ const (
controllerDiscoveryAgentName = "machine-controller-discovery"
)

var openStackGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "openstackmachineclasses"}
var awsGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "awsmachineclasses"}
var azureGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "azuremachineclasses"}
var gcpGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "gcpmachineclasses"}
var alicloudGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "alicloudmachineclasses"}
var packetGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "packetmachineclasses"}
var machineclassGVR = schema.GroupVersionResource{Group: "machine.sapcloud.io", Version: "v1alpha1", Resource: "machineclasses"}

// Run runs the MCMServer. This should never exit.
func Run(s *options.MCMServer) error {
Expand Down Expand Up @@ -222,7 +217,7 @@ func StartControllers(s *options.MCMServer,
glog.Fatal(err)
}

if availableResources[awsGVR] || availableResources[azureGVR] || availableResources[gcpGVR] || availableResources[openStackGVR] || availableResources[alicloudGVR] || availableResources[packetGVR] {
if availableResources[machineclassGVR] {
glog.V(5).Infof("Creating shared informers; resync interval: %v", s.MinResyncPeriod)

controlMachineInformerFactory := machineinformers.NewFilteredSharedInformerFactory(
Expand Down Expand Up @@ -257,12 +252,7 @@ func StartControllers(s *options.MCMServer,
targetCoreInformerFactory.Core().V1().PersistentVolumes(),
controlCoreInformerFactory.Core().V1().Secrets(),
targetCoreInformerFactory.Core().V1().Nodes(),
machineSharedInformers.OpenStackMachineClasses(),
machineSharedInformers.AWSMachineClasses(),
machineSharedInformers.AzureMachineClasses(),
machineSharedInformers.GCPMachineClasses(),
machineSharedInformers.AlicloudMachineClasses(),
machineSharedInformers.PacketMachineClasses(),
machineSharedInformers.MachineClasses(),
machineSharedInformers.Machines(),
machineSharedInformers.MachineSets(),
machineSharedInformers.MachineDeployments(),
Expand All @@ -283,7 +273,7 @@ func StartControllers(s *options.MCMServer,
go machineController.Run(int(s.ConcurrentNodeSyncs), stop)

} else {
return fmt.Errorf("unable to start machine controller: API GroupVersion %q or %q or %q or %q or %q or %q is not available; found %#v", awsGVR, azureGVR, gcpGVR, openStackGVR, alicloudGVR, packetGVR, availableResources)
return fmt.Errorf("unable to start machine controller: API GroupVersion %q is not available; found %#v", machineclassGVR, availableResources)
}

select {}
Expand Down
Loading