Skip to content

Commit

Permalink
upgrade: also bump clustermesh-apiserver
Browse files Browse the repository at this point in the history
We forgot to upgrade this particular DaemonSet if present.

Fixes: #689
Signed-off-by: Casey Callendrello <cdc@isovalent.com>
  • Loading branch information
squeed authored and tklauser committed Jul 28, 2022
1 parent cc2739a commit fdd4727
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
HubbleUIBackendImage = "quay.io/cilium/hubble-ui-backend"

ClusterMeshDeploymentName = "clustermesh-apiserver"
ClusterMeshContainerName = "apiserver"
ClusterMeshServiceAccountName = "clustermesh-apiserver"
ClusterMeshClusterRoleName = "clustermesh-apiserver"
ClusterMeshApiserverImage = "quay.io/cilium/clustermesh-apiserver"
Expand Down
5 changes: 5 additions & 0 deletions install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ type Parameters struct {
AgentImage string
OperatorImage string
RelayImage string
ClusterMeshAPIImage string
InheritCA string
Wait bool
WaitDuration time.Duration
Expand Down Expand Up @@ -345,6 +346,10 @@ func (k *K8sInstaller) fqRelayImage(imagePathMode utils.ImagePathMode) string {
return utils.BuildImagePath(k.params.RelayImage, k.params.Version, defaults.RelayImage, defaults.Version, imagePathMode)
}

func (k *K8sInstaller) fqClusterMeshAPIImage(imagePathMode utils.ImagePathMode) string {
return utils.BuildImagePath(k.params.ClusterMeshAPIImage, k.params.Version, defaults.ClusterMeshApiserverImage, defaults.Version, imagePathMode)
}

func NewK8sInstaller(client k8sInstallerImplementation, p Parameters) (*K8sInstaller, error) {
if err := (&p).validate(); err != nil {
return nil, fmt.Errorf("invalid parameters: %w", err)
Expand Down
18 changes: 17 additions & 1 deletion install/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,29 @@ func (k *K8sInstaller) Upgrade(ctx context.Context) error {
}
}

clustermeshAPIServerDeployment, err := k.client.GetDeployment(ctx, k.params.Namespace, defaults.ClusterMeshDeploymentName, metav1.GetOptions{})
if err != nil && !k8serrors.IsNotFound(err) {
return fmt.Errorf("unable to retrieve Deployment of %s: %w", defaults.ClusterMeshDeploymentName, err)
}

if err == nil { // only update clustermesh-apiserver if deployment was found on the cluster
if err = upgradeDeployment(ctx, k, upgradeDeploymentParams{
deployment: clustermeshAPIServerDeployment,
imageIncludeDigest: k.fqClusterMeshAPIImage(utils.ImagePathIncludeDigest),
imageExcludeDigest: k.fqClusterMeshAPIImage(utils.ImagePathExcludeDigest),
containerName: defaults.ClusterMeshContainerName,
}, &patched); err != nil {
return err
}
}

if patched > 0 && k.params.Wait {
k.Log("⌛ Waiting for Cilium to be upgraded...")
collector, err := status.NewK8sStatusCollector(k.client, status.K8sStatusParameters{
Namespace: k.params.Namespace,
Wait: true,
WaitDuration: k.params.WaitDuration,
WarningFreePods: []string{defaults.AgentDaemonSetName, defaults.OperatorDeploymentName, defaults.RelayDeploymentName},
WarningFreePods: []string{defaults.AgentDaemonSetName, defaults.OperatorDeploymentName, defaults.RelayDeploymentName, defaults.ClusterMeshDeploymentName},
})
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions internal/cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ cilium upgrade --version %s
cmd.Flags().StringVar(&params.AgentImage, "agent-image", "", "Image path to use for Cilium agent")
cmd.Flags().StringVar(&params.OperatorImage, "operator-image", "", "Image path to use for Cilium operator")
cmd.Flags().StringVar(&params.RelayImage, "hubble-relay-image", "", "Image path to use for Hubble Relay")
cmd.Flags().StringVar(&params.ClusterMeshAPIImage, "clustermesh-apiserver-image", "", "Image path to use for cluster mesh API server")

return cmd
}

0 comments on commit fdd4727

Please sign in to comment.