Skip to content

Commit 9756cbf

Browse files
feat: Enable Hubble Relay in Cilium deployment via CAAPH (#899)
**What problem does this PR solve?**: Relay is required for network visibility of a cluster as a whole. See https://docs.cilium.io/en/stable/gettingstarted/hubble_intro/. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. --> --------- Co-authored-by: Jimmi Dyson <[email protected]>
1 parent a039691 commit 9756cbf

File tree

11 files changed

+49
-22
lines changed

11 files changed

+49
-22
lines changed

charts/cluster-api-runtime-extensions-nutanix/templates/cni/cilium/manifests/helm-addon-installation.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ data:
1212
chainingMode: portmap
1313
exclusive: false
1414
hubble:
15+
enabled: true
1516
tls:
1617
auto:
1718
enabled: true # enable automatic TLS certificate generation
1819
method: cronJob # auto generate certificates using cronJob method
1920
certValidityDuration: 60 # certificates validity duration in days (default 2 months)
2021
schedule: "0 0 1 * *" # schedule on the 1st day regeneration of each month
22+
relay:
23+
enabled: true
24+
image:
25+
useDigest: false
2126
ipam:
2227
mode: kubernetes
2328
image:

hack/addons/kustomize/cilium/helm-values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ cni:
77
exclusive: false
88
hubble:
99
enabled: false
10+
relay:
11+
enabled: false
1012
ipam:
1113
mode: kubernetes
1214
image:

pkg/handlers/generic/lifecycle/ccm/aws/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/go-logr/logr"
1111
"github.com/spf13/pflag"
12+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1213
"k8s.io/utils/ptr"
1314
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1415
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -23,7 +24,7 @@ import (
2324
const (
2425
awsCCMPrefix = "aws-ccm-"
2526

26-
defaultHelmReleaseNamespace = "kube-system"
27+
defaultHelmReleaseNamespace = metav1.NamespaceSystem
2728
defaultHelmReleaseName = "aws-cloud-controller-manager"
2829
)
2930

pkg/handlers/generic/lifecycle/ccm/nutanix/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/go-logr/logr"
1414
"github.com/spf13/pflag"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1617
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
1718

@@ -25,7 +26,7 @@ import (
2526

2627
const (
2728
defaultHelmReleaseName = "nutanix-ccm"
28-
defaultHelmReleaseNamespace = "kube-system"
29+
defaultHelmReleaseNamespace = metav1.NamespaceSystem
2930

3031
// This is the name of the Secret on the remote cluster that should match what is defined in Helm values.
3132
//nolint:gosec // Does not contain hard coded credentials.

pkg/handlers/generic/lifecycle/cni/cilium/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99

1010
"github.com/spf13/pflag"
11+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112
"k8s.io/utils/ptr"
1213
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1314
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
@@ -32,7 +33,7 @@ type CNIConfig struct {
3233

3334
const (
3435
defaultCiliumReleaseName = "cilium"
35-
defaultCiliumNamespace = "kube-system"
36+
defaultCiliumNamespace = metav1.NamespaceSystem
3637
)
3738

3839
type helmAddonConfig struct {

pkg/handlers/generic/lifecycle/csi/awsebs/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/go-logr/logr"
1111
"github.com/spf13/pflag"
12+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1213
"k8s.io/utils/ptr"
1314
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1415
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -22,7 +23,7 @@ import (
2223

2324
const (
2425
defaultHelmReleaseName = "aws-ebs-csi-driver"
25-
defaultHelmReleaseNamespace = "kube-system"
26+
defaultHelmReleaseNamespace = metav1.NamespaceSystem
2627
)
2728

2829
var DefaultStorageClassParameters = map[string]string{

pkg/handlers/generic/lifecycle/csi/localpath/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/go-logr/logr"
1111
"github.com/spf13/pflag"
12+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1213
"k8s.io/utils/ptr"
1314
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1415
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -22,7 +23,7 @@ import (
2223

2324
const (
2425
defaultHelmReleaseName = "local-path-provisioner-csi"
25-
defaultHelmReleaseNamespace = "kube-system"
26+
defaultHelmReleaseNamespace = metav1.NamespaceSystem
2627
)
2728

2829
type Config struct {

pkg/handlers/generic/lifecycle/csi/snapshotcontroller/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99

1010
"github.com/spf13/pflag"
11+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112
"k8s.io/utils/ptr"
1213
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1314
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
@@ -25,7 +26,7 @@ import (
2526

2627
const (
2728
defaultHelmReleaseName = "snapshot-controller"
28-
defaultHelmReleaseNamespace = "kube-system"
29+
defaultHelmReleaseNamespace = metav1.NamespaceSystem
2930
)
3031

3132
type Config struct {

test/e2e/clusterautoscaler_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func WaitForClusterAutoscalerToBeReadyForWorkloadCluster(
135135

136136
statusConfigMap := &corev1.ConfigMap{
137137
ObjectMeta: metav1.ObjectMeta{
138-
Namespace: "kube-system",
138+
Namespace: metav1.NamespaceSystem,
139139
Name: "cluster-autoscaler-status",
140140
},
141141
}

test/e2e/cni_helpers.go

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ func waitForCiliumToBeReadyInWorkloadCluster(
205205
ctx context.Context,
206206
input waitForCiliumToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests.
207207
) {
208+
expectedDeployments := []*appsv1.Deployment{{
209+
ObjectMeta: metav1.ObjectMeta{
210+
Name: "cilium-operator",
211+
Namespace: metav1.NamespaceSystem,
212+
},
213+
}}
214+
208215
switch input.strategy {
209216
case v1alpha1.AddonStrategyClusterResourceSet:
210217
crs := &addonsv1.ClusterResourceSet{}
@@ -236,6 +243,15 @@ func waitForCiliumToBeReadyInWorkloadCluster(
236243
},
237244
input.helmReleaseIntervals...,
238245
)
246+
247+
// Hubble relay is also deployed as part of the Cilium Helm chart when deplying via
248+
// CAAPH.
249+
expectedDeployments = append(expectedDeployments, &appsv1.Deployment{
250+
ObjectMeta: metav1.ObjectMeta{
251+
Name: "hubble-relay",
252+
Namespace: metav1.NamespaceSystem,
253+
},
254+
})
239255
default:
240256
Fail(
241257
fmt.Sprintf(
@@ -249,23 +265,20 @@ func waitForCiliumToBeReadyInWorkloadCluster(
249265
ctx, input.workloadCluster.Namespace, input.workloadCluster.Name,
250266
).GetClient()
251267

252-
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
253-
Getter: workloadClusterClient,
254-
Deployment: &appsv1.Deployment{
255-
ObjectMeta: metav1.ObjectMeta{
256-
Name: "cilium-operator",
257-
Namespace: "kube-system",
258-
},
259-
},
260-
}, input.deploymentIntervals...)
261-
262268
WaitForDaemonSetsAvailable(ctx, WaitForDaemonSetsAvailableInput{
263269
Getter: workloadClusterClient,
264270
DaemonSet: &appsv1.DaemonSet{
265271
ObjectMeta: metav1.ObjectMeta{
266272
Name: "cilium",
267-
Namespace: "kube-system",
273+
Namespace: metav1.NamespaceSystem,
268274
},
269275
},
270276
}, input.daemonSetIntervals...)
277+
278+
for _, deployment := range expectedDeployments {
279+
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
280+
Getter: workloadClusterClient,
281+
Deployment: deployment,
282+
}, input.deploymentIntervals...)
283+
}
271284
}

test/e2e/framework/self_hosted.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
. "github.com/onsi/ginkgo/v2"
1717
. "github.com/onsi/gomega"
1818
corev1 "k8s.io/api/core/v1"
19+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1920
"k8s.io/apimachinery/pkg/runtime/schema"
2021
"k8s.io/klog/v2"
2122
"k8s.io/utils/ptr"
@@ -286,12 +287,12 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
286287
Consistently(func() error {
287288
kubeSystem := &corev1.Namespace{}
288289
return input.BootstrapClusterProxy.GetClient().
289-
Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem)
290+
Get(ctx, client.ObjectKey{Name: metav1.NamespaceSystem}, kubeSystem)
290291
}, "5s", "100ms").Should(BeNil(), "Failed to assert bootstrap API server stability")
291292
Consistently(func() error {
292293
kubeSystem := &corev1.Namespace{}
293294
return selfHostedClusterProxy.GetClient().
294-
Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem)
295+
Get(ctx, client.ObjectKey{Name: metav1.NamespaceSystem}, kubeSystem)
295296
}, "5s", "100ms").Should(BeNil(), "Failed to assert self-hosted API server stability")
296297

297298
By("Moving the cluster to self hosted")
@@ -343,12 +344,12 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
343344
Consistently(func() error {
344345
kubeSystem := &corev1.Namespace{}
345346
return input.BootstrapClusterProxy.GetClient().
346-
Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem)
347+
Get(ctx, client.ObjectKey{Name: metav1.NamespaceSystem}, kubeSystem)
347348
}, "5s", "100ms").Should(BeNil(), "Failed to assert bootstrap API server stability")
348349
Consistently(func() error {
349350
kubeSystem := &corev1.Namespace{}
350351
return selfHostedClusterProxy.GetClient().
351-
Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem)
352+
Get(ctx, client.ObjectKey{Name: metav1.NamespaceSystem}, kubeSystem)
352353
}, "5s", "100ms").Should(BeNil(), "Failed to assert self-hosted API server stability")
353354

354355
By("Moving the cluster back to bootstrap")

0 commit comments

Comments
 (0)