Skip to content

Commit

Permalink
fix: Adding support for Cilium Network Policy (#3402)
Browse files Browse the repository at this point in the history
# Supporting Cilium network policy in AKS

cilium data plane requires cilium network policy. when specifying azure
policy for cilium we get an error -
CiliumDataplaneRequiresNetworkPolicyCilium

Configuration
networkPolicy: 'azure'
networkPlugin: 'azure'
networkDataplane: 'cilium'

Detailed Error
```json
{
    "message": {
        "code": "BadRequest",
        "details": null,
        "message": "Cilium dataplane requires network policy cilium.",
        "subcode": "CiliumDataplaneRequiresNetworkPolicyCilium",
        "target": "networkProfile.networkPolicy"
    }
}
```

| Pipeline |
| -------- |
|
[![avm.res.container-service.managed-cluster](https://github.com/cv-gh/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml/badge.svg)](https://github.com/cv-gh/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ ] Azure Verified Module updates:
- [ x] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [ x] I'm sure there are no other open Pull Requests for the same
update/change
- [ x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Ilhaan Rasheed <[email protected]>
  • Loading branch information
cv-gh and ilhaan authored Nov 14, 2024
1 parent 245b9f6 commit 34cff93
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
1 change: 1 addition & 0 deletions avm/res/container-service/managed-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4645,6 +4645,7 @@ Specifies the network policy used for building Kubernetes network. - calico or a
[
'azure'
'calico'
'cilium'
]
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "13856766172443517827"
"version": "0.31.34.60546",
"templateHash": "13504241837980660061"
},
"name": "Azure Kubernetes Service (AKS) Managed Cluster Agent Pools",
"description": "This module deploys an Azure Kubernetes Service (AKS) Managed Cluster Agent Pool.",
Expand Down Expand Up @@ -355,10 +355,7 @@
"vmSize": "[parameters('vmSize')]",
"vnetSubnetID": "[parameters('vnetSubnetResourceId')]",
"workloadRuntime": "[parameters('workloadRuntime')]"
},
"dependsOn": [
"managedCluster"
]
}
}
},
"outputs": {
Expand Down
5 changes: 3 additions & 2 deletions avm/res/container-service/managed-cluster/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ param networkPluginMode string?
@allowed([
'azure'
'calico'
'cilium'
])
param networkPolicy string?

Expand Down Expand Up @@ -720,8 +721,8 @@ resource managedCluster 'Microsoft.ContainerService/managedClusters@2024-03-02-p
networkProfile: {
networkDataplane: networkDataplane
networkPlugin: networkPlugin
networkPluginMode: networkPluginMode
networkPolicy: networkPolicy
networkPluginMode: networkDataplane == 'cilium' ? 'overlay' : networkPluginMode
networkPolicy: networkDataplane == 'cilium' ? 'cilium' : networkPolicy
podCidr: podCidr
serviceCidr: serviceCidr
dnsServiceIP: dnsServiceIP
Expand Down
29 changes: 12 additions & 17 deletions avm/res/container-service/managed-cluster/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "543007463534644066"
"version": "0.31.34.60546",
"templateHash": "178765084464759811"
},
"name": "Azure Kubernetes Service (AKS) Managed Clusters",
"description": "This module deploys an Azure Kubernetes Service (AKS) Managed Cluster.",
Expand Down Expand Up @@ -812,7 +812,8 @@
"nullable": true,
"allowedValues": [
"azure",
"calico"
"calico",
"cilium"
],
"metadata": {
"description": "Optional. Specifies the network policy used for building Kubernetes network. - calico or azure."
Expand Down Expand Up @@ -1677,10 +1678,7 @@
"apiVersion": "2023-02-01",
"subscriptionId": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), '//'), '/')[2]]",
"resourceGroup": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), '////'), '/')[4]]",
"name": "[format('{0}/{1}', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), 'dummyVault'), '/')), coalesce(tryGet(parameters('customerManagedKey'), 'keyName'), 'dummyKey'))]",
"dependsOn": [
"cMKKeyVault"
]
"name": "[format('{0}/{1}', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), 'dummyVault'), '/')), coalesce(tryGet(parameters('customerManagedKey'), 'keyName'), 'dummyKey'))]"
},
"avmTelemetry": {
"condition": "[parameters('enableTelemetry')]",
Expand Down Expand Up @@ -1791,8 +1789,8 @@
"networkProfile": {
"networkDataplane": "[parameters('networkDataplane')]",
"networkPlugin": "[parameters('networkPlugin')]",
"networkPluginMode": "[parameters('networkPluginMode')]",
"networkPolicy": "[parameters('networkPolicy')]",
"networkPluginMode": "[if(equals(parameters('networkDataplane'), 'cilium'), 'overlay', parameters('networkPluginMode'))]",
"networkPolicy": "[if(equals(parameters('networkDataplane'), 'cilium'), 'cilium', parameters('networkPolicy'))]",
"podCidr": "[parameters('podCidr')]",
"serviceCidr": "[parameters('serviceCidr')]",
"dnsServiceIP": "[parameters('dnsServiceIP')]",
Expand Down Expand Up @@ -2007,8 +2005,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "2505380725266419010"
"version": "0.31.34.60546",
"templateHash": "3191846535289543816"
},
"name": "Azure Kubernetes Service (AKS) Managed Cluster Maintenance Configurations",
"description": "This module deploys an Azure Kubernetes Service (AKS) Managed Cluster Maintenance Configurations.",
Expand Down Expand Up @@ -2204,8 +2202,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "13856766172443517827"
"version": "0.31.34.60546",
"templateHash": "13504241837980660061"
},
"name": "Azure Kubernetes Service (AKS) Managed Cluster Agent Pools",
"description": "This module deploys an Azure Kubernetes Service (AKS) Managed Cluster Agent Pool.",
Expand Down Expand Up @@ -2554,10 +2552,7 @@
"vmSize": "[parameters('vmSize')]",
"vnetSubnetID": "[parameters('vnetSubnetResourceId')]",
"workloadRuntime": "[parameters('workloadRuntime')]"
},
"dependsOn": [
"managedCluster"
]
}
}
},
"outputs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "2505380725266419010"
"version": "0.31.34.60546",
"templateHash": "3191846535289543816"
},
"name": "Azure Kubernetes Service (AKS) Managed Cluster Maintenance Configurations",
"description": "This module deploys an Azure Kubernetes Service (AKS) Managed Cluster Maintenance Configurations.",
Expand Down

0 comments on commit 34cff93

Please sign in to comment.