Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/calico_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ components:
version: master
webhooks:
version: master
calico:
version: master
10 changes: 10 additions & 0 deletions hack/gen-versions/calico.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ var (
variant: calicoVariant,
}
{{- end }}
{{ with index .Components.calico }}
ComponentCalico = Component{
Version: "{{ .Version }}",
Image: "{{ .Image }}",
Registry: "{{ .Registry }}",
imagePath: "{{ .ImagePath }}",
variant: calicoVariant,
}
{{- end }}

CalicoImages = []Component{
ComponentCalicoCNI,
Expand Down Expand Up @@ -314,5 +323,6 @@ var (
ComponentCalicoIstioZTunnel,
ComponentCalicoIstioProxyv2,
ComponentCalicoWebhooks,
ComponentCalico,
}
)
2 changes: 1 addition & 1 deletion hack/gen-versions/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ var (
"istio-ztunnel": "istio-ztunnel",
"istio-proxyv2": "istio-proxyv2",
"webhooks": "webhooks",
"calico": "calico",
}

ignoredImages = map[string]struct{}{
"calico": {},
"networking-calico": {},
"calico-private": {},
"manager-proxy": {},
Expand Down
9 changes: 9 additions & 0 deletions pkg/components/calico.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ var (
variant: calicoVariant,
}

ComponentCalico = Component{
Version: "master",
Image: "calico",
Registry: "",
imagePath: "",
variant: calicoVariant,
}

CalicoImages = []Component{
ComponentCalicoCNI,
ComponentCalicoCNIFIPS,
Expand Down Expand Up @@ -291,5 +299,6 @@ var (
ComponentCalicoIstioZTunnel,
ComponentCalicoIstioProxyv2,
ComponentCalicoWebhooks,
ComponentCalico,
}
)
10 changes: 9 additions & 1 deletion pkg/render/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ type apiServerComponent struct {
l7AdmissionControllerImage string
l7AdmissionControllerEnvoyImage string
dikastesImage string
combinedImage bool
}

func (c *apiServerComponent) ResolveImages(is *operatorv1.ImageSet) error {
Expand Down Expand Up @@ -196,10 +197,11 @@ func (c *apiServerComponent) ResolveImages(is *operatorv1.ImageSet) error {
errMsgs = append(errMsgs, err.Error())
}
} else {
c.apiServerImage, err = components.GetReference(components.ComponentCalicoAPIServer, reg, path, prefix, is)
c.apiServerImage, err = components.GetReference(components.ComponentCalico, reg, path, prefix, is)
if err != nil {
errMsgs = append(errMsgs, err.Error())
}
c.combinedImage = true
}
}

Expand Down Expand Up @@ -1175,9 +1177,15 @@ func (c *apiServerComponent) apiServerContainer() corev1.Container {

apiServerTargetPort := getContainerPort(c.cfg, APIServerContainerName).ContainerPort

var apiServerCommand []string
if c.combinedImage {
apiServerCommand = []string{"calico", "component", "apiserver"}
}

apiServer := corev1.Container{
Name: string(APIServerContainerName),
Image: c.apiServerImage,
Command: apiServerCommand,
ImagePullPolicy: ImagePullPolicy(),
Args: c.startUpArgs(),
Env: env,
Expand Down
3 changes: 2 additions & 1 deletion pkg/render/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1867,8 +1867,9 @@ var _ = Describe("API server rendering tests (Calico)", func() {
Expect(len(d.Spec.Template.Spec.Containers)).To(Equal(1))
Expect(d.Spec.Template.Spec.Containers[0].Name).To(Equal("calico-apiserver"))
Expect(d.Spec.Template.Spec.Containers[0].Image).To(Equal(
fmt.Sprintf("testregistry.com/%s%s:%s", components.CalicoImagePath, components.ComponentCalicoAPIServer.Image, components.ComponentCalicoAPIServer.Version),
fmt.Sprintf("testregistry.com/%s%s:%s", components.CalicoImagePath, components.ComponentCalico.Image, components.ComponentCalico.Version),
))
Expect(d.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"calico", "component", "apiserver"}))

expectedArgs := []string{
"--secure-port=5443",
Expand Down
12 changes: 9 additions & 3 deletions pkg/render/csi.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022-2024 Tigera, Inc. All rights reserved.
// Copyright (c) 2022-2026 Tigera, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,6 +53,7 @@ type csiComponent struct {

csiImage string
csiRegistrarImage string
combinedImage bool
}

func CSI(cfg *CSIConfiguration) Component {
Expand Down Expand Up @@ -138,9 +139,14 @@ func (c *csiComponent) csiAffinities() *corev1.Affinity {

func (c *csiComponent) csiContainers() []corev1.Container {
mountPropagation := corev1.MountPropagationBidirectional
var csiCommand []string
if c.combinedImage {
csiCommand = []string{"calico", "component", "csi"}
}
csiContainer := corev1.Container{
Name: CSIContainerName,
Image: c.csiImage,
Command: csiCommand,
ImagePullPolicy: ImagePullPolicy(),
Args: []string{
"--nodeid=$(KUBE_NODE_NAME)",
Expand Down Expand Up @@ -393,11 +399,11 @@ func (c *csiComponent) ResolveImages(is *operatorv1.ImageSet) error {
}
c.csiRegistrarImage, err = components.GetReference(components.ComponentCalicoCSIRegistrarFIPS, reg, path, prefix, is)
} else {
c.csiImage, err = components.GetReference(components.ComponentCalicoCSI, reg, path, prefix, is)
c.csiImage, err = components.GetReference(components.ComponentCalico, reg, path, prefix, is)
if err != nil {
return err
}

c.combinedImage = true
c.csiRegistrarImage, err = components.GetReference(components.ComponentCalicoCSIRegistrar, reg, path, prefix, is)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/render/csi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ var _ = Describe("CSI rendering tests", func() {
Expect(comp.ResolveImages(nil)).To(BeNil())
createObjs, _ := comp.Objects()
dsResource := rtest.GetResource(createObjs, "csi-node-driver", common.CalicoNamespace, "apps", "v1", "DaemonSet")
Expect(dsResource.(*appsv1.DaemonSet).Spec.Template.Spec.Containers[0].Image).To(Equal(fmt.Sprintf("%s%s%s:%s", components.CalicoRegistry, components.CalicoImagePath, components.ComponentCalicoCSI.Image, components.ComponentCalicoCSI.Version)))
Expect(dsResource.(*appsv1.DaemonSet).Spec.Template.Spec.Containers[0].Image).To(Equal(fmt.Sprintf("%s%s%s:%s", components.CalicoRegistry, components.CalicoImagePath, components.ComponentCalico.Image, components.ComponentCalico.Version)))
Expect(dsResource.(*appsv1.DaemonSet).Spec.Template.Spec.Containers[1].Image).To(Equal(fmt.Sprintf("%s%s%s:%s", components.CalicoRegistry, components.CalicoImagePath, components.ComponentCalicoCSIRegistrar.Image, components.ComponentCalicoCSIRegistrar.Version)))
})

Expand Down
58 changes: 44 additions & 14 deletions pkg/render/goldmane/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
GoldmaneConfigFilePath = "/config"
GoldmaneConfigFileName = "config.json"
GoldmaneMetricsServiceName = "goldmane-metrics"
GoldmaneHealthPort = 8080
)

func Goldmane(cfg *Configuration) render.Component {
Expand All @@ -83,6 +84,7 @@ type Component struct {
cfg *Configuration

goldmaneImage string
combinedImage bool
}

func (c *Component) ResolveImages(is *operatorv1.ImageSet) error {
Expand All @@ -92,7 +94,12 @@ func (c *Component) ResolveImages(is *operatorv1.ImageSet) error {

var err error

c.goldmaneImage, err = components.GetReference(components.ComponentCalicoGoldmane, reg, path, prefix, is)
if c.cfg.Installation.Variant == operatorv1.TigeraSecureEnterprise || operatorv1.IsFIPSModeEnabled(c.cfg.Installation.FIPSMode) {
c.goldmaneImage, err = components.GetReference(components.ComponentCalicoGoldmane, reg, path, prefix, is)
} else {
c.goldmaneImage, err = components.GetReference(components.ComponentCalico, reg, path, prefix, is)
c.combinedImage = true
}
if err != nil {
return err
}
Expand Down Expand Up @@ -236,25 +243,48 @@ func (c *Component) goldmaneContainer() corev1.Container {
MountPath: GoldmaneConfigFilePath,
})

readinessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{
Command: []string{"/health", "-ready"},
}},
}
livenessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{
Command: []string{"/health", "-live"},
}},
}

var containerCommand []string
if c.combinedImage {
containerCommand = []string{"calico", "component", "goldmane"}
readinessProbe = &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"calico", "health", fmt.Sprintf("--port=%d", GoldmaneHealthPort), "--type=readiness"},
},
},
PeriodSeconds: 10,
}
livenessProbe = &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"calico", "health", fmt.Sprintf("--port=%d", GoldmaneHealthPort), "--type=liveness"},
},
},
PeriodSeconds: 10,
}
}

return corev1.Container{
Name: GoldmaneContainerName,
Image: c.goldmaneImage,
ImagePullPolicy: render.ImagePullPolicy(),
Command: containerCommand,
Env: env,
SecurityContext: securitycontext.NewNonRootContext(),
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{
Command: []string{"/health", "-ready"},
}},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"/health", "-live"},
},
},
},
VolumeMounts: volumeMounts,
ReadinessProbe: readinessProbe,
LivenessProbe: livenessProbe,
VolumeMounts: volumeMounts,
}
}

Expand Down
16 changes: 9 additions & 7 deletions pkg/render/goldmane/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package goldmane_test

import (
"fmt"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand Down Expand Up @@ -92,6 +94,7 @@ var _ = Describe("ComponentRendering", func() {

DescribeTable("Goldmane Deployment", func(cfg *goldmane.Configuration, expected *appsv1.Deployment) {
component := goldmane.Goldmane(cfg)
Expect(component.ResolveImages(nil)).NotTo(HaveOccurred())
objsToCreate, _ := component.Objects()

deployment, err := rtest.GetResourceOfType[*appsv1.Deployment](objsToCreate, goldmane.GoldmaneName, goldmane.GoldmaneNamespace)
Expand Down Expand Up @@ -138,7 +141,8 @@ var _ = Describe("ComponentRendering", func() {
Containers: []corev1.Container{
{
Name: goldmane.GoldmaneContainerName,
Image: "",
Image: "quay.io/calico/calico:master",
Command: []string{"calico", "component", "goldmane"},
ImagePullPolicy: render.ImagePullPolicy(),
Env: []corev1.EnvVar{
{Name: "LOG_LEVEL", Value: "INFO"},
Expand All @@ -153,15 +157,13 @@ var _ = Describe("ComponentRendering", func() {
SecurityContext: securitycontext.NewNonRootContext(),
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{
Command: []string{"/health", "-ready"},
Command: []string{"calico", "health", fmt.Sprintf("--port=%d", goldmane.GoldmaneHealthPort), "--type=readiness"},
}},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"/health", "-live"},
},
},
ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{
Command: []string{"calico", "health", fmt.Sprintf("--port=%d", goldmane.GoldmaneHealthPort), "--type=liveness"},
}},
},
VolumeMounts: append(
[]corev1.VolumeMount{defaultTLSKeyPair.VolumeMount(rmeta.OSTypeLinux)},
Expand Down
62 changes: 42 additions & 20 deletions pkg/render/kubecontrollers/kube-controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ type kubeControllersComponent struct {
cfg *KubeControllersConfiguration

// Internal state generated by the given configuration.
image string
image string
combinedImage bool

kubeControllerServiceAccountName string
kubeControllerRoleName string
Expand All @@ -242,7 +243,8 @@ func (c *kubeControllersComponent) ResolveImages(is *operatorv1.ImageSet) error
if operatorv1.IsFIPSModeEnabled(c.cfg.Installation.FIPSMode) {
c.image, err = components.GetReference(components.ComponentCalicoKubeControllersFIPS, reg, path, prefix, is)
} else {
c.image, err = components.GetReference(components.ComponentCalicoKubeControllers, reg, path, prefix, is)
c.image, err = components.GetReference(components.ComponentCalico, reg, path, prefix, is)
c.combinedImage = true
}
}
return err
Expand Down Expand Up @@ -589,36 +591,56 @@ func (c *kubeControllersComponent) controllersDeployment() *appsv1.Deployment {
sc.RunAsUser = ptr.Int64ToPtr(999)
sc.RunAsGroup = ptr.Int64ToPtr(0)

container := corev1.Container{
Name: c.kubeControllerName,
Image: c.image,
ImagePullPolicy: render.ImagePullPolicy(),
Env: env,
Resources: c.kubeControllersResources(),
ReadinessProbe: &corev1.Probe{
readinessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"/usr/bin/check-status", "-r"},
},
},
TimeoutSeconds: 10,
}
livenessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"/usr/bin/check-status", "-l"},
},
},
FailureThreshold: 6,
InitialDelaySeconds: 10,
TimeoutSeconds: 10,
}
var containerCommand []string
if c.combinedImage {
containerCommand = []string{"calico", "component", "kube-controllers", "--health-port=9440"}
readinessProbe = &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{
"/usr/bin/check-status",
"-r",
},
Command: []string{"calico", "health", "--port=9440", "--type=readiness"},
},
},
TimeoutSeconds: 10,
},
LivenessProbe: &corev1.Probe{
}
livenessProbe = &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{
"/usr/bin/check-status",
"-l",
},
Command: []string{"calico", "health", "--port=9440", "--type=liveness"},
},
},
FailureThreshold: 6,
InitialDelaySeconds: 10,
TimeoutSeconds: 10,
},
}
}

container := corev1.Container{
Name: c.kubeControllerName,
Image: c.image,
Command: containerCommand,
ImagePullPolicy: render.ImagePullPolicy(),
Env: env,
Resources: c.kubeControllersResources(),
ReadinessProbe: readinessProbe,
LivenessProbe: livenessProbe,
SecurityContext: sc,
VolumeMounts: c.kubeControllersVolumeMounts(),
}
Expand Down
Loading
Loading