Skip to content

Commit 3eec92a

Browse files
Merge pull request #3819 from caseydavenport/auto-pick-of-#3802-origin-release-v1.37
[release-v1.37] Auto pick #3802: Add API for managed cluster variant
2 parents bd6c640 + 8149411 commit 3eec92a

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

api/v1/tenant_types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023-2024 Tigera, Inc. All rights reserved.
1+
// Copyright (c) 2023-2025 Tigera, Inc. All rights reserved.
22
/*
33
44
Licensed under the Apache License, Version 2.0 (the "License");
@@ -93,6 +93,10 @@ type TenantSpec struct {
9393

9494
// DashboardsJob configures the Dashboards job
9595
DashboardsJob *DashboardsJob `json:"dashboardsJob,omitempty"`
96+
97+
// ManagedClusterVariant is the variant of the managed cluster.
98+
// +optional
99+
ManagedClusterVariant *ProductVariant `json:"managedClusterVariant,omitempty"`
96100
}
97101

98102
// Index defines how to store a tenant's data
@@ -144,6 +148,10 @@ func (t *Tenant) SingleTenant() bool {
144148
return t != nil && t.GetNamespace() == ""
145149
}
146150

151+
func (t *Tenant) ManagedClusterIsCalico() bool {
152+
return t != nil && t.Spec.ManagedClusterVariant != nil && *t.Spec.ManagedClusterVariant == Calico
153+
}
154+
147155
// +kubebuilder:object:root=true
148156

149157
// TenantList contains a list of Tenant

api/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/crds/operator/operator.tigera.io_tenants.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,9 @@ spec:
15351535
type: object
15361536
type: object
15371537
type: object
1538+
managedClusterVariant:
1539+
description: ManagedClusterVariant is the variant of the managed cluster.
1540+
type: string
15381541
name:
15391542
description: Name is a human readable name for this tenant.
15401543
type: string

pkg/render/logstorage/linseed/linseed.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022-2024 Tigera, Inc. All rights reserved.
1+
// Copyright (c) 2022-2025 Tigera, Inc. All rights reserved.
22

33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -406,7 +406,10 @@ func (l *linseed) linseedDeployment() *appsv1.Deployment {
406406
annotations[fmt.Sprintf("hash.operator.tigera.io/%s", render.ElasticsearchLinseedUserSecret)] = rmeta.SecretsAnnotationHash(l.cfg.ElasticClientCredentialsSecret)
407407
}
408408

409-
if l.cfg.TokenKeyPair != nil {
409+
if l.cfg.TokenKeyPair != nil && !l.cfg.Tenant.ManagedClusterIsCalico() {
410+
// If a token key pair is provided, configure Linseed to use it.
411+
// We don't need to do this for OSS Calico managed clusters - they don't have permissions for the
412+
// token controller to create tokens.
410413
envVars = append(envVars,
411414
corev1.EnvVar{Name: "TOKEN_CONTROLLER_ENABLED", Value: "true"},
412415
corev1.EnvVar{Name: "LINSEED_TOKEN_KEY", Value: l.cfg.TokenKeyPair.VolumeMountKeyFilePath()},

pkg/render/manager.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ type managerComponent struct {
174174
tlsSecrets []*corev1.Secret
175175
tlsAnnotations map[string]string
176176
managerImage string
177-
proxyImage string
177+
voltronImage string
178178
uiAPIsImage string
179179
}
180180

@@ -189,7 +189,7 @@ func (c *managerComponent) ResolveImages(is *operatorv1.ImageSet) error {
189189
errMsgs = append(errMsgs, err.Error())
190190
}
191191

192-
c.proxyImage, err = components.GetReference(components.ComponentManagerProxy, reg, path, prefix, is)
192+
c.voltronImage, err = components.GetReference(components.ComponentManagerProxy, reg, path, prefix, is)
193193
if err != nil {
194194
errMsgs = append(errMsgs, err.Error())
195195
}
@@ -567,6 +567,12 @@ func (c *managerComponent) voltronContainer() corev1.Container {
567567
env = append(env, corev1.EnvVar{Name: "VOLTRON_TENANT_NAMESPACE", Value: c.cfg.Tenant.Namespace})
568568
linseedEndpointEnv = corev1.EnvVar{Name: "VOLTRON_LINSEED_ENDPOINT", Value: fmt.Sprintf("https://tigera-linseed.%s.svc", c.cfg.Tenant.Namespace)}
569569
}
570+
571+
if c.cfg.Tenant.ManagedClusterIsCalico() {
572+
// Enable access to / from Goldmane in Voltron.
573+
env = append(env, corev1.EnvVar{Name: "GOLDMANE_ENABLED", Value: "true"})
574+
env = append(env, corev1.EnvVar{Name: "MANAGED_CLUSTER_SUPPORTS_IMPERSONATION", Value: "false"})
575+
}
570576
}
571577
env = append(env, linseedEndpointEnv)
572578

@@ -576,7 +582,7 @@ func (c *managerComponent) voltronContainer() corev1.Container {
576582

577583
return corev1.Container{
578584
Name: VoltronName,
579-
Image: c.proxyImage,
585+
Image: c.voltronImage,
580586
ImagePullPolicy: ImagePullPolicy(),
581587
Env: env,
582588
VolumeMounts: mounts,
@@ -616,6 +622,14 @@ func (c *managerComponent) managerUIAPIsContainer() corev1.Container {
616622
env = append(env, corev1.EnvVar{Name: "LINSEED_URL", Value: fmt.Sprintf("https://tigera-linseed.%s.svc", c.cfg.Namespace)})
617623
env = append(env, corev1.EnvVar{Name: "TENANT_NAMESPACE", Value: c.cfg.Namespace})
618624
}
625+
626+
if c.cfg.Tenant.ManagedClusterIsCalico() {
627+
// Calico clusters do not give Guardian impersonation permissions.
628+
env = append(env, corev1.EnvVar{Name: "IMPERSONATE", Value: "false"})
629+
630+
// Calico clusters use Goldmane for policy metrics and stats.
631+
env = append(env, corev1.EnvVar{Name: "GOLDMANE_ENABLED", Value: "true"})
632+
}
619633
}
620634

621635
volumeMounts := append(
@@ -837,6 +851,16 @@ func managerClusterRole(managedCluster bool, kubernetesProvider operatorv1.Provi
837851
Verbs: []string{"create"},
838852
},
839853
)
854+
855+
if tenant.ManagedClusterIsCalico() {
856+
// Voltron needs permissions to write flow logs.
857+
cr.Rules = append(cr.Rules,
858+
rbacv1.PolicyRule{
859+
APIGroups: []string{"linseed.tigera.io"},
860+
Resources: []string{"flowlogs"},
861+
Verbs: []string{"create"},
862+
})
863+
}
840864
}
841865

842866
if kubernetesProvider.IsOpenShift() {

0 commit comments

Comments
 (0)