deploy

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command *cli.Command = &cli.Command{
	Name:      "deploy",
	Aliases:   []string{"d"},
	Usage:     "Deploy an application to a one of Atlas' Kubernetes clusters.",
	UsageText: "3lv deploy [options] <application-name>",
	Hidden:    true,
	Flags: []cli.Flag{
		shared.SystemNameFlag(
			"The name of the system (Kubernetes namespace) to deploy to.",
		),
		shared.RuntimeCloudProviderFlag(),
		shared.HelmValuesFileFlag(),
		&cli.StringFlag{
			Name:    "image-tag",
			Aliases: []string{"i"},
			Usage:   "The image tag to deploy.",
		},
		&cli.StringFlag{
			Name:    "environment",
			Aliases: []string{"e"},
			Usage:   "The environment to deploy to: sandbox, dev, test or prod",
			Value:   "dev",
			Action: func(_ context.Context, _ *cli.Command, environment string) error {
				allowedEnvironments := []string{"sandbox", "dev", "test", "prod"}
				if !slices.Contains(allowedEnvironments, environment) {
					return cli.Exit(fmt.Sprintf("Invalid environment provided: must be one of %v", allowedEnvironments), 1)
				}

				return nil
			},
		},
		&cli.StringFlag{
			Name:    "workload-type",
			Aliases: []string{"w"},
			Usage:   "The Kubernetes workload type to use: deployment or statefulset",
			Value:   "deployment",
			Action: func(_ context.Context, _ *cli.Command, workloadType string) error {
				allowedWorkloadTypes := []string{"deployment", "statefulset"}
				if !slices.Contains(allowedWorkloadTypes, workloadType) {
					return cli.Exit(fmt.Sprintf("Invalid workload type provided: must be one of %v", allowedWorkloadTypes), 1)
				}

				return nil
			},
		},
		&cli.StringFlag{
			Name:    "commit-hash",
			Aliases: []string{"c"},
			Usage: "The commit hash of the commit being deployed. Used for deployment annotations." +
				" If you are running this command from a git repository," +
				" the commit hash of the latest commit in the currently checked out branch will be used by default.",
		},
		&cli.StringFlag{
			Name:    "commit-message",
			Aliases: []string{"m"},
			Usage: "The commit message of the commit being deployed. Used for deployment annotations." +
				" If you are running this command from a git repository," +
				" the commit message of the latest commit in the currently checked out branch will be used by default.",
		},
		&cli.StringFlag{
			Name:    "repository-name",
			Aliases: []string{"n"},
			Usage: "Name of the repository the code of the application is stored in. Used for deployment annotations." +
				" If you are running this command from a git repository, that repository name will be used by default.",
		},
		&cli.BoolFlag{
			Name:    "dry-run",
			Aliases: []string{"D"},
			Usage:   "Simulate the deployment without actually deploying.",
		},
		&cli.StringFlag{
			Name:    "azure-tenant-id",
			Usage:   "The AKS tenant ID to use",
			Sources: cli.EnvVars("3LV_AZURE_TENANT_ID"),
		},
		&cli.StringFlag{
			Name: "azure-client-id",
			Usage: "The client ID to use when authenticating with the registry." +
				" Must be combined with --azure-federated-token.",
			Sources: cli.EnvVars("3LV_AZURE_CLIENT_ID"),
		},
		&cli.StringFlag{
			Name: "azure-federated-token",
			Usage: "The federated token to use when authenticating with the Azure Container Registry." +
				" Must be combined with --client-id.",
			Sources: cli.EnvVars("3LV_AZURE_FEDERATED_TOKEN"),
		},
		&cli.StringFlag{
			Name:    "aks-subscription-id",
			Usage:   "Subscription ID of the AKS cluster to deploy to.",
			Sources: cli.EnvVars("3LV_AKS_SUBSCRIPTION_ID"),
		},
		&cli.StringFlag{
			Name:    "aks-cluster-name",
			Usage:   "Name of the AKS cluster to deploy to.",
			Sources: cli.EnvVars("3LV_AKS_CLUSTER_NAME"),
		},
		&cli.StringFlag{
			Name:    "aks-resource-group-name",
			Usage:   "Resource group name of the AKS cluster to deploy to.",
			Sources: cli.EnvVars("3LV_AKS_RESOURCE_GROUP_NAME"),
		},
		&cli.StringFlag{
			Name:    "gke-project-id",
			Usage:   "Project ID of the GKE cluster to deploy to.",
			Sources: cli.EnvVars("3LV_GKE_PROJECT_ID"),
		},
		&cli.StringFlag{
			Name:    "gke-cluster-name",
			Usage:   "Name of the GKE cluster to deploy to.",
			Sources: cli.EnvVars("3LV_GKE_CLUSTER_NAME"),
		},
		&cli.StringFlag{
			Name:    "gke-cluster-location",
			Usage:   "Location of the GKE cluster to deploy to.",
			Hidden:  true,
			Sources: cli.EnvVars("3LV_GKE_CLUSTER_LOCATION"),
		},
		&cli.BoolFlag{
			Name:  "add-deployment-annotation",
			Usage: "Add a deployment annotation to Grafana. Requires --grafana-url and --grafana-api-key to be set.",
		},
		&cli.StringFlag{
			Name:  "grafana-url",
			Usage: "The Grafana URL to use for deployment annotations.",
		},
		&cli.StringFlag{
			Name:  "grafana-api-key",
			Usage: "The Grafana API key to use for deployment annotations.",
		},
		&cli.StringFlag{
			Name:  "run-id",
			Usage: "The GitHub Actions run ID to use for deployment annotations.",
		},
		&cli.StringFlag{
			Name: "helm-chart-repository-url",
			Usage: "Override the helm chart repository where the elvia-charts are located." +
				" Useful for testing feature branches." +
				" For instance 'https://raw.githubusercontent.com/3lvia/kubernetes-charts/feature/cool-new-charts'.",
			Sources: cli.EnvVars("3LV_HELM_CHART_REPOSITORY_URL"),
		},
		&cli.BoolFlag{
			Name:    "allow-deploy",
			Hidden:  true,
			Sources: cli.EnvVars("CI"),
		},
	},
	Action: Deploy,
}

Functions

func Deploy

func Deploy(ctx context.Context, c *cli.Command) error

Types

type FormatDeploymentMessageOptions added in v0.12.0

type FormatDeploymentMessageOptions struct {
	RunID string
}

type GcloudGetCredentialsCommandOptions added in v0.11.19

type GcloudGetCredentialsCommandOptions struct {
	ProjectID       string
	ClusterName     string
	ClusterLocation string
	RunOptions      *command.RunOptions
}

type GrafanaAnnotation added in v0.12.0

type GrafanaAnnotation struct {
	What string   `json:"what"` // required
	Data string   `json:"data"` // required
	Tags []string `json:"tags"` // required
}

type PostGrafanaAnnotationOptions added in v0.12.0

type PostGrafanaAnnotationOptions struct {
	RunID string
}

type SetupAKSOptions added in v0.11.4

type SetupAKSOptions struct {
	SubscriptionID    string
	ClusterName       string
	ResourceGroupName string
	AzLoginOptions    *auth.AzLoginCommandOptions
}

type SetupGKEOptions added in v0.11.4

type SetupGKEOptions struct {
	ProjectID       string
	ClusterName     string
	ClusterLocation string
}

Jump to

Keyboard shortcuts

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