Skip to content

Commit

Permalink
Add deployments reason for helm history
Browse files Browse the repository at this point in the history
Migration deploys the helm chart multiple times. Identifying which
revision corresponds to which step in helm history is hard without a
description.
  • Loading branch information
cbosdo committed Sep 24, 2024
1 parent 20e6345 commit b203265
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions mgradm/cmd/install/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func installForKubernetes(globalFlags *types.GlobalFlags,

// Deploy Uyuni and wait for it to be up
if err := kubernetes.Deploy(
L("Initial deployment from mgradm install"),
cnx, flags.Image.Registry, &flags.Image, &flags.HubXmlrpc, &flags.Helm, &flags.Ssl,
clusterInfos, fqdn, flags.Debug.Java, false, helmArgs...,
); err != nil {
Expand Down
9 changes: 7 additions & 2 deletions mgradm/cmd/migrate/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ func migrateToKubernetes(
var sslFlags adm_utils.SslCertFlags

// Deploy for running migration command
if err := kubernetes.Deploy(cnx, flags.Image.Registry, &flags.Image, &flags.HubXmlrpc,
if err := kubernetes.Deploy(
fmt.Sprintf(L("Deploy to migrate the data from %s"), fqdn),
cnx, flags.Image.Registry, &flags.Image, &flags.HubXmlrpc,
&flags.Helm, &sslFlags, clusterInfos, fqdn, false, flags.Prepare,
"--set", "migration.ssh.agentSocket="+sshAuthSocket,
"--set", "migration.ssh.configPath="+sshConfigPath,
Expand Down Expand Up @@ -147,6 +149,7 @@ func migrateToKubernetes(
// Run uyuni upgrade using the new ssl certificate
// We don't need to start the Hub XML-RPC API containers during the setup phase
err = kubernetes.UyuniUpgrade(
L("Upgrade with final volumes"),
serverImage, flags.Image.PullPolicy, 0, hubXmlrpcImage, &flags.Helm,
kubeconfig, fqdn, clusterInfos.Ingress, helmArgs...,
)
Expand Down Expand Up @@ -191,7 +194,9 @@ func migrateToKubernetes(

// This is the final deployment, all the replicas need to be correct here.
err = kubernetes.UyuniUpgrade(
serverImage, flags.Image.PullPolicy, hubReplicas, hubXmlrpcImage, &flags.Helm, kubeconfig, fqdn, clusterInfos.Ingress, helmArgs...,
L("Complete deployment after migration"),
serverImage, flags.Image.PullPolicy, hubReplicas, hubXmlrpcImage, &flags.Helm, kubeconfig, fqdn,
clusterInfos.Ingress, helmArgs...,
)
if err != nil {
return utils.Errorf(err, L("cannot upgrade to image %s"), serverImage)
Expand Down
30 changes: 25 additions & 5 deletions mgradm/shared/kubernetes/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const HELM_APP_NAME = "uyuni"

// Deploy execute a deploy of a given image and helm to a cluster.
func Deploy(
reason string,
cnx *shared.Connection,
registry string,
imageFlags *types.ImageFlags,
Expand Down Expand Up @@ -60,7 +61,10 @@ func Deploy(
}

// Install the uyuni server helm chart
err = UyuniUpgrade(serverImage, imageFlags.PullPolicy, hubXmlrpcFlags.Replicas, hubXmlrpcImage, helmFlags, clusterInfos.GetKubeconfig(), fqdn, clusterInfos.Ingress, helmArgs...)
err = UyuniUpgrade(
reason, serverImage, imageFlags.PullPolicy, hubXmlrpcFlags.Replicas, hubXmlrpcImage,
helmFlags, clusterInfos.GetKubeconfig(), fqdn, clusterInfos.Ingress, helmArgs...,
)
if err != nil {
return utils.Errorf(err, L("cannot upgrade"))
}
Expand Down Expand Up @@ -106,8 +110,18 @@ func DeployExistingCertificate(helmFlags *cmd_utils.HelmFlags, sslFlags *cmd_uti
}

// UyuniUpgrade runs an helm upgrade using images and helm configuration as parameters.
func UyuniUpgrade(serverImage string, pullPolicy string, hubXmlrpcReplicas int, hubXmlrpcImage string, helmFlags *cmd_utils.HelmFlags, kubeconfig string,
fqdn string, ingress string, helmArgs ...string) error {
func UyuniUpgrade(
reason string,
serverImage string,
pullPolicy string,
hubXmlrpcReplicas int,
hubXmlrpcImage string,
helmFlags *cmd_utils.HelmFlags,
kubeconfig string,
fqdn string,
ingress string,
helmArgs ...string,
) error {
log.Info().Msg(L("Installing Uyuni"))

// The guessed ingress is passed before the user's value to let the user override it in case we got it wrong.
Expand All @@ -124,7 +138,9 @@ func UyuniUpgrade(serverImage string, pullPolicy string, hubXmlrpcReplicas int,
helmParams = append(helmParams,
"--set", "images.server="+serverImage,
"--set", "pullPolicy="+kubernetes.GetPullPolicy(pullPolicy),
"--set", "fqdn="+fqdn)
"--set", "fqdn="+fqdn,
"--description", reason,
)

if hubXmlrpcReplicas > 0 {
log.Info().Msg(L("Enabling Hub XMLRPC API container."))
Expand Down Expand Up @@ -252,7 +268,11 @@ func Upgrade(
hubXmlrpcReplicas = 1
}

err = UyuniUpgrade(serverImage, image.PullPolicy, hubXmlrpcReplicas, hubXmlrpcImageName, &helm, kubeconfig, fqdn, clusterInfos.Ingress)
err = UyuniUpgrade(
L("Upgrade from mgradm"),
serverImage, image.PullPolicy, hubXmlrpcReplicas, hubXmlrpcImageName,
&helm, kubeconfig, fqdn, clusterInfos.Ingress,
)
if err != nil {
return utils.Errorf(err, L("cannot upgrade to image %s"), serverImage)
}
Expand Down

0 comments on commit b203265

Please sign in to comment.