From d2df9ccf336875db29282da3b11486e7fd9ff012 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 27 Nov 2020 09:16:43 +0200 Subject: [PATCH] Add service account arg to create commands Signed-off-by: Stefan Prodan --- cmd/flux/create_helmrelease.go | 6 ++++++ cmd/flux/create_kustomization.go | 4 ++-- docs/cmd/flux_create_helmrelease.md | 1 + docs/cmd/flux_create_kustomization.md | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/flux/create_helmrelease.go b/cmd/flux/create_helmrelease.go index d662f14a..3abb3da7 100644 --- a/cmd/flux/create_helmrelease.go +++ b/cmd/flux/create_helmrelease.go @@ -107,6 +107,7 @@ var ( hrTargetNamespace string hrValuesFile string hrValuesFrom flags.HelmReleaseValuesFrom + hrSAName string ) func init() { @@ -116,6 +117,7 @@ func init() { createHelmReleaseCmd.Flags().StringVar(&hrChartVersion, "chart-version", "", "Helm chart version, accepts a semver range (ignored for charts from GitRepository sources)") createHelmReleaseCmd.Flags().StringArrayVar(&hrDependsOn, "depends-on", nil, "HelmReleases that must be ready before this release can be installed, supported formats '' and '/'") createHelmReleaseCmd.Flags().StringVar(&hrTargetNamespace, "target-namespace", "", "namespace to install this release, defaults to the HelmRelease namespace") + createHelmReleaseCmd.Flags().StringVar(&hrSAName, "service-account", "", "the name of the service account to impersonate when reconciling this HelmRelease") createHelmReleaseCmd.Flags().StringVar(&hrValuesFile, "values", "", "local path to the values.yaml file") createHelmReleaseCmd.Flags().Var(&hrValuesFrom, "values-from", hrValuesFrom.Description()) createCmd.AddCommand(createHelmReleaseCmd) @@ -167,6 +169,10 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error { }, } + if hrSAName != "" { + helmRelease.Spec.ServiceAccountName = hrSAName + } + if hrValuesFile != "" { data, err := ioutil.ReadFile(hrValuesFile) if err != nil { diff --git a/cmd/flux/create_kustomization.go b/cmd/flux/create_kustomization.go index 402a5812..af9799c0 100644 --- a/cmd/flux/create_kustomization.go +++ b/cmd/flux/create_kustomization.go @@ -88,13 +88,13 @@ var ( func init() { createKsCmd.Flags().Var(&ksSource, "source", ksSource.Description()) - createKsCmd.Flags().StringVar(&ksPath, "path", "./", "path to the directory containing the Kustomization file") + createKsCmd.Flags().StringVar(&ksPath, "path", "./", "path to the directory containing a kustomization.yaml file") createKsCmd.Flags().BoolVar(&ksPrune, "prune", false, "enable garbage collection") createKsCmd.Flags().StringArrayVar(&ksHealthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '/.'") createKsCmd.Flags().DurationVar(&ksHealthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations") createKsCmd.Flags().StringVar(&ksValidation, "validation", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'") createKsCmd.Flags().StringArrayVar(&ksDependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied, supported formats '' and '/'") - createKsCmd.Flags().StringVar(&ksSAName, "sa-name", "", "service account name") + createKsCmd.Flags().StringVar(&ksSAName, "service-account", "", "the name of the service account to impersonate when reconciling this Kustomization") createKsCmd.Flags().Var(&ksDecryptionProvider, "decryption-provider", ksDecryptionProvider.Description()) createKsCmd.Flags().StringVar(&ksDecryptionSecret, "decryption-secret", "", "set the Kubernetes secret name that contains the OpenPGP private keys used for sops decryption") createKsCmd.Flags().StringVar(&ksTargetNamespace, "target-namespace", "", "overrides the namespace of all Kustomization objects reconciled by this Kustomization") diff --git a/docs/cmd/flux_create_helmrelease.md b/docs/cmd/flux_create_helmrelease.md index 5042d80f..136c365b 100644 --- a/docs/cmd/flux_create_helmrelease.md +++ b/docs/cmd/flux_create_helmrelease.md @@ -75,6 +75,7 @@ flux create helmrelease [name] [flags] --depends-on stringArray HelmReleases that must be ready before this release can be installed, supported formats '' and '/' -h, --help help for helmrelease --release-name string name used for the Helm release, defaults to a composition of '[-]' + --service-account string the name of the service account to impersonate when reconciling this HelmRelease --source helmChartSource source that contains the chart in the format '/',where kind can be one of: (HelmRepository, GitRepository, Bucket) --target-namespace string namespace to install this release, defaults to the HelmRelease namespace --values string local path to the values.yaml file diff --git a/docs/cmd/flux_create_kustomization.md b/docs/cmd/flux_create_kustomization.md index 6652be25..4d6466aa 100644 --- a/docs/cmd/flux_create_kustomization.md +++ b/docs/cmd/flux_create_kustomization.md @@ -50,9 +50,9 @@ flux create kustomization [name] [flags] --health-check stringArray workload to be included in the health assessment, in the format '/.' --health-check-timeout duration timeout of health checking operations (default 2m0s) -h, --help help for kustomization - --path string path to the directory containing the Kustomization file (default "./") + --path string path to the directory containing a kustomization.yaml file (default "./") --prune enable garbage collection - --sa-name string service account name + --service-account string the name of the service account to impersonate when reconciling this Kustomization --source kustomizationSource source that contains the Kubernetes manifests in the format '[/]',where kind can be one of: (GitRepository, Bucket), if kind is not specified it defaults to GitRepository --target-namespace string overrides the namespace of all Kustomization objects reconciled by this Kustomization --validation string validate the manifests before applying them on the cluster, can be 'client' or 'server'