@@ -234,20 +234,49 @@ spec:
234
234
name: ca-1
235
235
type: builtin
236
236
enabledBackend: ca-1`
237
+
238
+ allowAllTrafficPermission = `apiVersion: kuma.io/v1alpha1
239
+ kind: MeshTrafficPermission
240
+ metadata:
241
+ name: allow-all
242
+ namespace: kuma-system
243
+ labels:
244
+ kuma.io/mesh: default
245
+ spec:
246
+ targetRef:
247
+ kind: Mesh
248
+ from:
249
+ - targetRef:
250
+ kind: Mesh
251
+ default:
252
+ action: Allow`
253
+ )
254
+
255
+ var (
256
+ // From Kuma 2.6.0, the default mesh traffic permission is no longer created by default
257
+ // and must be created manually if mTLS is enabled.
258
+ // https://github.com/kumahq/kuma/blob/2.6.0/UPGRADE.md#default-trafficroute-and-trafficpermission-resources-are-not-created-when-creating-a-new-mesh
259
+ installDefaultMeshTrafficPermissionCutoffVersion = semver .MustParse ("2.6.0" )
237
260
)
238
261
239
262
// enableMTLS attempts to apply a Mesh resource with a basic retry mechanism to deal with delays in the Kuma webhook
240
263
// startup
241
264
func (a * Addon ) enableMTLS (ctx context.Context , cluster clusters.Cluster ) (err error ) {
242
265
ticker := time .NewTicker (5 * time .Second ) //nolint:gomnd
266
+ defer ticker .Stop ()
243
267
timeoutTimer := time .NewTimer (time .Minute )
244
268
245
269
for {
246
270
select {
247
271
case <- ctx .Done ():
248
272
return fmt .Errorf ("context completed while retrying to apply Mesh" )
249
273
case <- ticker .C :
250
- err = clusters .ApplyManifestByYAML (ctx , cluster , mtlsEnabledDefaultMesh )
274
+ yamlToApply := mtlsEnabledDefaultMesh
275
+ if v , ok := a .Version (); ok && v .GTE (installDefaultMeshTrafficPermissionCutoffVersion ) {
276
+ a .logger .Infof ("Kuma version is %s or later, creating default mesh traffic permission" , installDefaultMeshTrafficPermissionCutoffVersion )
277
+ yamlToApply = strings .Join ([]string {mtlsEnabledDefaultMesh , allowAllTrafficPermission }, "\n ---\n " )
278
+ }
279
+ err = clusters .ApplyManifestByYAML (ctx , cluster , yamlToApply )
251
280
if err == nil {
252
281
return nil
253
282
}
0 commit comments