/
infrastructure.go
98 lines (89 loc) · 2.6 KB
/
infrastructure.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package model
import (
"github.com/kyma-incubator/compass/components/provisioner/internal/model/infrastructure/aws"
"github.com/kyma-incubator/compass/components/provisioner/internal/model/infrastructure/azure"
"github.com/kyma-incubator/compass/components/provisioner/internal/model/infrastructure/gcp"
"github.com/kyma-incubator/compass/components/provisioner/internal/util"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
infrastructureConfigKind = "InfrastructureConfig"
controlPlaneConfigKind = "ControlPlaneConfig"
gcpAPIVersion = "gcp.provider.extensions.gardener.cloud/v1alpha1"
azureAPIVersion = "azure.provider.extensions.gardener.cloud/v1alpha1"
awsAPIVersion = "aws.provider.extensions.gardener.cloud/v1alpha1"
)
func NewGCPInfrastructure(workerCIDR string) *gcp.InfrastructureConfig {
return &gcp.InfrastructureConfig{
TypeMeta: v1.TypeMeta{
Kind: infrastructureConfigKind,
APIVersion: gcpAPIVersion,
},
Networks: gcp.NetworkConfig{
Worker: workerCIDR,
Workers: util.StringPtr(workerCIDR),
},
}
}
func NewGCPControlPlane(zones []string) *gcp.ControlPlaneConfig {
return &gcp.ControlPlaneConfig{
TypeMeta: v1.TypeMeta{
Kind: controlPlaneConfigKind,
APIVersion: gcpAPIVersion,
},
Zone: zones[0],
}
}
func NewAzureInfrastructure(workerCIDR string, azConfig AzureGardenerConfig) *azure.InfrastructureConfig {
isZoned := len(azConfig.input.Zones) > 0
return &azure.InfrastructureConfig{
TypeMeta: v1.TypeMeta{
Kind: infrastructureConfigKind,
APIVersion: azureAPIVersion,
},
Networks: azure.NetworkConfig{
Workers: workerCIDR,
VNet: azure.VNet{
CIDR: &azConfig.input.VnetCidr,
},
},
Zoned: isZoned,
}
}
func NewAzureControlPlane(zones []string) *azure.ControlPlaneConfig {
return &azure.ControlPlaneConfig{
TypeMeta: v1.TypeMeta{
Kind: controlPlaneConfigKind,
APIVersion: azureAPIVersion,
},
}
}
func NewAWSInfrastructure(workerCIDR string, awsConfig AWSGardenerConfig) *aws.InfrastructureConfig {
return &aws.InfrastructureConfig{
TypeMeta: v1.TypeMeta{
Kind: infrastructureConfigKind,
APIVersion: awsAPIVersion,
},
Networks: aws.Networks{
Zones: []aws.Zone{
{
Name: awsConfig.input.Zone,
Internal: awsConfig.input.InternalCidr,
Public: awsConfig.input.PublicCidr,
Workers: workerCIDR,
},
},
VPC: aws.VPC{
CIDR: util.StringPtr(awsConfig.input.VpcCidr),
},
},
}
}
func NewAWSControlPlane() *aws.ControlPlaneConfig {
return &aws.ControlPlaneConfig{
TypeMeta: v1.TypeMeta{
Kind: controlPlaneConfigKind,
APIVersion: awsAPIVersion,
},
}
}