Skip to content

Commit

Permalink
[PTX-1641] Added AKS node driver
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakshnd committed Jan 22, 2020
1 parent 5644fcc commit 13fb53f
Show file tree
Hide file tree
Showing 190 changed files with 50,812 additions and 735 deletions.
129 changes: 112 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion deployments/deploy-ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ if [ -z "$STORAGENODE_RECOVERY_TIMEOUT" ]; then
echo "Using default storage node recovery timeout of ${STORAGENODE_RECOVERY_TIMEOUT}"
fi

AZURE_TENANTID=""
if [ -n "$AZURE_TENANT_ID" ]; then
AZURE_TENANTID="${AZURE_TENANT_ID}"
fi

AZURE_CLIENTID=""
if [ -n "$AZURE_CLIENT_ID" ]; then
AZURE_CLIENTID="${AZURE_CLIENT_ID}"
fi

AZURE_CLIENTSECRET=""
if [ -n "$AZURE_CLIENT_SECRET" ]; then
AZURE_CLIENTSECRET="${AZURE_CLIENT_SECRET}"
fi

if [ -z "$TEST_SUITE" ]; then
TEST_SUITE='"bin/asg.test",
"bin/autopilot-capacity.test",
Expand Down Expand Up @@ -183,6 +198,7 @@ if [ -n "${K8S_VENDOR}" ]; then
K8S_VENDOR_KEY=px/enabled
K8S_VENDOR_OPERATOR="In"
K8S_VENDOR_VALUE='values: ["false"]'
NODE_DRIVER="aks"
;;
eks)
# Run torpedo on worker node, where px installation is disabled.
Expand Down Expand Up @@ -306,6 +322,12 @@ spec:
value: "${TORPEDO_SSH_PASSWORD}"
- name: TORPEDO_SSH_KEY
value: "${TORPEDO_SSH_KEY}"
- name: AZURE_TENANT_ID
value: "${AZURE_TENANTID}"
- name: AZURE_CLIENT_ID
value: "${AZURE_CLIENTID}"
- name: AZURE_CLIENT_SECRET
value: "${AZURE_CLIENTSECRET}"
volumes: [${VOLUMES}]
restartPolicy: Never
serviceAccountName: torpedo-account
Expand Down Expand Up @@ -337,4 +359,4 @@ for i in $(seq 1 600) ; do
done

echo "Error: Failed to wait for torpedo to start running..."
describe_pod_then_exit
describe_pod_then_exit
80 changes: 80 additions & 0 deletions drivers/node/aks/aks.go
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)
}
5 changes: 3 additions & 2 deletions drivers/node/gke/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ func (g *gke) Init() error {
return nil
}

func (g *gke) SetASGClusterSize(count int64, timeout time.Duration) error {
err := g.ops.SetInstanceGroupSize(g.instanceGroup, count, timeout)
func (g *gke) SetASGClusterSize(perZoneCount int64, timeout time.Duration) error {
// GCP SDK requires per zone cluster size
err := g.ops.SetInstanceGroupSize(g.instanceGroup, perZoneCount, timeout)
if err != nil {
logrus.Errorf("failed to set size of node pool %s. Error: %v", g.instanceGroup, err)
return err
Expand Down
Loading

0 comments on commit 13fb53f

Please sign in to comment.