Skip to content

Commit 7382e0c

Browse files
authored
Enable Istio for OSS (#4536)
* Enable Istio for OSS * Fix duplicated import
1 parent bb0fdd1 commit 7382e0c

File tree

9 files changed

+306
-53
lines changed

9 files changed

+306
-53
lines changed

hack/gen-versions/calico.go.tpl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,42 @@ var (
237237
variant: calicoVariant,
238238
}
239239
{{- end }}
240+
{{ with index .Components "istio-pilot" }}
241+
ComponentCalicoIstioPilot = Component{
242+
Version: "{{ .Version }}",
243+
Image: "{{ .Image }}",
244+
Registry: "{{ .Registry }}",
245+
imagePath: "{{ .ImagePath }}",
246+
variant: calicoVariant,
247+
}
248+
{{- end }}
249+
{{ with index .Components "istio-install-cni" }}
250+
ComponentCalicoIstioInstallCNI = Component{
251+
Version: "{{ .Version }}",
252+
Image: "{{ .Image }}",
253+
Registry: "{{ .Registry }}",
254+
imagePath: "{{ .ImagePath }}",
255+
variant: calicoVariant,
256+
}
257+
{{- end }}
258+
{{ with index .Components "istio-ztunnel" }}
259+
ComponentCalicoIstioZTunnel = Component{
260+
Version: "{{ .Version }}",
261+
Image: "{{ .Image }}",
262+
Registry: "{{ .Registry }}",
263+
imagePath: "{{ .ImagePath }}",
264+
variant: calicoVariant,
265+
}
266+
{{- end }}
267+
{{ with index .Components "istio-proxyv2" }}
268+
ComponentCalicoIstioProxyv2 = Component{
269+
Version: "{{ .Version }}",
270+
Image: "{{ .Image }}",
271+
Registry: "{{ .Registry }}",
272+
imagePath: "{{ .ImagePath }}",
273+
variant: calicoVariant,
274+
}
275+
{{- end }}
240276
{{ with index .Components.webhooks }}
241277
ComponentCalicoWebhooks = Component{
242278
Version: "{{ .Version }}",
@@ -273,6 +309,10 @@ var (
273309
ComponentCalicoEnvoyProxy,
274310
ComponentCalicoEnvoyRatelimit,
275311
ComponentCalicoGuardian,
312+
ComponentCalicoIstioPilot,
313+
ComponentCalicoIstioInstallCNI,
314+
ComponentCalicoIstioZTunnel,
315+
ComponentCalicoIstioProxyv2,
276316
ComponentCalicoWebhooks,
277317
}
278318
)

hack/gen-versions/enterprise.go.tpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -490,31 +490,31 @@ var (
490490
}
491491
{{- end }}
492492
{{ with index .Components "istio-pilot" }}
493-
ComponentCalicoIstioPilot = Component{
493+
ComponentIstioPilot = Component{
494494
Version: "{{ .Version }}",
495495
Image: "{{ .Image }}",
496496
Registry: "{{ .Registry }}",
497497
variant: enterpriseVariant,
498498
}
499499
{{- end }}
500500
{{ with index .Components "istio-install-cni" }}
501-
ComponentCalicoIstioInstallCNI = Component{
501+
ComponentIstioInstallCNI = Component{
502502
Version: "{{ .Version }}",
503503
Image: "{{ .Image }}",
504504
Registry: "{{ .Registry }}",
505505
variant: enterpriseVariant,
506506
}
507507
{{- end }}
508508
{{ with index .Components "istio-ztunnel" }}
509-
ComponentCalicoIstioZTunnel = Component{
509+
ComponentIstioZTunnel = Component{
510510
Version: "{{ .Version }}",
511511
Image: "{{ .Image }}",
512512
Registry: "{{ .Registry }}",
513513
variant: enterpriseVariant,
514514
}
515515
{{- end }}
516516
{{ with index .Components "istio-proxyv2" }}
517-
ComponentCalicoIstioProxyv2 = Component{
517+
ComponentIstioProxyv2 = Component{
518518
Version: "{{ .Version }}",
519519
Image: "{{ .Image }}",
520520
Registry: "{{ .Registry }}",
@@ -583,10 +583,10 @@ var (
583583
ComponentGatewayAPIEnvoyGateway,
584584
ComponentGatewayAPIEnvoyProxy,
585585
ComponentGatewayAPIEnvoyRatelimit,
586-
ComponentCalicoIstioPilot,
587-
ComponentCalicoIstioInstallCNI,
588-
ComponentCalicoIstioZTunnel,
589-
ComponentCalicoIstioProxyv2,
586+
ComponentIstioPilot,
587+
ComponentIstioInstallCNI,
588+
ComponentIstioZTunnel,
589+
ComponentIstioProxyv2,
590590
ComponentTigeraWebhooks,
591591
}
592592
)

pkg/components/calico.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,38 @@ var (
220220
variant: calicoVariant,
221221
}
222222

223+
ComponentCalicoIstioPilot = Component{
224+
Version: "master",
225+
Image: "istio-pilot",
226+
Registry: "",
227+
imagePath: "",
228+
variant: calicoVariant,
229+
}
230+
231+
ComponentCalicoIstioInstallCNI = Component{
232+
Version: "master",
233+
Image: "istio-install-cni",
234+
Registry: "",
235+
imagePath: "",
236+
variant: calicoVariant,
237+
}
238+
239+
ComponentCalicoIstioZTunnel = Component{
240+
Version: "master",
241+
Image: "istio-ztunnel",
242+
Registry: "",
243+
imagePath: "",
244+
variant: calicoVariant,
245+
}
246+
247+
ComponentCalicoIstioProxyv2 = Component{
248+
Version: "master",
249+
Image: "istio-proxyv2",
250+
Registry: "",
251+
imagePath: "",
252+
variant: calicoVariant,
253+
}
254+
223255
ComponentCalicoWebhooks = Component{
224256
Version: "master",
225257
Image: "webhooks",
@@ -254,6 +286,10 @@ var (
254286
ComponentCalicoEnvoyProxy,
255287
ComponentCalicoEnvoyRatelimit,
256288
ComponentCalicoGuardian,
289+
ComponentCalicoIstioPilot,
290+
ComponentCalicoIstioInstallCNI,
291+
ComponentCalicoIstioZTunnel,
292+
ComponentCalicoIstioProxyv2,
257293
ComponentCalicoWebhooks,
258294
}
259295
)

pkg/components/enterprise.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,28 +436,28 @@ var (
436436
variant: enterpriseVariant,
437437
}
438438

439-
ComponentCalicoIstioPilot = Component{
439+
ComponentIstioPilot = Component{
440440
Version: "master",
441441
Image: "istio-pilot",
442442
Registry: "",
443443
variant: enterpriseVariant,
444444
}
445445

446-
ComponentCalicoIstioInstallCNI = Component{
446+
ComponentIstioInstallCNI = Component{
447447
Version: "master",
448448
Image: "istio-install-cni",
449449
Registry: "",
450450
variant: enterpriseVariant,
451451
}
452452

453-
ComponentCalicoIstioZTunnel = Component{
453+
ComponentIstioZTunnel = Component{
454454
Version: "master",
455455
Image: "istio-ztunnel",
456456
Registry: "",
457457
variant: enterpriseVariant,
458458
}
459459

460-
ComponentCalicoIstioProxyv2 = Component{
460+
ComponentIstioProxyv2 = Component{
461461
Version: "master",
462462
Image: "istio-proxyv2",
463463
Registry: "",
@@ -524,10 +524,10 @@ var (
524524
ComponentGatewayAPIEnvoyGateway,
525525
ComponentGatewayAPIEnvoyProxy,
526526
ComponentGatewayAPIEnvoyRatelimit,
527-
ComponentCalicoIstioPilot,
528-
ComponentCalicoIstioInstallCNI,
529-
ComponentCalicoIstioZTunnel,
530-
ComponentCalicoIstioProxyv2,
527+
ComponentIstioPilot,
528+
ComponentIstioInstallCNI,
529+
ComponentIstioZTunnel,
530+
ComponentIstioProxyv2,
531531
ComponentTigeraWebhooks,
532532
}
533533
)

pkg/controller/istio/istio_controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ var (
5959
// Start Watches within the Add function for any resources that this controller creates or monitors. This will trigger
6060
// calls to Reconcile() when an instance of one of the watched resources is modified.
6161
func Add(mgr manager.Manager, opts options.ControllerOptions) error {
62-
if !opts.EnterpriseCRDExists {
63-
log.V(1).Info("Enterprise CRDs not found. Skipping Istio controller.")
64-
return nil
65-
}
66-
6762
r := newReconciler(mgr, opts)
6863

6964
c, err := ctrlruntime.NewController("istio-controller", mgr, controller.Options{Reconciler: r})

pkg/controller/istio/istio_controller_test.go

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,90 @@ var _ = Describe("Istio controller tests", func() {
698698
ObjectMeta: metav1.ObjectMeta{
699699
Name: "calico-master",
700700
},
701+
Spec: operatorv1.ImageSetSpec{
702+
Images: []operatorv1.Image{
703+
{Image: "calico/istio-pilot", Digest: "sha256:pilot123"},
704+
{Image: "calico/istio-install-cni", Digest: "sha256:cni123"},
705+
{Image: "calico/istio-ztunnel", Digest: "sha256:ztunnel123"},
706+
{Image: "calico/istio-proxyv2", Digest: "sha256:proxyv2123"},
707+
},
708+
},
709+
}
710+
Expect(cli.Create(ctx, imageSet)).NotTo(HaveOccurred())
711+
712+
r := &ReconcileIstio{
713+
Client: cli,
714+
scheme: scheme,
715+
provider: operatorv1.ProviderNone,
716+
status: mockStatus,
717+
}
718+
719+
_, err := r.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: "default"}})
720+
Expect(err).ShouldNot(HaveOccurred())
721+
722+
// Verify Istiod Deployment uses ImageSet digest
723+
istiodDeploy := &appsv1.Deployment{}
724+
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioIstiodDeploymentName, Namespace: istio.IstioNamespace}, istiodDeploy)).NotTo(HaveOccurred())
725+
Expect(istiodDeploy.Spec.Template.Spec.Containers).NotTo(BeEmpty())
726+
// Verify the pilot container image uses the digest from ImageSet
727+
Expect(istiodDeploy.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("@sha256:pilot123"))
728+
729+
// Verify CNI DaemonSet uses ImageSet digest
730+
cniDaemonSet := &appsv1.DaemonSet{}
731+
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioCNIDaemonSetName, Namespace: istio.IstioNamespace}, cniDaemonSet)).NotTo(HaveOccurred())
732+
Expect(cniDaemonSet.Spec.Template.Spec.Containers).NotTo(BeEmpty())
733+
// Verify the install-cni container image uses the digest from ImageSet
734+
Expect(cniDaemonSet.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("@sha256:cni123"))
735+
736+
// Verify Ztunnel DaemonSet uses ImageSet digest
737+
ztunnelDaemonSet := &appsv1.DaemonSet{}
738+
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioZTunnelDaemonSetName, Namespace: istio.IstioNamespace}, ztunnelDaemonSet)).NotTo(HaveOccurred())
739+
Expect(ztunnelDaemonSet.Spec.Template.Spec.Containers).NotTo(BeEmpty())
740+
// Verify the ztunnel container image uses the digest from ImageSet
741+
Expect(ztunnelDaemonSet.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("@sha256:ztunnel123"))
742+
})
743+
744+
It("should create expected Istio resources for Enterprise variant", func() {
745+
installation.Spec.Variant = operatorv1.TigeraSecureEnterprise
746+
installation.Status.Variant = operatorv1.TigeraSecureEnterprise
747+
Expect(cli.Update(ctx, installation)).NotTo(HaveOccurred())
748+
749+
r := &ReconcileIstio{
750+
Client: cli,
751+
scheme: scheme,
752+
provider: operatorv1.ProviderNone,
753+
status: mockStatus,
754+
}
755+
756+
_, err := r.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: "default"}})
757+
Expect(err).ShouldNot(HaveOccurred())
758+
759+
// Verify Istiod Deployment was created
760+
istiodDeploy := &appsv1.Deployment{}
761+
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioIstiodDeploymentName, Namespace: istio.IstioNamespace}, istiodDeploy)).NotTo(HaveOccurred())
762+
763+
// Verify Istio CNI DaemonSet was created
764+
cniDaemonSet := &appsv1.DaemonSet{}
765+
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioCNIDaemonSetName, Namespace: istio.IstioNamespace}, cniDaemonSet)).NotTo(HaveOccurred())
766+
767+
// Verify Istio Ztunnel DaemonSet was created
768+
ztunnelDaemonSet := &appsv1.DaemonSet{}
769+
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioZTunnelDaemonSetName, Namespace: istio.IstioNamespace}, ztunnelDaemonSet)).NotTo(HaveOccurred())
770+
771+
// Verify status was marked ready
772+
mockStatus.AssertCalled(GinkgoT(), "ClearDegraded")
773+
})
774+
775+
It("should handle ImageSet application for Enterprise variant", func() {
776+
installation.Spec.Variant = operatorv1.TigeraSecureEnterprise
777+
installation.Status.Variant = operatorv1.TigeraSecureEnterprise
778+
Expect(cli.Update(ctx, installation)).NotTo(HaveOccurred())
779+
780+
// Create ImageSet with all required Istio images for Enterprise
781+
imageSet := &operatorv1.ImageSet{
782+
ObjectMeta: metav1.ObjectMeta{
783+
Name: "enterprise-master",
784+
},
701785
Spec: operatorv1.ImageSetSpec{
702786
Images: []operatorv1.Image{
703787
{Image: "tigera/istio-pilot", Digest: "sha256:pilot123"},
@@ -723,21 +807,18 @@ var _ = Describe("Istio controller tests", func() {
723807
istiodDeploy := &appsv1.Deployment{}
724808
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioIstiodDeploymentName, Namespace: istio.IstioNamespace}, istiodDeploy)).NotTo(HaveOccurred())
725809
Expect(istiodDeploy.Spec.Template.Spec.Containers).NotTo(BeEmpty())
726-
// Verify the pilot container image uses the digest from ImageSet
727810
Expect(istiodDeploy.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("@sha256:pilot123"))
728811

729812
// Verify CNI DaemonSet uses ImageSet digest
730813
cniDaemonSet := &appsv1.DaemonSet{}
731814
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioCNIDaemonSetName, Namespace: istio.IstioNamespace}, cniDaemonSet)).NotTo(HaveOccurred())
732815
Expect(cniDaemonSet.Spec.Template.Spec.Containers).NotTo(BeEmpty())
733-
// Verify the install-cni container image uses the digest from ImageSet
734816
Expect(cniDaemonSet.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("@sha256:cni123"))
735817

736818
// Verify Ztunnel DaemonSet uses ImageSet digest
737819
ztunnelDaemonSet := &appsv1.DaemonSet{}
738820
Expect(cli.Get(ctx, types.NamespacedName{Name: istio.IstioZTunnelDaemonSetName, Namespace: istio.IstioNamespace}, ztunnelDaemonSet)).NotTo(HaveOccurred())
739821
Expect(ztunnelDaemonSet.Spec.Template.Spec.Containers).NotTo(BeEmpty())
740-
// Verify the ztunnel container image uses the digest from ImageSet
741822
Expect(ztunnelDaemonSet.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("@sha256:ztunnel123"))
742823
})
743824
})

pkg/imports/crds/crds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var (
5353
)
5454

5555
func init() {
56-
calicoCRDNames := []string{"installation", "apiserver", "gatewayapi", "imageset", "tigerastatus", "whisker", "goldmane", "managementclusterconnection"}
56+
calicoCRDNames := []string{"installation", "apiserver", "gatewayapi", "imageset", "tigerastatus", "whisker", "goldmane", "managementclusterconnection", "istio"}
5757
calicoOprtrCRDsRe = regexp.MustCompile(fmt.Sprintf("(%s)", strings.Join(calicoCRDNames, "|")))
5858
}
5959

pkg/render/istio/istio.go

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,40 @@ func (c *IstioComponent) ResolveImages(is *operatorv1.ImageSet) error {
185185
path := c.cfg.Installation.ImagePath
186186
prefix := c.cfg.Installation.ImagePrefix
187187

188-
c.IstioPilotImage, err = components.GetReference(components.ComponentCalicoIstioPilot, reg, path, prefix, is)
189-
if err != nil {
190-
return err
191-
}
192-
c.IstioInstallCNIImage, err = components.GetReference(components.ComponentCalicoIstioInstallCNI, reg, path, prefix, is)
193-
if err != nil {
194-
return err
195-
}
196-
c.IstioZTunnelImage, err = components.GetReference(components.ComponentCalicoIstioZTunnel, reg, path, prefix, is)
197-
if err != nil {
198-
return err
199-
}
200-
c.IstioProxyv2Image, err = components.GetReference(components.ComponentCalicoIstioProxyv2, reg, path, prefix, is)
201-
if err != nil {
202-
return err
188+
if c.cfg.Installation.Variant == operatorv1.TigeraSecureEnterprise {
189+
c.IstioPilotImage, err = components.GetReference(components.ComponentIstioPilot, reg, path, prefix, is)
190+
if err != nil {
191+
return err
192+
}
193+
c.IstioInstallCNIImage, err = components.GetReference(components.ComponentIstioInstallCNI, reg, path, prefix, is)
194+
if err != nil {
195+
return err
196+
}
197+
c.IstioZTunnelImage, err = components.GetReference(components.ComponentIstioZTunnel, reg, path, prefix, is)
198+
if err != nil {
199+
return err
200+
}
201+
c.IstioProxyv2Image, err = components.GetReference(components.ComponentIstioProxyv2, reg, path, prefix, is)
202+
if err != nil {
203+
return err
204+
}
205+
} else {
206+
c.IstioPilotImage, err = components.GetReference(components.ComponentCalicoIstioPilot, reg, path, prefix, is)
207+
if err != nil {
208+
return err
209+
}
210+
c.IstioInstallCNIImage, err = components.GetReference(components.ComponentCalicoIstioInstallCNI, reg, path, prefix, is)
211+
if err != nil {
212+
return err
213+
}
214+
c.IstioZTunnelImage, err = components.GetReference(components.ComponentCalicoIstioZTunnel, reg, path, prefix, is)
215+
if err != nil {
216+
return err
217+
}
218+
c.IstioProxyv2Image, err = components.GetReference(components.ComponentCalicoIstioProxyv2, reg, path, prefix, is)
219+
if err != nil {
220+
return err
221+
}
203222
}
204223

205224
if err = c.patchImages(); err != nil {

0 commit comments

Comments
 (0)