-
Notifications
You must be signed in to change notification settings - Fork 30
/
main.go
84 lines (78 loc) · 2.55 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"context"
"log"
"github.com/spotinst/spotinst-sdk-go/service/ocean"
"github.com/spotinst/spotinst-sdk-go/service/ocean/spark"
"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()
// Update cluster configuration.
_, err := svc.Spark().UpdateCluster(ctx, &spark.UpdateClusterInput{
ClusterID: spotinst.String("osc-12345"),
Cluster: &spark.UpdateClusterRequest{
Config: &spark.Config{
LogCollection: &spark.LogCollectionConfig{
CollectAppLogs: spotinst.Bool(true),
},
Compute: &spark.ComputeConfig{
UseTaints: spotinst.Bool(true),
CreateVngs: spotinst.Bool(true),
},
Ingress: &spark.IngressConfig{
ServiceAnnotations: map[string]string{
"my-custom-annotation": "custom_value",
},
Controller: &spark.IngressConfigController{
Managed: spotinst.Bool(true),
},
CustomEndpoint: &spark.IngressConfigCustomEndpoint{
Enabled: spotinst.Bool(false),
Address: spotinst.String("custom-endpoint-address"),
},
LoadBalancer: &spark.IngressConfigLoadBalancer{
Managed: spotinst.Bool(true),
TargetGroupARN: spotinst.String("target-group-arn"),
ServiceAnnotations: map[string]string{
"lb-service-annotation": "lb-service-annotation-value",
},
},
PrivateLink: &spark.IngressConfigPrivateLink{
Enabled: spotinst.Bool(false),
VPCEndpointService: spotinst.String("vpc-endpoint-service"),
},
},
Webhook: &spark.WebhookConfig{
UseHostNetwork: spotinst.Bool(true),
HostNetworkPorts: spotinst.IntSlice([]int{
2000,
}),
},
Spark: &spark.SparkConfig{
AppNamespaces: spotinst.StringSlice([]string{
"spark-apps",
"spark-apps-extra-ns-1",
"spark-apps-extra-ns-2",
}),
},
},
},
})
if err != nil {
log.Fatalf("spotinst: failed to update cluster: %v", err)
}
}