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

Added support for cluster roll #279

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions examples/service/ocean/providers/azure/clusterroll/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/ocean/providers/azure"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
"log"

"github.com/spotinst/spotinst-sdk-go/service/ocean"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)

func main() {
// All clients require a Session. The Session provides the client with
// shared configuration such as account and credentials.
// A Session should be shared where possible to take advantage of
// configuration and credential caching. See the session package for
// more information.
sess := session.New()

// Create a new instance of the service's client with a Session.
// Optional spotinst.Config values can also be provided as variadic
// arguments to the New function. This option allows you to provide
// service specific configuration.
svc := ocean.New(sess)

// Create a new context.
ctx := context.Background()

// Trigger cluster roll.
out, err := svc.CloudProviderAzure().CreateRoll(ctx, &azure.CreateRollInput{
Roll: &azure.RollSpec{
ClusterID: spotinst.String("o-12345"),
BatchSizePercentage: spotinst.Int(20),
Comment: spotinst.String("Comment to describe roll."),
RespectPDB: spotinst.Bool(true),
BatchMinHealthyPercentage: spotinst.Int(100),
NodeNames: []string{"node123"},
VngIds: []string{"vng-123"},
NodePoolNames: []string{"nodepool12345", "nodepool67890"},
sharadkesarwani marked this conversation as resolved.
Show resolved Hide resolved
RespectRestrictScaleDown: spotinst.Bool(true),
},
})
if err != nil {
log.Fatalf("spotinst: failed to roll cluster: %v", err)
}

if (out.Roll) != nil {
log.Printf("Roll details: %q: %s",
spotinst.StringValue(out.Roll.ID),
stringutil.Stringify(out))
}
}
46 changes: 46 additions & 0 deletions examples/service/ocean/providers/azure/listrolls/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/ocean/providers/azure"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
"log"

"github.com/spotinst/spotinst-sdk-go/service/ocean"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)

func main() {
// All clients require a Session. The Session provides the client with
// shared configuration such as account and credentials.
// A Session should be shared where possible to take advantage of
// configuration and credential caching. See the session package for
// more information.
sess := session.New()

// Create a new instance of the service's client with a Session.
// Optional spotinst.Config values can also be provided as variadic
// arguments to the New function. This option allows you to provide
// service specific configuration.
svc := ocean.New(sess)

// Create a new context.
ctx := context.Background()

// List cluster roll.
out, err := svc.CloudProviderAzure().ListRolls(ctx, &azure.ListRollsInput{
ClusterID: spotinst.String("o-12345"),
})
if err != nil {
log.Fatalf("spotinst: failed to list roll: %v", err)
}

if len(out.Rolls) > 0 {
for _, roll := range out.Rolls {
log.Printf("Roll %q: %s",
spotinst.StringValue(roll.ID),
stringutil.Stringify(roll))
}
}
}
45 changes: 45 additions & 0 deletions examples/service/ocean/providers/azure/readroll/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/ocean/providers/azure"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
"log"

"github.com/spotinst/spotinst-sdk-go/service/ocean"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)

func main() {
// All clients require a Session. The Session provides the client with
// shared configuration such as account and credentials.
// A Session should be shared where possible to take advantage of
// configuration and credential caching. See the session package for
// more information.
sess := session.New()

// Create a new instance of the service's client with a Session.
// Optional spotinst.Config values can also be provided as variadic
// arguments to the New function. This option allows you to provide
// service specific configuration.
svc := ocean.New(sess)

// Create a new context.
ctx := context.Background()

// Read cluster roll.
out, err := svc.CloudProviderAzure().ReadRoll(ctx, &azure.ReadRollInput{
ClusterID: spotinst.String("o-12345"),
RollID: spotinst.String("scr-12345"),
})
if err != nil {
log.Fatalf("spotinst: failed to read roll: %v", err)
}

if (out.Roll) != nil {
log.Printf("Roll details: %q: %s",
spotinst.StringValue(out.Roll.ID),
stringutil.Stringify(out))
}
}
47 changes: 47 additions & 0 deletions examples/service/ocean/providers/azure/stoproll/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/ocean/providers/azure"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
"log"

"github.com/spotinst/spotinst-sdk-go/service/ocean"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)

func main() {
// All clients require a Session. The Session provides the client with
// shared configuration such as account and credentials.
// A Session should be shared where possible to take advantage of
// configuration and credential caching. See the session package for
// more information.
sess := session.New()

// Create a new instance of the service's client with a Session.
// Optional spotinst.Config values can also be provided as variadic
// arguments to the New function. This option allows you to provide
// service specific configuration.
svc := ocean.New(sess)

// Create a new context.
ctx := context.Background()

// Stop cluster roll.
out, err := svc.CloudProviderAzure().StopRoll(ctx, &azure.StopRollInput{
ClusterID: spotinst.String("o-12345"),
RollID: spotinst.String("scr-7890"),
})
if err != nil {
log.Fatalf("spotinst: failed to stop roll: %v", err)
}

if len(out.Rolls) > 0 {
for _, roll := range out.Rolls {
log.Printf("Roll %q: %s",
spotinst.StringValue(roll.ID),
stringutil.Stringify(roll))
}
}
}
Loading
Loading