Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
Add networkpool support on AWS Clusters (#577)
Browse files Browse the repository at this point in the history
* Add networkpool support on AWS Clusters

* Add changelog

* Add NetworkPool test

* Add empty NetworkPool test
  • Loading branch information
paurosello authored Oct 2, 2020
1 parent 88af39a commit 99fa9ca
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add NetworkPool option for ClusterCRsConfig

## [2.5.2] - 2020-10-01

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: infrastructure.giantswarm.io/v1alpha2
kind: AWSCluster
metadata:
annotations:
giantswarm.io/docs: https://docs.giantswarm.io/reference/cp-k8s-api/awsclusters.infrastructure.giantswarm.io/
creationTimestamp: null
name: asj5e
spec:
cluster:
description: Dev cluster
dns:
domain: g8s.example.com
kubeProxy:
conntrackMaxPerCore: 100000
oidc:
claims:
groups: groups-field
username: username-field
clientID: some-example-client-id
issuerURL: https://idp.example.com/
provider:
credentialSecret:
name: example-credential
namespace: example-namespace
master:
availabilityZone: eu-central-1b
instanceType: m5.2xlarge
nodes:
networkPool: custom
pods:
cidrBlock: 10.2.0.0/16
externalSNAT: true
region: eu-central-1
93 changes: 93 additions & 0 deletions pkg/apis/infrastructure/v1alpha2/aws_cluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ func Test_GenerateAWSClusterYAML(t *testing.T) {
name: fmt.Sprintf("%s_%s_awscluster.yaml", group, version),
resource: newAWSClusterExampleCR(),
},
{
category: "cr",
name: fmt.Sprintf("%s_%s_awscluster.yaml", group, version),
resource: newAWSClusterEmptyNetworkPoolCR(),
},
{
category: "cr",
name: fmt.Sprintf("%s_%s_awscluster_networkpool.yaml", group, version),
resource: newAWSClusterNetworkPoolCR(),
},
}

docs := filepath.Join(root, "..", "..", "..", "..", "docs")
Expand Down Expand Up @@ -144,3 +154,86 @@ func newAWSClusterExampleCR() *AWSCluster {

return cr
}

func newAWSClusterEmptyNetworkPoolCR() *AWSCluster {
awscluster := newAWSClusterExampleCR()

awscluster.Spec.Provider.Nodes = AWSClusterSpecProviderNodes{
NetworkPool: "",
}

return awscluster
}

func newAWSClusterNetworkPoolCR() *AWSCluster {
cr := NewAWSClusterCR()

externalSNAT := true

cr.Name = "asj5e"
cr.Spec = AWSClusterSpec{
Cluster: AWSClusterSpecCluster{
Description: "Dev cluster",
DNS: AWSClusterSpecClusterDNS{
Domain: "g8s.example.com",
},
KubeProxy: AWSClusterSpecClusterKubeProxy{
ConntrackMaxPerCore: 100000,
},
OIDC: AWSClusterSpecClusterOIDC{
Claims: AWSClusterSpecClusterOIDCClaims{
Username: "username-field",
Groups: "groups-field",
},
ClientID: "some-example-client-id",
IssuerURL: "https://idp.example.com/",
},
},
Provider: AWSClusterSpecProvider{
CredentialSecret: AWSClusterSpecProviderCredentialSecret{
Name: "example-credential",
Namespace: "example-namespace",
},
Pods: AWSClusterSpecProviderPods{
CIDRBlock: "10.2.0.0/16",
ExternalSNAT: &externalSNAT,
},
Nodes: AWSClusterSpecProviderNodes{
NetworkPool: "custom",
},
Master: AWSClusterSpecProviderMaster{
AvailabilityZone: "eu-central-1b",
InstanceType: "m5.2xlarge",
},
Region: "eu-central-1",
},
}
cr.Status = AWSClusterStatus{
Cluster: CommonClusterStatus{
Conditions: []CommonClusterStatusCondition{
{
LastTransitionTime: metav1.Date(2020, 4, 16, 12, 51, 33, 432, time.UTC),
Condition: "Created",
},
{
LastTransitionTime: metav1.Date(2020, 4, 16, 12, 35, 33, 432, time.UTC),
Condition: "Creating",
},
},
ID: "g8kw3",
Versions: []CommonClusterStatusVersion{
{
LastTransitionTime: metav1.Now(),
Version: "8.2.3",
},
},
},
Provider: AWSClusterStatusProvider{
Network: AWSClusterStatusProviderNetwork{
CIDR: "172.19.73.0/24",
},
},
}

return cr
}
4 changes: 4 additions & 0 deletions pkg/apis/infrastructure/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type ClusterCRsConfig struct {
ReleaseComponents map[string]string
ReleaseVersion string
Labels map[string]string
NetworkPool string
}

// +k8s:deepcopy-gen=false
Expand Down Expand Up @@ -104,6 +105,9 @@ func newAWSClusterCR(c ClusterCRsConfig) *AWSCluster {
CIDRBlock: c.PodsCIDR,
ExternalSNAT: &c.ExternalSNAT,
},
Nodes: AWSClusterSpecProviderNodes{
NetworkPool: c.NetworkPool,
},
Region: c.Region,
},
},
Expand Down

0 comments on commit 99fa9ca

Please sign in to comment.