@@ -45,7 +45,7 @@ type Addon struct {
4545 name string
4646 logger * logrus.Logger
4747
48- version semver.Version
48+ version * semver.Version
4949
5050 mtlsEnabled bool
5151}
@@ -61,9 +61,14 @@ func (a *Addon) Namespace() string {
6161 return Namespace
6262}
6363
64- // Version indicates the Kuma version for this addon.
65- func (a * Addon ) Version () semver.Version {
66- return a .version
64+ // Version returns the version of the Kuma Helm chart deployed by the addon.
65+ // If the version is not set, the second return value will be false and the latest local
66+ // chart version will be used.
67+ func (a * Addon ) Version () (v semver.Version , ok bool ) {
68+ if a .version == nil {
69+ return semver.Version {}, false
70+ }
71+ return * a .version , true
6772}
6873
6974// -----------------------------------------------------------------------------
@@ -144,6 +149,10 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
144149 // if the dbmode is postgres, set several related values
145150 args := []string {"--kubeconfig" , kubeconfig .Name (), "install" , DefaultReleaseName , "kuma/kuma" }
146151
152+ if a .version != nil {
153+ args = append (args , "--version" , a .version .String ())
154+ }
155+
147156 // compile the helm installation values
148157 args = append (args , "--create-namespace" , "--namespace" , Namespace )
149158 a .logger .Debugf ("helm install arguments: %+v" , args )
@@ -225,20 +234,49 @@ spec:
225234 name: ca-1
226235 type: builtin
227236 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" )
228260)
229261
230262// enableMTLS attempts to apply a Mesh resource with a basic retry mechanism to deal with delays in the Kuma webhook
231263// startup
232264func (a * Addon ) enableMTLS (ctx context.Context , cluster clusters.Cluster ) (err error ) {
233265 ticker := time .NewTicker (5 * time .Second ) //nolint:gomnd
266+ defer ticker .Stop ()
234267 timeoutTimer := time .NewTimer (time .Minute )
235268
236269 for {
237270 select {
238271 case <- ctx .Done ():
239272 return fmt .Errorf ("context completed while retrying to apply Mesh" )
240273 case <- ticker .C :
241- 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 )
242280 if err == nil {
243281 return nil
244282 }
0 commit comments