Skip to content

Commit

Permalink
The current version of flux configuration 2022-03-01 doesn't add Post…
Browse files Browse the repository at this point in the history
…build substitution variables (#4142)

* Updated flux configuration version to 2023-05-01

* Update readme and generate main.json

* Add kustomization settings to tests

* Update readme and generate main.json

---------

Co-authored-by: Asad Arif <asad.arif@capgemini.com>
  • Loading branch information
aadev1 and aadev1 authored Nov 21, 2023
1 parent 34e9610 commit 1fb163e
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
timeoutInSeconds: 180
url: 'https://github.com/mspnp/aks-baseline'
}
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
timeoutInSeconds: 180
url: 'https://github.com/mspnp/aks-baseline'
}
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
}
]
}
Expand Down
129 changes: 81 additions & 48 deletions modules/kubernetes-configuration/flux-configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This module deploys a Kubernetes Configuration Flux Configuration.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.KubernetesConfiguration/fluxConfigurations` | [2022-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.KubernetesConfiguration/2022-03-01/fluxConfigurations) |
| `Microsoft.KubernetesConfiguration/fluxConfigurations` | [2023-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.KubernetesConfiguration/fluxConfigurations) |

## Usage examples

Expand Down Expand Up @@ -46,6 +46,22 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
params: {
// Required parameters
clusterName: '<clusterName>'
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
postBuild: {
substitute: {
TEST_VAR1: 'foo'
TEST_VAR2: 'bar'
}
}
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
name: 'kcfcmin001'
namespace: 'flux-system'
sourceKind: 'GitRepository'
Expand Down Expand Up @@ -80,6 +96,24 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
"clusterName": {
"value": "<clusterName>"
},
"kustomizations": {
"value": {
"unified": {
"dependsOn": [],
"force": false,
"path": "./cluster-manifests",
"postBuild": {
"substitute": {
"TEST_VAR1": "foo",
"TEST_VAR2": "bar"
}
},
"prune": true,
"syncIntervalInSeconds": 300,
"timeoutInSeconds": 300
}
}
},
"name": {
"value": "kcfcmin001"
},
Expand Down Expand Up @@ -126,6 +160,16 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
params: {
// Required parameters
clusterName: '<clusterName>'
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
name: 'kcfcmax001'
namespace: 'flux-system'
sourceKind: 'GitRepository'
Expand All @@ -140,16 +184,6 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
timeoutInSeconds: 180
url: 'https://github.com/mspnp/aks-baseline'
}
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
}
}
```
Expand All @@ -170,6 +204,18 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
"clusterName": {
"value": "<clusterName>"
},
"kustomizations": {
"value": {
"unified": {
"dependsOn": [],
"force": false,
"path": "./cluster-manifests",
"prune": true,
"syncIntervalInSeconds": 300,
"timeoutInSeconds": 300
}
}
},
"name": {
"value": "kcfcmax001"
},
Expand All @@ -193,18 +239,6 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
"timeoutInSeconds": 180,
"url": "https://github.com/mspnp/aks-baseline"
}
},
"kustomizations": {
"value": {
"unified": {
"dependsOn": [],
"force": false,
"path": "./cluster-manifests",
"prune": true,
"syncIntervalInSeconds": 300,
"timeoutInSeconds": 300
}
}
}
}
}
Expand All @@ -228,6 +262,16 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
params: {
// Required parameters
clusterName: '<clusterName>'
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
name: 'kcfcwaf001'
namespace: 'flux-system'
sourceKind: 'GitRepository'
Expand All @@ -242,16 +286,6 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
timeoutInSeconds: 180
url: 'https://github.com/mspnp/aks-baseline'
}
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
}
}
}
}
```
Expand All @@ -272,6 +306,18 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
"clusterName": {
"value": "<clusterName>"
},
"kustomizations": {
"value": {
"unified": {
"dependsOn": [],
"force": false,
"path": "./cluster-manifests",
"prune": true,
"syncIntervalInSeconds": 300,
"timeoutInSeconds": 300
}
}
},
"name": {
"value": "kcfcwaf001"
},
Expand All @@ -295,18 +341,6 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
"timeoutInSeconds": 180,
"url": "https://github.com/mspnp/aks-baseline"
}
},
"kustomizations": {
"value": {
"unified": {
"dependsOn": [],
"force": false,
"path": "./cluster-manifests",
"prune": true,
"syncIntervalInSeconds": 300,
"timeoutInSeconds": 300
}
}
}
}
}
Expand All @@ -323,6 +357,7 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`clusterName`](#parameter-clustername) | string | The name of the AKS cluster that should be configured. |
| [`kustomizations`](#parameter-kustomizations) | object | Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster. |
| [`name`](#parameter-name) | string | The name of the Flux Configuration. |
| [`namespace`](#parameter-namespace) | string | The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. |
| [`scope`](#parameter-scope) | string | Scope at which the configuration will be installed. |
Expand All @@ -336,7 +371,6 @@ module fluxConfiguration 'br:bicep/modules/kubernetes-configuration.flux-configu
| [`configurationProtectedSettings`](#parameter-configurationprotectedsettings) | secureObject | Key-value pairs of protected configuration settings for the configuration. |
| [`enableDefaultTelemetry`](#parameter-enabledefaulttelemetry) | bool | Enable telemetry via a Globally Unique Identifier (GUID). |
| [`gitRepository`](#parameter-gitrepository) | object | Parameters to reconcile to the GitRepository source kind type. |
| [`kustomizations`](#parameter-kustomizations) | object | Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster. |
| [`location`](#parameter-location) | string | Location for all resources. |
| [`suspend`](#parameter-suspend) | bool | Whether this configuration should suspend its reconciliation of its kustomizations and sources. |

Expand Down Expand Up @@ -377,9 +411,8 @@ Parameters to reconcile to the GitRepository source kind type.
### Parameter: `kustomizations`

Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster.
- Required: No
- Required: Yes
- Type: object
- Default: `{}`

### Parameter: `location`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ param configurationProtectedSettings object = {}
@description('Optional. Parameters to reconcile to the GitRepository source kind type.')
param gitRepository object = {}

@description('Optional. Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster.')
param kustomizations object = {}
@description('Required. Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster.')
param kustomizations object

@description('Required. The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only.')
param namespace string
Expand Down Expand Up @@ -63,14 +63,14 @@ resource managedCluster 'Microsoft.ContainerService/managedClusters@2022-07-01'
name: clusterName
}

resource fluxConfiguration 'Microsoft.KubernetesConfiguration/fluxConfigurations@2022-03-01' = {
resource fluxConfiguration 'Microsoft.KubernetesConfiguration/fluxConfigurations@2023-05-01' = {
name: name
scope: managedCluster
properties: {
bucket: !empty(bucket) ? bucket : null
configurationProtectedSettings: !empty(configurationProtectedSettings) ? configurationProtectedSettings : {}
gitRepository: !empty(gitRepository) ? gitRepository : null
kustomizations: !empty(kustomizations) ? kustomizations : {}
kustomizations: kustomizations
namespace: namespace
scope: scope
sourceKind: sourceKind
Expand Down
9 changes: 4 additions & 5 deletions modules/kubernetes-configuration/flux-configuration/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.23.1.45101",
"templateHash": "8985718648814286209"
"templateHash": "10031296768791737313"
},
"name": "Kubernetes Configuration Flux Configurations",
"description": "This module deploys a Kubernetes Configuration Flux Configuration.",
Expand Down Expand Up @@ -61,9 +61,8 @@
},
"kustomizations": {
"type": "object",
"defaultValue": {},
"metadata": {
"description": "Optional. Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster."
"description": "Required. Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster."
}
},
"namespace": {
Expand Down Expand Up @@ -117,14 +116,14 @@
},
{
"type": "Microsoft.KubernetesConfiguration/fluxConfigurations",
"apiVersion": "2022-03-01",
"apiVersion": "2023-05-01",
"scope": "[format('Microsoft.ContainerService/managedClusters/{0}', parameters('clusterName'))]",
"name": "[parameters('name')]",
"properties": {
"bucket": "[if(not(empty(parameters('bucket'))), parameters('bucket'), null())]",
"configurationProtectedSettings": "[if(not(empty(parameters('configurationProtectedSettings'))), parameters('configurationProtectedSettings'), createObject())]",
"gitRepository": "[if(not(empty(parameters('gitRepository'))), parameters('gitRepository'), null())]",
"kustomizations": "[if(not(empty(parameters('kustomizations'))), parameters('kustomizations'), createObject())]",
"kustomizations": "[parameters('kustomizations')]",
"namespace": "[parameters('namespace')]",
"scope": "[parameters('scope')]",
"sourceKind": "[parameters('sourceKind')]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,21 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
timeoutInSeconds: 180
url: 'https://github.com/mspnp/aks-baseline'
}
kustomizations: {
unified: {
dependsOn: []
force: false
path: './cluster-manifests'
prune: true
syncIntervalInSeconds: 300
timeoutInSeconds: 300
postBuild: {
substitute: {
TEST_VAR1: 'foo'
TEST_VAR2: 'bar'
}
}
}
}
}
}]

0 comments on commit 1fb163e

Please sign in to comment.