Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0e660d

Browse files
committedMar 17, 2025·
Add env vars to the whisker deployment
1 parent 8580a4f commit c0e660d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
 

‎pkg/controller/whisker/controller.go

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020

21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
"k8s.io/apimachinery/pkg/runtime"
2223
"sigs.k8s.io/controller-runtime/pkg/client"
2324
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -26,7 +27,9 @@ import (
2627
"sigs.k8s.io/controller-runtime/pkg/manager"
2728
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2829

30+
v3 "github.com/tigera/api/pkg/apis/projectcalico/v3"
2931
operatorv1 "github.com/tigera/operator/api/v1"
32+
3033
"github.com/tigera/operator/pkg/common"
3134
"github.com/tigera/operator/pkg/controller/certificatemanager"
3235
"github.com/tigera/operator/pkg/controller/options"
@@ -197,6 +200,14 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
197200
)
198201
if err != nil {
199202
r.status.SetDegraded(operatorv1.ResourceCreateError, "Unable to create the trusted bundle", err, reqLogger)
203+
return reconcile.Result{}, err
204+
}
205+
206+
clusterInfo := &v3.ClusterInformation{ObjectMeta: metav1.ObjectMeta{Name: "default"}}
207+
err = r.cli.Get(ctx, client.ObjectKeyFromObject(clusterInfo), clusterInfo)
208+
if err != nil {
209+
r.status.SetDegraded(operatorv1.ResourceReadError, "Failed to get ClusterInformation: ", err, reqLogger)
210+
return reconcile.Result{}, err
200211
}
201212

202213
ch := utils.NewComponentHandler(log, r.cli, r.scheme, whiskerCR)
@@ -206,6 +217,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
206217
Installation: installation,
207218
TrustedCertBundle: trustedBundle,
208219
WhiskerBackendKeyPair: backendKeyPair,
220+
WhiskerID: clusterInfo.Spec.ClusterGUID,
221+
ClusterType: clusterInfo.Spec.ClusterType,
222+
CalicoVersion: clusterInfo.Spec.CalicoVersion,
209223
}
210224

211225
certComponent := rcertificatemanagement.CertificateManagement(&rcertificatemanagement.Config{

‎pkg/render/whisker/component.go

+7
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ type Configuration struct {
6464
Installation *operatorv1.InstallationSpec
6565
TrustedCertBundle certificatemanagement.TrustedBundleRO
6666
WhiskerBackendKeyPair certificatemanagement.KeyPairInterface
67+
68+
WhiskerID string
69+
CalicoVersion string
70+
ClusterType string
6771
}
6872

6973
type Component struct {
@@ -133,6 +137,9 @@ func (c *Component) whiskerContainer() corev1.Container {
133137
ImagePullPolicy: render.ImagePullPolicy(),
134138
Env: []corev1.EnvVar{
135139
{Name: "LOG_LEVEL", Value: "INFO"},
140+
{Name: "CALICO_VERSION", Value: c.cfg.CalicoVersion},
141+
{Name: "WHISKER_ID", Value: c.cfg.WhiskerID},
142+
{Name: "CLUSTER_TYPE", Value: string(c.cfg.ClusterType)},
136143
},
137144
SecurityContext: securitycontext.NewNonRootContext(),
138145
}

‎pkg/render/whisker/component_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ var _ = Describe("ComponentRendering", func() {
8686
},
8787
TrustedCertBundle: defaultTrustedCertBundle,
8888
WhiskerBackendKeyPair: defaultTLSKeyPair,
89+
WhiskerID: "test-whisker-id",
90+
CalicoVersion: "test-calico-version",
91+
ClusterType: "test-cluster-type",
8992
},
9093
&appsv1.Deployment{
9194
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
@@ -112,6 +115,9 @@ var _ = Describe("ComponentRendering", func() {
112115
ImagePullPolicy: render.ImagePullPolicy(),
113116
Env: []corev1.EnvVar{
114117
{Name: "LOG_LEVEL", Value: "INFO"},
118+
{Name: "CALICO_VERSION", Value: "test-calico-version"},
119+
{Name: "WHISKER_ID", Value: "test-whisker-id"},
120+
{Name: "CLUSTER_TYPE", Value: "test-cluster-type"},
115121
},
116122
SecurityContext: securitycontext.NewNonRootContext(),
117123
},

0 commit comments

Comments
 (0)
Please sign in to comment.