-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
AKS: NetworkProfile / Advanced Networking #1479
Merged
tombuildsstuff
merged 37 commits into
hashicorp:master
from
lfshr:containerservices-advancednetworking
Jul 25, 2018
Merged
Changes from 20 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
5865322
Added kubernetes_cluster advanced network creation
lfshr 305c1d0
Changed network_profile from TypeSet to TypeList
lfshr df237b2
Added kubernetes_cluster advanced network creation
lfshr e3ec37e
Changed network_profile from TypeSet to TypeList
lfshr a3ff5b0
Merge branch 'containerservices-advancednetworking' of https://github…
lfshr b7d274b
Updated ForceNew attributes on kubernetes_cluster.network_profile params
lfshr 11bed67
Added advanced network read functionality
lfshr 30f39ff
Added tests for kubernetes_cluster.network_profile
lfshr 195e7d6
Fixed indentations
lfshr f8f5626
Fixed function name in tests
lfshr 25c6e6e
Fixed property name in test
lfshr 48cff90
Fixed variable name
lfshr 2dd887c
working on data source for kubernetes cluster
lfshr 1bdf8b6
Merge branch 'containerservices-advancednetworking' of https://github…
lfshr 33c84c6
Fixed issue with datasource not working
lfshr f9786e1
Added network_policy and fixed read
lfshr 02b22e5
Removed network_policy as unsupported
lfshr b62a643
Added example of advanced networking
lfshr 377c52f
Added test for data_source
lfshr 7453f41
Made address space more sensible
lfshr c90ea55
Removing kubenet test.
lfshr 16e7d3e
Made network_plugin a mandatory field.
lfshr 675d0b9
Updated documentation to include network_profile
lfshr 7c21183
Fixing the build
tombuildsstuff 1959c2f
Added ForceNew to network_profile
lfshr 518cacc
Made the docs a little clearer
lfshr 9faeb69
Documenting a required field
tombuildsstuff 1ef6ccf
Rephrasing the data sources
tombuildsstuff dac7913
Making the `network_profile` block computed
tombuildsstuff 48d5ed7
Fixing the field we're asserting on
tombuildsstuff a54aa89
Conditionally expanding the network_profile block.
tombuildsstuff 9e862eb
Validation to ensure that a Subnet ID is assigned to the cluster when…
tombuildsstuff f2219c5
Updating the documentation to mention the new behaviour
tombuildsstuff 8a23d24
Adding independent tests for Kubenet and Azure networking profiles
tombuildsstuff 8d08c53
Conditional validation of the `docker_bridge_cidr`, `dns_service_ip` …
tombuildsstuff a72f105
Updating the docs
tombuildsstuff ff3e206
Fixing the tests
tombuildsstuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,6 +209,48 @@ func resourceArmKubernetesCluster() *schema.Resource { | |
Set: resourceAzureRMKubernetesClusterServicePrincipalProfileHash, | ||
}, | ||
|
||
"network_profile": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we document this block/these new fields here? (I've had to link to the Blame since you can't link to a regular line in a Markdown file in Github ¯_(ツ)_/¯) |
||
Type: schema.TypeList, | ||
Optional: true, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
|
||
"network_plugin": { | ||
Type: schema.TypeString, | ||
Default: "azure", | ||
Optional: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"service_cidr": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"dns_service_ip": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"docker_bridge_cidr": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"pod_cidr": { | ||
Type: schema.TypeString, | ||
Default: "10.244.0.0/24", | ||
Optional: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"tags": tagsSchema(), | ||
}, | ||
} | ||
|
@@ -229,6 +271,7 @@ func resourceArmKubernetesClusterCreate(d *schema.ResourceData, meta interface{} | |
linuxProfile := expandAzureRmKubernetesClusterLinuxProfile(d) | ||
agentProfiles := expandAzureRmKubernetesClusterAgentProfiles(d) | ||
servicePrincipalProfile := expandAzureRmKubernetesClusterServicePrincipal(d) | ||
networkProfile := expandAzureRmKubernetesClusterNetworkProfile(d) | ||
|
||
tags := d.Get("tags").(map[string]interface{}) | ||
|
||
|
@@ -241,6 +284,7 @@ func resourceArmKubernetesClusterCreate(d *schema.ResourceData, meta interface{} | |
KubernetesVersion: &kubernetesVersion, | ||
LinuxProfile: &linuxProfile, | ||
ServicePrincipalProfile: servicePrincipalProfile, | ||
NetworkProfile: networkProfile, | ||
}, | ||
Tags: expandTags(tags), | ||
} | ||
|
@@ -324,6 +368,12 @@ func resourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{}) | |
} | ||
} | ||
|
||
networkProfile := flattenKubernetesClusterDataSourceNetworkProfile(resp.NetworkProfile) | ||
|
||
if err := d.Set("network_profile", networkProfile); err != nil { | ||
return fmt.Errorf("Error setting `network_profile`: %+v", err) | ||
} | ||
|
||
kubeConfigRaw, kubeConfig := flattenAzureRmKubernetesClusterAccessProfile(&profile) | ||
d.Set("kube_config_raw", kubeConfigRaw) | ||
|
||
|
@@ -469,6 +519,30 @@ func flattenAzureRmKubernetesClusterAccessProfile(profile *containerservice.Mana | |
return nil, []interface{}{} | ||
} | ||
|
||
func flattenAzureRmKubernetesClusterNetworkProfile(profile *containerservice.NetworkProfile) []interface{} { | ||
values := make(map[string]interface{}) | ||
|
||
values["network_plugin"] = profile.NetworkPlugin | ||
|
||
if profile.ServiceCidr != nil { | ||
values["service_cidr"] = *profile.ServiceCidr | ||
} | ||
|
||
if profile.DNSServiceIP != nil { | ||
values["dns_service_ip"] = *profile.DNSServiceIP | ||
} | ||
|
||
if profile.DockerBridgeCidr != nil { | ||
values["docker_bridge_cidr"] = *profile.DockerBridgeCidr | ||
} | ||
|
||
if profile.PodCidr != nil { | ||
values["pod_cidr"] = *profile.PodCidr | ||
} | ||
|
||
return []interface{}{values} | ||
} | ||
|
||
func flattenKubernetesClusterKubeConfig(config kubernetes.KubeConfig) []interface{} { | ||
values := make(map[string]interface{}) | ||
|
||
|
@@ -566,6 +640,31 @@ func expandAzureRmKubernetesClusterAgentProfiles(d *schema.ResourceData) []conta | |
return profiles | ||
} | ||
|
||
func expandAzureRmKubernetesClusterNetworkProfile(d *schema.ResourceData) *containerservice.NetworkProfile { | ||
configs := d.Get("network_profile").([]interface{}) | ||
if len(configs) == 0 { | ||
return nil | ||
} | ||
|
||
config := configs[0].(map[string]interface{}) | ||
|
||
dnsServiceIP := config["dns_service_ip"].(string) | ||
dockerBridgeCidr := config["docker_bridge_cidr"].(string) | ||
networkPlugin := config["network_plugin"].(string) | ||
podCidr := config["pod_cidr"].(string) | ||
serviceCidr := config["service_cidr"].(string) | ||
|
||
networkProfile := containerservice.NetworkProfile{ | ||
DNSServiceIP: utils.String(dnsServiceIP), | ||
DockerBridgeCidr: utils.String(dockerBridgeCidr), | ||
NetworkPlugin: containerservice.NetworkPlugin(networkPlugin), | ||
PodCidr: utils.String(podCidr), | ||
ServiceCidr: utils.String(serviceCidr), | ||
} | ||
|
||
return &networkProfile | ||
} | ||
|
||
func resourceAzureRMKubernetesClusterServicePrincipalProfileHash(v interface{}) int { | ||
var buf bytes.Buffer | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we document this block/these new fields here? (I've had to link to the Blame since you can't link to a regular line in a Markdown file in Github ¯_(ツ)_/¯)