Skip to content

Commit

Permalink
Sync Calico CNI images from upstream (#506)
Browse files Browse the repository at this point in the history
* Add Calico upstream images to regsync configuration

* Use `ghcr.io/canonical/k8s-snap` mirror for Calico images
  • Loading branch information
mateoflorido authored Jun 21, 2024
1 parent d0ef772 commit 325380d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 29 deletions.
30 changes: 30 additions & 0 deletions build-scripts/hack/upstream-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,33 @@ sync:
- source: registry.k8s.io/pause:3.10
target: ghcr.io/canonical/k8s-snap/pause:3.10
type: image
- source: docker.io/calico/apiserver:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/apiserver:v3.28.0
type: image
- source: docker.io/calico/cni:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/cni:v3.28.0
type: image
- source: docker.io/calico/csi:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/csi:v3.28.0
type: image
- source: docker.io/calico/ctl:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/ctl:v3.28.0
type: image
- source: docker.io/calico/kube-controllers:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/kube-controllers:v3.28.0
type: image
- source: docker.io/calico/node-driver-registrar:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/node-driver-registrar:v3.28.0
type: image
- source: docker.io/calico/node:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/node:v3.28.0
type: image
- source: docker.io/calico/pod2daemon-flexvol:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/pod2daemon-flexvol:v3.28.0
type: image
- source: docker.io/calico/typha:v3.28.0
target: ghcr.io/canonical/k8s-snap/calico/typha:v3.28.0
type: image
- source: quay.io/tigera/operator:v1.34.0
target: ghcr.io/canonical/k8s-snap/tigera/operator:v1.34.0
type: image
11 changes: 8 additions & 3 deletions src/k8s/pkg/k8sd/features/calico/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ var (
ManifestPath: path.Join("charts", "tigera-operator-v3.28.0.tgz"),
}

// tigeraOperatorRepo represents the repo to fetch the tigera-operator image for calico.
// Note: Tigera is the company behind Calico and the tigera-operator is the operator for Calico.
// TODO: use ROCKs instead of upstream
tigeraOperatorRegistry = "quay.io"
// imageRepo represents the repo to fetch the Calico CNI images.
imageRepo = "ghcr.io/canonical/k8s-snap"

// calicoImageRepo represents the repo to fetch the calico images.
calicoImageRepo = "ghcr.io/canonical/k8s-snap/calico"
// calicoTag represents the tag to use for the calico images.
calicoTag = "v3.28.0"

// tigeraOperatorImage represents the image to fetch for calico.
tigeraOperatorImage = "tigera/operator"
Expand All @@ -27,7 +32,7 @@ var (

// calicoCtlImage represents the image to fetch for calicoctl.
// TODO: use ROCKs instead of upstream
calicoCtlImage = "docker.io/calico/ctl"
calicoCtlImage = "ghcr.io/canonical/k8s-snap/calico/ctl"
// calicoCtlTag represents the tag to use for the calicoctl image.
calicoCtlTag = "v3.28.0"
)
3 changes: 2 additions & 1 deletion src/k8s/pkg/k8sd/features/calico/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func ApplyNetwork(ctx context.Context, snap snap.Snap, cfg types.Network, _ type

values := map[string]any{
"tigeraOperator": map[string]any{
"registry": tigeraOperatorRegistry,
"registry": imageRepo,
"image": tigeraOperatorImage,
"version": tigeraOperatorVersion,
},
Expand All @@ -67,6 +67,7 @@ func ApplyNetwork(ctx context.Context, snap snap.Snap, cfg types.Network, _ type
"calicoNetwork": map[string]any{
"ipPools": podIpPools,
},
"registry": imageRepo,
},
"serviceCIDRs": serviceCIDRs,
}
Expand Down
37 changes: 12 additions & 25 deletions src/k8s/pkg/k8sd/features/calico/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,17 @@ import (

func init() {
images.Register(
fmt.Sprintf("%s/%s:%s", tigeraOperatorRegistry, tigeraOperatorImage, tigeraOperatorVersion),
)

// TODO: configurable Calico images, include in this list
//
// Hardcoded list based on "k8s kubectl get node -o template='{{ range .items }}{{ .metadata.name }}{{":"}}{{ range .status.images }}{{ "\n- " }}{{ index .names 1 }}{{ end }}{{"\n"}}{{ end }}' | grep calico":
//
// - docker.io/calico/node:v3.28.0
// - docker.io/calico/cni:v3.28.0
// - docker.io/calico/apiserver:v3.28.0
// - docker.io/calico/kube-controllers:v3.28.0
// - docker.io/calico/typha:v3.28.0
// - docker.io/calico/node-driver-registrar:v3.28.0
// - docker.io/calico/csi:v3.28.0
// - docker.io/calico/pod2daemon-flexvol:v3.28.0

images.Register(
"docker.io/calico/node:v3.28.0",
"docker.io/calico/cni:v3.28.0",
"docker.io/calico/apiserver:v3.28.0",
"docker.io/calico/kube-controllers:v3.28.0",
"docker.io/calico/typha:v3.28.0",
"docker.io/calico/node-driver-registrar:v3.28.0",
"docker.io/calico/csi:v3.28.0",
"docker.io/calico/pod2daemon-flexvol:v3.28.0",
// Tigera images
fmt.Sprintf("%s/%s:%s", imageRepo, tigeraOperatorImage, tigeraOperatorVersion),
// Calico images
fmt.Sprintf("%s/apiserver:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/cni:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/csi:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/ctl:%s", calicoImageRepo, calicoCtlTag),
fmt.Sprintf("%s/kube-controllers:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/node:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/node-driver-registrar:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/pod2daemon-flexvol:%s", calicoImageRepo, calicoTag),
fmt.Sprintf("%s/typha:%s", calicoImageRepo, calicoTag),
)
}

0 comments on commit 325380d

Please sign in to comment.