-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from portworx/PTX-1641-2
[PTX-1641] Add AKS node driver
- Loading branch information
Showing
192 changed files
with
47,686 additions
and
2,167 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
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,80 @@ | ||
package aks | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"github.com/libopenstorage/cloudops" | ||
"github.com/libopenstorage/cloudops/azure" | ||
"github.com/portworx/torpedo/drivers/node" | ||
"github.com/portworx/torpedo/drivers/node/ssh" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
const ( | ||
// DriverName is the name of the gke driver | ||
DriverName = "aks" | ||
// ZoneCount number of zones in autoscaling group | ||
ZoneCount = 3 | ||
) | ||
|
||
type aks struct { | ||
ssh.SSH | ||
ops cloudops.Ops | ||
instanceGroup string | ||
} | ||
|
||
func (a *aks) String() string { | ||
return DriverName | ||
} | ||
|
||
func (a *aks) Init() error { | ||
|
||
instanceGroup := os.Getenv("INSTANCE_GROUP") | ||
if len(instanceGroup) != 0 { | ||
a.instanceGroup = instanceGroup | ||
} else { | ||
a.instanceGroup = "nodepool1" | ||
} | ||
|
||
ops, err := azure.NewClientFromMetadata() | ||
if err != nil { | ||
return err | ||
} | ||
a.ops = ops | ||
|
||
return nil | ||
} | ||
|
||
func (a *aks) SetASGClusterSize(perZoneCount int64, timeout time.Duration) error { | ||
// Azure SDK requires total cluster size | ||
totalClusterSize := perZoneCount * ZoneCount | ||
err := a.ops.SetInstanceGroupSize(a.instanceGroup, totalClusterSize, timeout) | ||
if err != nil { | ||
logrus.Errorf("failed to set size of node pool %s. Error: %v", a.instanceGroup, err) | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (a *aks) GetASGClusterSize() (int64, error) { | ||
nodeCount, err := a.ops.GetInstanceGroupSize(a.instanceGroup) | ||
if err != nil { | ||
logrus.Errorf("failed to get size of node pool %s. Error: %v", a.instanceGroup, err) | ||
return 0, err | ||
} | ||
|
||
return nodeCount, nil | ||
} | ||
|
||
func init() { | ||
|
||
SSHDriver := ssh.SSH{} | ||
SSHDriver.Init() | ||
g := &aks{ | ||
SSH: SSHDriver, | ||
} | ||
|
||
node.Register(DriverName, g) | ||
} |
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
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
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
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
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
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
Oops, something went wrong.