nodepool

package
v0.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package nodepool provides helpers for Nodepool

Package nodepool functions

Index

Constants

This section is empty.

Variables

View Source
var CreateNamespaceNodepoolCmd = &cobra.Command{
	Use:   "create-namespace-for-nodepool",
	Short: "Create the namespace for nodepool openshiftpods driver",
	Long:  "This command produce a KUBECONFIG file for nodepool",

	Run: func(cmd *cobra.Command, args []string) {
		nodepoolContext, _ := cmd.Flags().GetString("nodepool-context")
		nodepoolNamespace, _ := cmd.Flags().GetString("nodepool-namespace")
		sfContext, _ := cmd.Flags().GetString("sf-context")
		sfNamespace, _ := cmd.Flags().GetString("sf-namespace")
		sfEnv := utils.ENV{
			Cli: utils.CreateKubernetesClientOrDie(sfContext),
			Ctx: context.TODO(),
			Ns:  sfNamespace,
		}
		CreateNamespaceForNodepool(&sfEnv, nodepoolContext, nodepoolNamespace, sfContext)
	},
}
View Source
var ProvidersSecretsCmd = &cobra.Command{
	Use:   "nodepool-providers-secrets",
	Short: "Handle nodepool providers secrets",
	Long:  "This command provides capabilities to dump and update a clouds.yaml and a kube.config file for Nodepool",

	Run: func(cmd *cobra.Command, args []string) {
		sfContext, _ := cmd.Flags().GetString("sf-context")
		sfNamespace, _ := cmd.Flags().GetString("sf-namespace")
		updateOpt, _ := cmd.Flags().GetBool("update")
		dumpOpt, _ := cmd.Flags().GetBool("dump")
		sfEnv := utils.ENV{
			Cli: utils.CreateKubernetesClientOrDie(sfContext),
			Ctx: context.TODO(),
			Ns:  sfNamespace,
		}

		if updateOpt && dumpOpt || !updateOpt && !dumpOpt {
			cmd.Help()
			println()
			println("Either the 'update' or the 'dump' parameter must be set.")
			println()
			os.Exit(1)
		}

		conf := config.GetSFConfigOrDie()

		if updateOpt {
			cloudsContent, _ := utils.GetFileContent(conf.Nodepool.CloudsFile)
			println(conf.Nodepool.CloudsFile)
			kubeContent, _ := utils.GetFileContent(conf.Nodepool.KubeFile)
			ensureNodepoolProvidersSecrets(&sfEnv, cloudsContent, kubeContent)
		}

		if dumpOpt {
			var secret apiv1.Secret
			if utils.GetM(&sfEnv, controllers.NodepoolProvidersSecretsName, &secret) {
				if len(secret.Data["clouds.yaml"]) > 0 {
					os.WriteFile(conf.Nodepool.CloudsFile, secret.Data["clouds.yaml"], 0644)
					println("Updated " + conf.Nodepool.CloudsFile + " with secret content")
				}
				if len(secret.Data["kube.config"]) > 0 {
					os.WriteFile(conf.Nodepool.KubeFile, secret.Data["kube.config"], 0644)
					println("Updated " + conf.Nodepool.KubeFile + " with secret content")
				}
			} else {
				println("Unable to find Secret named: " + controllers.NodepoolProvidersSecretsName)
				os.Exit(1)
			}
		}
	},
}

Functions

func CreateNamespaceForNodepool

func CreateNamespaceForNodepool(sfEnv *utils.ENV, nodepoolContext string, nodepoolNamespace string, sfContext string)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL