diff --git a/cmd/tk/bootstrap_github.go b/cmd/tk/bootstrap_github.go index 4e7f8d5fcda5eb0ece27504fce637518b8aa40a0..ad4a6fbbb75df037daf6a45b5a59c33c00e0df10 100644 --- a/cmd/tk/bootstrap_github.go +++ b/cmd/tk/bootstrap_github.go @@ -42,19 +42,19 @@ the bootstrap command will perform an upgrade if needed.`, export GITHUB_TOKEN=<my-token> # Run bootstrap for a private repo owned by a GitHub organization - bootstrap github --owner=<organization> --repository=<repo name> + tk bootstrap github --owner=<organization> --repository=<repo name> # Run bootstrap for a private repo and assign organization teams to it - bootstrap github --owner=<organization> --repository=<repo name> --team=<team1 slug> --team=<team2 slug> + tk bootstrap github --owner=<organization> --repository=<repo name> --team=<team1 slug> --team=<team2 slug> # Run bootstrap for a repository path - bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster + tk bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster # Run bootstrap for a public repository on a personal account - bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true + tk bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true # Run bootstrap for a private repo hosted on GitHub Enterprise - bootstrap github --owner=<organization> --repository=<repo name> --hostname=<domain> + tk bootstrap github --owner=<organization> --repository=<repo name> --hostname=<domain> `, RunE: bootstrapGitHubCmdRun, } diff --git a/cmd/tk/bootstrap_gitlab.go b/cmd/tk/bootstrap_gitlab.go index d35aab4f7a91d38489dc10aad90ceb84eea4f72b..b259e7bc54b5d30be7e7b1ec748444b8ed279f01 100644 --- a/cmd/tk/bootstrap_gitlab.go +++ b/cmd/tk/bootstrap_gitlab.go @@ -42,16 +42,16 @@ the bootstrap command will perform an upgrade if needed.`, export GITLAB_TOKEN=<my-token> # Run bootstrap for a private repo owned by a GitLab group - bootstrap gitlab --owner=<group> --repository=<repo name> + tk bootstrap gitlab --owner=<group> --repository=<repo name> # Run bootstrap for a repository path - bootstrap gitlab --owner=<group> --repository=<repo name> --path=dev-cluster + tk bootstrap gitlab --owner=<group> --repository=<repo name> --path=dev-cluster # Run bootstrap for a public repository on a personal account - bootstrap gitlab --owner=<user> --repository=<repo name> --private=false --personal=true + tk bootstrap gitlab --owner=<user> --repository=<repo name> --private=false --personal=true # Run bootstrap for a private repo hosted on a GitLab server - bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain> + tk bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain> `, RunE: bootstrapGitLabCmdRun, } diff --git a/cmd/tk/create_kustomization.go b/cmd/tk/create_kustomization.go index 13ce334e16727d68368bd8b6526185a5ccc360b7..e358f5334a3991c8d52b460b9695141457505c29 100644 --- a/cmd/tk/create_kustomization.go +++ b/cmd/tk/create_kustomization.go @@ -40,7 +40,7 @@ var createKsCmd = &cobra.Command{ Short: "Create or update a Kustomization resource", Long: "The kustomization source create command generates a Kustomize resource for a given GitRepository source.", Example: ` # Create a Kustomization resource from a source at a given path - create kustomization contour \ + tk create kustomization contour \ --source=contour \ --path="./examples/contour/" \ --prune=true \ @@ -51,7 +51,7 @@ var createKsCmd = &cobra.Command{ --health-check-timeout=3m # Create a Kustomization resource that depends on the previous one - create kustomization webapp \ + tk create kustomization webapp \ --depends-on=contour \ --source=webapp \ --path="./deploy/overlays/dev" \ @@ -60,7 +60,7 @@ var createKsCmd = &cobra.Command{ --validation=client # Create a Kustomization resource that runs under a service account - create kustomization webapp \ + tk create kustomization webapp \ --source=webapp \ --path="./deploy/overlays/staging" \ --prune=true \ diff --git a/cmd/tk/create_source_git.go b/cmd/tk/create_source_git.go index 78d183eb995c45823fe1a671e1fecf095e37defd..9fa7d6f2d2f20daa2ff879313b66c5001379735d 100644 --- a/cmd/tk/create_source_git.go +++ b/cmd/tk/create_source_git.go @@ -46,35 +46,35 @@ The create source git command generates a GitRepository resource and waits for i For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret. For private Git repositories, the basic authentication credentials are stored in a Kubernetes secret.`, Example: ` # Create a source from a public Git repository master branch - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --branch=master # Create a source from a Git repository pinned to specific git tag - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --tag="3.2.3" # Create a source from a public Git repository tag that matches a semver range - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --tag-semver=">=3.2.0 <3.3.0" # Create a source from a Git repository using SSH authentication - create source git podinfo \ + tk create source git podinfo \ --url=ssh://git@github.com/stefanprodan/podinfo \ --branch=master # Create a source from a Git repository using SSH authentication and an # ECDSA P-521 curve public key - create source git podinfo \ + tk create source git podinfo \ --url=ssh://git@github.com/stefanprodan/podinfo \ --branch=master \ --ssh-key-algorithm=ecdsa \ --ssh-ecdsa-curve=p521 # Create a source from a Git repository using basic authentication - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --username=username \ --password=password @@ -115,7 +115,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { name := args[0] if sourceGitURL == "" { - return fmt.Errorf("git-url is required") + return fmt.Errorf("url is required") } tmpDir, err := ioutil.TempDir("", name) diff --git a/cmd/tk/create_source_helm.go b/cmd/tk/create_source_helm.go new file mode 100644 index 0000000000000000000000000000000000000000..0b1f0e925e9a7512b89ae3de73f57f8624f3bb92 --- /dev/null +++ b/cmd/tk/create_source_helm.go @@ -0,0 +1,229 @@ +/* +Copyright 2020 The Flux CD contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + "fmt" + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + "github.com/spf13/cobra" + "io/ioutil" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/wait" + "net/url" + "os" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/yaml" +) + +var createSourceHelmCmd = &cobra.Command{ + Use: "helm [name]", + Short: "Create or update a HelmRepository source", + Long: ` +The create source helm command generates a HelmRepository resource and waits for it to fetch the index. +For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret.`, + Example: ` # Create a source from a public Helm repository + tk create source helm podinfo \ + --url=https://stefanprodan.github.io/podinfo \ + --interval=10m + + # Create a source from a Helm repository using basic authentication + tk create source helm podinfo \ + --url=https://stefanprodan.github.io/podinfo \ + --username=username \ + --password=password +`, + RunE: createSourceHelmCmdRun, +} + +var ( + sourceHelmURL string + sourceHelmUsername string + sourceHelmPassword string +) + +func init() { + createSourceHelmCmd.Flags().StringVar(&sourceHelmURL, "url", "", "Helm repository address") + createSourceHelmCmd.Flags().StringVarP(&sourceHelmUsername, "username", "u", "", "basic authentication username") + createSourceHelmCmd.Flags().StringVarP(&sourceHelmPassword, "password", "p", "", "basic authentication password") + + createSourceCmd.AddCommand(createSourceHelmCmd) +} + +func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return fmt.Errorf("source name is required") + } + name := args[0] + secretName := fmt.Sprintf("helm-%s", name) + + if sourceHelmURL == "" { + return fmt.Errorf("url is required") + } + + tmpDir, err := ioutil.TempDir("", name) + if err != nil { + return err + } + defer os.RemoveAll(tmpDir) + + if _, err := url.Parse(sourceHelmURL); err != nil { + return fmt.Errorf("url parse failed: %w", err) + } + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + kubeClient, err := utils.kubeClient(kubeconfig) + if err != nil { + return err + } + + helmRepository := sourcev1.HelmRepository{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: sourcev1.HelmRepositorySpec{ + URL: sourceHelmURL, + Interval: metav1.Duration{ + Duration: interval, + }, + }, + } + + if export { + return exportHelmRepository(helmRepository) + } + + withAuth := false + if sourceHelmUsername != "" && sourceHelmPassword != "" { + logger.Actionf("applying secret with basic auth credentials") + secret := corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: secretName, + Namespace: namespace, + }, + StringData: map[string]string{ + "username": sourceHelmUsername, + "password": sourceHelmPassword, + }, + } + if err := upsertSecret(ctx, kubeClient, secret); err != nil { + return err + } + withAuth = true + } + + if withAuth { + logger.Successf("authentication configured") + } + + logger.Generatef("generating source") + + if withAuth { + helmRepository.Spec.SecretRef = &corev1.LocalObjectReference{ + Name: secretName, + } + } + + logger.Actionf("applying source") + if err := upsertHelmRepository(ctx, kubeClient, helmRepository); err != nil { + return err + } + + logger.Waitingf("waiting for index download") + if err := wait.PollImmediate(pollInterval, timeout, + isHelmRepositoryReady(ctx, kubeClient, name, namespace)); err != nil { + return err + } + + logger.Successf("index download completed") + + namespacedName := types.NamespacedName{ + Namespace: namespace, + Name: name, + } + err = kubeClient.Get(ctx, namespacedName, &helmRepository) + if err != nil { + return fmt.Errorf("helm index failed: %w", err) + } + + if helmRepository.Status.Artifact != nil { + logger.Successf("fetched revision: %s", helmRepository.Status.Artifact.Revision) + } else { + return fmt.Errorf("index download failed, artifact not found") + } + + return nil +} + +func upsertHelmRepository(ctx context.Context, kubeClient client.Client, helmRepository sourcev1.HelmRepository) error { + namespacedName := types.NamespacedName{ + Namespace: helmRepository.GetNamespace(), + Name: helmRepository.GetName(), + } + + var existing sourcev1.HelmRepository + err := kubeClient.Get(ctx, namespacedName, &existing) + if err != nil { + if errors.IsNotFound(err) { + if err := kubeClient.Create(ctx, &helmRepository); err != nil { + return err + } else { + logger.Successf("source created") + return nil + } + } + return err + } + + existing.Spec = helmRepository.Spec + if err := kubeClient.Update(ctx, &existing); err != nil { + return err + } + + logger.Successf("source updated") + return nil +} + +func exportHelmRepository(source sourcev1.HelmRepository) error { + gvk := sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind) + export := sourcev1.HelmRepository{ + TypeMeta: metav1.TypeMeta{ + Kind: gvk.Kind, + APIVersion: gvk.GroupVersion().String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: source.Name, + Namespace: source.Namespace, + }, + Spec: source.Spec, + } + + data, err := yaml.Marshal(export) + if err != nil { + return err + } + + fmt.Println("---") + fmt.Println(string(data)) + return nil +} diff --git a/cmd/tk/delete_kustomization.go b/cmd/tk/delete_kustomization.go index d72bf18637954637030899a99c77b04542d884c9..68c61851bdbf27fc7203f3e00925331d1ea37497 100644 --- a/cmd/tk/delete_kustomization.go +++ b/cmd/tk/delete_kustomization.go @@ -31,7 +31,10 @@ var deleteKsCmd = &cobra.Command{ Aliases: []string{"ks"}, Short: "Delete a Kustomization resource", Long: "The delete kustomization command deletes the given Kustomization from the cluster.", - RunE: deleteKsCmdRun, + Example: ` # Delete a kustomization and the Kubernetes resources created by it + tk delete kustomization podinfo +`, + RunE: deleteKsCmdRun, } func init() { diff --git a/cmd/tk/delete_source_git.go b/cmd/tk/delete_source_git.go index cbb4f092fde811872633257b25f80aa7c2dc69ee..e307905e3b196d5ed93398caffa402a921c5051c 100644 --- a/cmd/tk/delete_source_git.go +++ b/cmd/tk/delete_source_git.go @@ -30,7 +30,10 @@ var deleteSourceGitCmd = &cobra.Command{ Use: "git [name]", Short: "Delete a GitRepository source", Long: "The delete source git command deletes the given GitRepository from the cluster.", - RunE: deleteSourceGitCmdRun, + Example: ` # Delete a Git repository + tk delete source git podinfo +`, + RunE: deleteSourceGitCmdRun, } func init() { diff --git a/cmd/tk/delete_source_helm.go b/cmd/tk/delete_source_helm.go new file mode 100644 index 0000000000000000000000000000000000000000..6dbe8397093c7abb38b07bf35f087f48651447dd --- /dev/null +++ b/cmd/tk/delete_source_helm.go @@ -0,0 +1,86 @@ +/* +Copyright 2020 The Flux CD contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + "fmt" + + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + "github.com/manifoldco/promptui" + "github.com/spf13/cobra" + "k8s.io/apimachinery/pkg/types" +) + +var deleteSourceHelmCmd = &cobra.Command{ + Use: "helm [name]", + Short: "Delete a HelmRepository source", + Long: "The delete source helm command deletes the given HelmRepository from the cluster.", + Example: ` # Delete a Helm repository + tk delete source helm podinfo +`, + RunE: deleteSourceHelmCmdRun, +} + +func init() { + deleteSourceCmd.AddCommand(deleteSourceHelmCmd) +} + +func deleteSourceHelmCmdRun(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return fmt.Errorf("name is required") + } + name := args[0] + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + kubeClient, err := utils.kubeClient(kubeconfig) + if err != nil { + return err + } + + namespacedName := types.NamespacedName{ + Namespace: namespace, + Name: name, + } + + var helmRepository sourcev1.HelmRepository + err = kubeClient.Get(ctx, namespacedName, &helmRepository) + if err != nil { + return err + } + + if !deleteSilent { + prompt := promptui.Prompt{ + Label: "Are you sure you want to delete this source", + IsConfirm: true, + } + if _, err := prompt.Run(); err != nil { + return fmt.Errorf("aborting") + } + } + + logger.Actionf("deleting source %s in %s namespace", name, namespace) + err = kubeClient.Delete(ctx, &helmRepository) + if err != nil { + return err + } + logger.Successf("source deleted") + + return nil +} diff --git a/cmd/tk/export_kustomization.go b/cmd/tk/export_kustomization.go index 17fc28007306cbfb4e2a6d18137bd74fc31fe3c3..71032de4eab197791081626c90e7cf96431e8ca7 100644 --- a/cmd/tk/export_kustomization.go +++ b/cmd/tk/export_kustomization.go @@ -34,10 +34,10 @@ var exportKsCmd = &cobra.Command{ Short: "Export Kustomization resources in YAML format", Long: "The export kustomization command exports one or all Kustomization resources in YAML format.", Example: ` # Export all Kustomization resources - export kustomization --all > kustomizations.yaml + tk export kustomization --all > kustomizations.yaml # Export a Kustomization - export kustomization my-app > kustomization.yaml + tk export kustomization my-app > kustomization.yaml `, RunE: exportKsCmdRun, } diff --git a/cmd/tk/export_source_git.go b/cmd/tk/export_source_git.go index 6b8dafa84f7ea052ff5055f5dcff0699ecaf6b40..f891748c5c9d4473aab8faadb3e4825b39a31e52 100644 --- a/cmd/tk/export_source_git.go +++ b/cmd/tk/export_source_git.go @@ -34,10 +34,10 @@ var exportSourceGitCmd = &cobra.Command{ Short: "Export GitRepository sources in YAML format", Long: "The export source git command exports on or all GitRepository sources in YAML format.", Example: ` # Export all GitRepository sources - export source git --all > sources.yaml + tk export source git --all > sources.yaml # Export a GitRepository source including the SSH key pair or basic auth credentials - export source git my-private-repo --with-credentials > source.yaml + tk export source git my-private-repo --with-credentials > source.yaml `, RunE: exportSourceGitCmdRun, } @@ -48,7 +48,7 @@ func init() { func exportSourceGitCmdRun(cmd *cobra.Command, args []string) error { if !exportAll && len(args) < 1 { - return fmt.Errorf("kustomization name is required") + return fmt.Errorf("name is required") } ctx, cancel := context.WithTimeout(context.Background(), timeout) @@ -103,7 +103,7 @@ func exportSourceGitCmdRun(cmd *cobra.Command, args []string) error { } func exportGit(source sourcev1.GitRepository) error { - gvk := sourcev1.GroupVersion.WithKind("GitRepository") + gvk := sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind) export := sourcev1.GitRepository{ TypeMeta: metav1.TypeMeta{ Kind: gvk.Kind, diff --git a/cmd/tk/export_source_helm.go b/cmd/tk/export_source_helm.go new file mode 100644 index 0000000000000000000000000000000000000000..1026693c744df5cd493a74fb08a9b7189799582e --- /dev/null +++ b/cmd/tk/export_source_helm.go @@ -0,0 +1,139 @@ +/* +Copyright 2020 The Flux CD contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + "fmt" + + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + "github.com/spf13/cobra" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/yaml" +) + +var exportSourceHelmCmd = &cobra.Command{ + Use: "helm [name]", + Short: "Export HelmRepository sources in YAML format", + Long: "The export source git command exports on or all HelmRepository sources in YAML format.", + Example: ` # Export all HelmRepository sources + tk export source helm --all > sources.yaml + + # Export a HelmRepository source including the basic auth credentials + tk export source helm my-private-repo --with-credentials > source.yaml +`, + RunE: exportSourceHelmCmdRun, +} + +func init() { + exportSourceCmd.AddCommand(exportSourceHelmCmd) +} + +func exportSourceHelmCmdRun(cmd *cobra.Command, args []string) error { + if !exportAll && len(args) < 1 { + return fmt.Errorf("name is required") + } + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + kubeClient, err := utils.kubeClient(kubeconfig) + if err != nil { + return err + } + + if exportAll { + var list sourcev1.HelmRepositoryList + err = kubeClient.List(ctx, &list, client.InNamespace(namespace)) + if err != nil { + return err + } + + if len(list.Items) == 0 { + logger.Failuref("no source found in %s namespace", namespace) + return nil + } + + for _, repository := range list.Items { + if err := exportHelmRepository(repository); err != nil { + return err + } + if exportSourceWithCred { + if err := exportHelmCredentials(ctx, kubeClient, repository); err != nil { + return err + } + } + } + } else { + name := args[0] + namespacedName := types.NamespacedName{ + Namespace: namespace, + Name: name, + } + var repository sourcev1.HelmRepository + err = kubeClient.Get(ctx, namespacedName, &repository) + if err != nil { + return err + } + if err := exportHelmRepository(repository); err != nil { + return err + } + if exportSourceWithCred { + return exportHelmCredentials(ctx, kubeClient, repository) + } + } + return nil +} + +func exportHelmCredentials(ctx context.Context, kubeClient client.Client, source sourcev1.HelmRepository) error { + if source.Spec.SecretRef != nil { + namespacedName := types.NamespacedName{ + Namespace: source.Namespace, + Name: source.Spec.SecretRef.Name, + } + var cred corev1.Secret + err := kubeClient.Get(ctx, namespacedName, &cred) + if err != nil { + return fmt.Errorf("failed to retrieve secret %s, error: %w", namespacedName.Name, err) + } + + exported := corev1.Secret{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "Secret", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: namespacedName.Name, + Namespace: namespacedName.Namespace, + }, + Data: cred.Data, + Type: cred.Type, + } + + data, err := yaml.Marshal(exported) + if err != nil { + return err + } + + fmt.Println("---") + fmt.Println(string(data)) + } + return nil +} diff --git a/cmd/tk/get_kustomization.go b/cmd/tk/get_kustomization.go index f53d96006db247881673f7bd6a2f695d7c7495c7..83ad4aacf24cef1ee95e0c7d67fded28241622ea 100644 --- a/cmd/tk/get_kustomization.go +++ b/cmd/tk/get_kustomization.go @@ -28,9 +28,12 @@ import ( var getKsCmd = &cobra.Command{ Use: "kustomizations", Aliases: []string{"ks"}, - Short: "Get Kustomization source statuses", + Short: "Get Kustomization statuses", Long: "The get kustomizations command prints the statuses of the resources.", - RunE: getKsCmdRun, + Example: ` # List all kustomizations and their status + tk get kustomizations +`, + RunE: getKsCmdRun, } func init() { diff --git a/cmd/tk/get_source_git.go b/cmd/tk/get_source_git.go index f490b66da82ac5d07eb687f041c555b517392a86..9492a2c5213f51e19c87fa9d498b73a4f6427fd4 100644 --- a/cmd/tk/get_source_git.go +++ b/cmd/tk/get_source_git.go @@ -29,7 +29,10 @@ var getSourceGitCmd = &cobra.Command{ Use: "git", Short: "Get GitRepository source statuses", Long: "The get sources git command prints the status of the GitRepository sources.", - RunE: getSourceGitCmdRun, + Example: ` # List all Git repositories and their status + tk get sources git +`, + RunE: getSourceGitCmdRun, } func init() { diff --git a/cmd/tk/get_source_helm.go b/cmd/tk/get_source_helm.go new file mode 100644 index 0000000000000000000000000000000000000000..04d46635733f2c72ac8bdf8c8b0f0ea758bfc73b --- /dev/null +++ b/cmd/tk/get_source_helm.go @@ -0,0 +1,80 @@ +/* +Copyright 2020 The Flux CD contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + "github.com/spf13/cobra" + corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var getSourceHelmCmd = &cobra.Command{ + Use: "helm", + Short: "Get HelmRepository source statuses", + Long: "The get sources helm command prints the status of the HelmRepository sources.", + Example: ` # List all Helm repositories and their status + tk get sources helm +`, + RunE: getSourceHelmCmdRun, +} + +func init() { + getSourceCmd.AddCommand(getSourceHelmCmd) +} + +func getSourceHelmCmdRun(cmd *cobra.Command, args []string) error { + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + kubeClient, err := utils.kubeClient(kubeconfig) + if err != nil { + return err + } + + var list sourcev1.HelmRepositoryList + err = kubeClient.List(ctx, &list, client.InNamespace(namespace)) + if err != nil { + return err + } + + if len(list.Items) == 0 { + logger.Failuref("no sources found in %s namespace", namespace) + return nil + } + + for _, source := range list.Items { + isInitialized := false + for _, condition := range source.Status.Conditions { + if condition.Type == sourcev1.ReadyCondition { + if condition.Status != corev1.ConditionFalse { + logger.Successf("%s last fetched revision: %s", source.GetName(), source.Status.Artifact.Revision) + } else { + logger.Failuref("%s %s", source.GetName(), condition.Message) + } + isInitialized = true + break + } + } + if !isInitialized { + logger.Failuref("%s is not ready", source.GetName()) + } + } + return nil +} diff --git a/cmd/tk/reconcile_source_helm.go b/cmd/tk/reconcile_source_helm.go index e5fa96625e038df75a86a1f6a1cffd02f9c5a4bf..efffc261e6b57a52476769fb313d20e87f02c613 100644 --- a/cmd/tk/reconcile_source_helm.go +++ b/cmd/tk/reconcile_source_helm.go @@ -34,7 +34,7 @@ var reconcileSourceHelmCmd = &cobra.Command{ Use: "helm [name]", Short: "Reconcile a HelmRepository source", Long: `The reconcile source command triggers a reconciliation of a HelmRepository resource and waits for it to finish.`, - Example: ` # Trigger a helm repo update for an existing source + Example: ` # Trigger a reconciliation for an existing source tk reconcile source helm podinfo `, RunE: syncSourceHelmCmdRun, diff --git a/cmd/tk/resume_helmrelease.go b/cmd/tk/resume_helmrelease.go index ce588b5e21db15ba997cb278e6f05e15d0f14ef6..a98ac07cc28c2c65a166222018f1dfb7beb5b1c7 100644 --- a/cmd/tk/resume_helmrelease.go +++ b/cmd/tk/resume_helmrelease.go @@ -35,6 +35,9 @@ var resumeHrCmd = &cobra.Command{ Short: "Resume a suspended HelmRelease", Long: `The resume command marks a previously suspended HelmRelease resource for reconciliation and waits for it to finish the apply.`, + Example: ` # Resume reconciliation for an existing Helm release + tk resume hr podinfo +`, RunE: resumeHrCmdRun, } diff --git a/cmd/tk/resume_kustomization.go b/cmd/tk/resume_kustomization.go index a1d708a862d899e0e5169a5d401798e98a0249e8..bac1bf8893d71e6d0f0f56f707069d53bd448fee 100644 --- a/cmd/tk/resume_kustomization.go +++ b/cmd/tk/resume_kustomization.go @@ -35,6 +35,9 @@ var resumeKsCmd = &cobra.Command{ Short: "Resume a suspended Kustomization", Long: `The resume command marks a previously suspended Kustomization resource for reconciliation and waits for it to finish the apply.`, + Example: ` # Resume reconciliation for an existing Kustomization + tk resume ks podinfo +`, RunE: resumeKsCmdRun, } diff --git a/cmd/tk/suspend_helmrelease.go b/cmd/tk/suspend_helmrelease.go index eafeab626fcf55de1f4664493d929e1d7671b97f..c7840ef7ff4fae02bac0d5367df6d5c3390d0c54 100644 --- a/cmd/tk/suspend_helmrelease.go +++ b/cmd/tk/suspend_helmrelease.go @@ -31,7 +31,10 @@ var suspendHrCmd = &cobra.Command{ Aliases: []string{"hr"}, Short: "Suspend reconciliation of HelmRelease", Long: "The suspend command disables the reconciliation of a HelmRelease resource.", - RunE: suspendHrCmdRun, + Example: ` # Suspend reconciliation for an existing Helm release + tk suspend hr podinfo +`, + RunE: suspendHrCmdRun, } func init() { diff --git a/cmd/tk/suspend_kustomization.go b/cmd/tk/suspend_kustomization.go index d879a44e504eb6a5a95ea9dc01f9130c8486d276..0a9593f5eb8e67de1605871d3ee62aab236a19be 100644 --- a/cmd/tk/suspend_kustomization.go +++ b/cmd/tk/suspend_kustomization.go @@ -29,7 +29,10 @@ var suspendKsCmd = &cobra.Command{ Aliases: []string{"ks"}, Short: "Suspend reconciliation of Kustomization", Long: "The suspend command disables the reconciliation of a Kustomization resource.", - RunE: suspendKsCmdRun, + Example: ` # Suspend reconciliation for an existing Kustomization + tk suspend ks podinfo +`, + RunE: suspendKsCmdRun, } func init() { diff --git a/cmd/tk/uninstall.go b/cmd/tk/uninstall.go index 7e145c73ead38370661df0f6a6d13b88b220bc72..a92951198a4c3ec2600340c32fc4e1c956ef5561 100644 --- a/cmd/tk/uninstall.go +++ b/cmd/tk/uninstall.go @@ -30,10 +30,10 @@ var uninstallCmd = &cobra.Command{ Short: "Uninstall the toolkit components", Long: "The uninstall command removes the namespace, cluster roles, cluster role bindings and CRDs from the cluster.", Example: ` # Dry-run uninstall of all components - uninstall --dry-run --namespace=gitops-system + tk uninstall --dry-run --namespace=gitops-system # Uninstall all components and delete custom resource definitions - uninstall --crds --namespace=gitops-system + tk uninstall --crds --namespace=gitops-system `, RunE: uninstallCmdRun, } diff --git a/docs/cmd/tk_bootstrap_github.md b/docs/cmd/tk_bootstrap_github.md index df7c34f4d5b2a1748ee1f7eef73452a311398e99..3aa71ad630d233e693777e4d9e54d942c6605773 100644 --- a/docs/cmd/tk_bootstrap_github.md +++ b/docs/cmd/tk_bootstrap_github.md @@ -21,19 +21,19 @@ tk bootstrap github [flags] export GITHUB_TOKEN=<my-token> # Run bootstrap for a private repo owned by a GitHub organization - bootstrap github --owner=<organization> --repository=<repo name> + tk bootstrap github --owner=<organization> --repository=<repo name> # Run bootstrap for a private repo and assign organization teams to it - bootstrap github --owner=<organization> --repository=<repo name> --team=<team1 slug> --team=<team2 slug> + tk bootstrap github --owner=<organization> --repository=<repo name> --team=<team1 slug> --team=<team2 slug> # Run bootstrap for a repository path - bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster + tk bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster # Run bootstrap for a public repository on a personal account - bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true + tk bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true # Run bootstrap for a private repo hosted on GitHub Enterprise - bootstrap github --owner=<organization> --repository=<repo name> --hostname=<domain> + tk bootstrap github --owner=<organization> --repository=<repo name> --hostname=<domain> ``` diff --git a/docs/cmd/tk_bootstrap_gitlab.md b/docs/cmd/tk_bootstrap_gitlab.md index 5b0cda8b7c57df1680368e88e3e8129f3e1f45be..0502838bca0c00d97dd1d515e6177138aed84b30 100644 --- a/docs/cmd/tk_bootstrap_gitlab.md +++ b/docs/cmd/tk_bootstrap_gitlab.md @@ -21,16 +21,16 @@ tk bootstrap gitlab [flags] export GITLAB_TOKEN=<my-token> # Run bootstrap for a private repo owned by a GitLab group - bootstrap gitlab --owner=<group> --repository=<repo name> + tk bootstrap gitlab --owner=<group> --repository=<repo name> # Run bootstrap for a repository path - bootstrap gitlab --owner=<group> --repository=<repo name> --path=dev-cluster + tk bootstrap gitlab --owner=<group> --repository=<repo name> --path=dev-cluster # Run bootstrap for a public repository on a personal account - bootstrap gitlab --owner=<user> --repository=<repo name> --private=false --personal=true + tk bootstrap gitlab --owner=<user> --repository=<repo name> --private=false --personal=true # Run bootstrap for a private repo hosted on a GitLab server - bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain> + tk bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain> ``` diff --git a/docs/cmd/tk_create_kustomization.md b/docs/cmd/tk_create_kustomization.md index 18464d4621ac5c3369434afbe5e4ec39db551be7..0523a5f4b701b1851600607c4317653588ccdd5d 100644 --- a/docs/cmd/tk_create_kustomization.md +++ b/docs/cmd/tk_create_kustomization.md @@ -14,7 +14,7 @@ tk create kustomization [name] [flags] ``` # Create a Kustomization resource from a source at a given path - create kustomization contour \ + tk create kustomization contour \ --source=contour \ --path="./examples/contour/" \ --prune=true \ @@ -25,7 +25,7 @@ tk create kustomization [name] [flags] --health-check-timeout=3m # Create a Kustomization resource that depends on the previous one - create kustomization webapp \ + tk create kustomization webapp \ --depends-on=contour \ --source=webapp \ --path="./deploy/overlays/dev" \ @@ -34,7 +34,7 @@ tk create kustomization [name] [flags] --validation=client # Create a Kustomization resource that runs under a service account - create kustomization webapp \ + tk create kustomization webapp \ --source=webapp \ --path="./deploy/overlays/staging" \ --prune=true \ diff --git a/docs/cmd/tk_create_source.md b/docs/cmd/tk_create_source.md index 796c3161fbb016be3c17d0db2b90676fb0671423..170694c9bdd5feb72f56930dc86f78181015884e 100644 --- a/docs/cmd/tk_create_source.md +++ b/docs/cmd/tk_create_source.md @@ -27,4 +27,5 @@ The create source sub-commands generate sources. * [tk create](tk_create.md) - Create or update sources and resources * [tk create source git](tk_create_source_git.md) - Create or update a GitRepository source +* [tk create source helm](tk_create_source_helm.md) - Create or update a HelmRepository source diff --git a/docs/cmd/tk_create_source_git.md b/docs/cmd/tk_create_source_git.md index 825ff472b01f203e875a14a4b2784f4d5c106684..d7d55525a4e01692433105946586e123b14bc4aa 100644 --- a/docs/cmd/tk_create_source_git.md +++ b/docs/cmd/tk_create_source_git.md @@ -17,35 +17,35 @@ tk create source git [name] [flags] ``` # Create a source from a public Git repository master branch - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --branch=master # Create a source from a Git repository pinned to specific git tag - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --tag="3.2.3" # Create a source from a public Git repository tag that matches a semver range - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --tag-semver=">=3.2.0 <3.3.0" # Create a source from a Git repository using SSH authentication - create source git podinfo \ + tk create source git podinfo \ --url=ssh://git@github.com/stefanprodan/podinfo \ --branch=master # Create a source from a Git repository using SSH authentication and an # ECDSA P-521 curve public key - create source git podinfo \ + tk create source git podinfo \ --url=ssh://git@github.com/stefanprodan/podinfo \ --branch=master \ --ssh-key-algorithm=ecdsa \ --ssh-ecdsa-curve=p521 # Create a source from a Git repository using basic authentication - create source git podinfo \ + tk create source git podinfo \ --url=https://github.com/stefanprodan/podinfo \ --username=username \ --password=password diff --git a/docs/cmd/tk_create_source_helm.md b/docs/cmd/tk_create_source_helm.md new file mode 100644 index 0000000000000000000000000000000000000000..3c7b361d062228546a509f2f8db2e5dd4c0a7712 --- /dev/null +++ b/docs/cmd/tk_create_source_helm.md @@ -0,0 +1,54 @@ +## tk create source helm + +Create or update a HelmRepository source + +### Synopsis + + +The create source helm command generates a HelmRepository resource and waits for it to fetch the index. +For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret. + +``` +tk create source helm [name] [flags] +``` + +### Examples + +``` + # Create a source from a public Helm repository + tk create source helm podinfo \ + --url=https://stefanprodan.github.io/podinfo \ + --interval=10m + + # Create a source from a Helm repository using basic authentication + tk create source helm podinfo \ + --url=https://stefanprodan.github.io/podinfo \ + --username=username \ + --password=password + +``` + +### Options + +``` + -h, --help help for helm + -p, --password string basic authentication password + --url string Helm repository address + -u, --username string basic authentication username +``` + +### Options inherited from parent commands + +``` + --export export in YAML format to stdout + --interval duration source sync interval (default 1m0s) + --kubeconfig string path to the kubeconfig file (default "~/.kube/config") + --namespace string the namespace scope for this operation (default "gitops-system") + --timeout duration timeout for this operation (default 5m0s) + --verbose print generated objects +``` + +### SEE ALSO + +* [tk create source](tk_create_source.md) - Create or update sources + diff --git a/docs/cmd/tk_delete_kustomization.md b/docs/cmd/tk_delete_kustomization.md index f4ee36744abfaf0e1b4f46dc51821e8a630495ef..12465377ba9478db8810551f7fd3d481d7627e1f 100644 --- a/docs/cmd/tk_delete_kustomization.md +++ b/docs/cmd/tk_delete_kustomization.md @@ -10,6 +10,14 @@ The delete kustomization command deletes the given Kustomization from the cluste tk delete kustomization [name] [flags] ``` +### Examples + +``` + # Delete a kustomization and the Kubernetes resources created by it + tk delete kustomization podinfo + +``` + ### Options ``` diff --git a/docs/cmd/tk_delete_source.md b/docs/cmd/tk_delete_source.md index 1d81169c36907970b9f03cbdbb92244d2ca12fca..10ceb172166b9bbda1a2129145a089c9101fe41b 100644 --- a/docs/cmd/tk_delete_source.md +++ b/docs/cmd/tk_delete_source.md @@ -26,4 +26,5 @@ The delete source sub-commands delete sources. * [tk delete](tk_delete.md) - Delete sources and resources * [tk delete source git](tk_delete_source_git.md) - Delete a GitRepository source +* [tk delete source helm](tk_delete_source_helm.md) - Delete a HelmRepository source diff --git a/docs/cmd/tk_delete_source_git.md b/docs/cmd/tk_delete_source_git.md index b6952af98fdf7a9541b7b393145fc1f4c21ffe18..81447b2f35d7afb2ddce6284487d3c556363a385 100644 --- a/docs/cmd/tk_delete_source_git.md +++ b/docs/cmd/tk_delete_source_git.md @@ -10,6 +10,14 @@ The delete source git command deletes the given GitRepository from the cluster. tk delete source git [name] [flags] ``` +### Examples + +``` + # Delete a Git repository + tk delete source git podinfo + +``` + ### Options ``` diff --git a/docs/cmd/tk_delete_source_helm.md b/docs/cmd/tk_delete_source_helm.md new file mode 100644 index 0000000000000000000000000000000000000000..18daa63f6b5c8d27cfaf9f723c99686afb7c4f66 --- /dev/null +++ b/docs/cmd/tk_delete_source_helm.md @@ -0,0 +1,40 @@ +## tk delete source helm + +Delete a HelmRepository source + +### Synopsis + +The delete source helm command deletes the given HelmRepository from the cluster. + +``` +tk delete source helm [name] [flags] +``` + +### Examples + +``` + # Delete a Helm repository + tk delete source helm podinfo + +``` + +### Options + +``` + -h, --help help for helm +``` + +### Options inherited from parent commands + +``` + --kubeconfig string path to the kubeconfig file (default "~/.kube/config") + --namespace string the namespace scope for this operation (default "gitops-system") + -s, --silent delete resource without asking for confirmation + --timeout duration timeout for this operation (default 5m0s) + --verbose print generated objects +``` + +### SEE ALSO + +* [tk delete source](tk_delete_source.md) - Delete sources + diff --git a/docs/cmd/tk_export_kustomization.md b/docs/cmd/tk_export_kustomization.md index bf2eaa1861ab1412e0cb118f40bfbdb1cb9c448a..eed9414ba583e8726709fe5c6807addef4578820 100644 --- a/docs/cmd/tk_export_kustomization.md +++ b/docs/cmd/tk_export_kustomization.md @@ -14,10 +14,10 @@ tk export kustomization [name] [flags] ``` # Export all Kustomization resources - export kustomization --all > kustomizations.yaml + tk export kustomization --all > kustomizations.yaml # Export a Kustomization - export kustomization my-app > kustomization.yaml + tk export kustomization my-app > kustomization.yaml ``` diff --git a/docs/cmd/tk_export_source.md b/docs/cmd/tk_export_source.md index a40675168ffa973f0fe8e267f9f9e900a1e452d5..06aa18d576720737695e234eb9765c8e573c19ff 100644 --- a/docs/cmd/tk_export_source.md +++ b/docs/cmd/tk_export_source.md @@ -27,4 +27,5 @@ The export source sub-commands export sources in YAML format. * [tk export](tk_export.md) - Export resources in YAML format * [tk export source git](tk_export_source_git.md) - Export GitRepository sources in YAML format +* [tk export source helm](tk_export_source_helm.md) - Export HelmRepository sources in YAML format diff --git a/docs/cmd/tk_export_source_git.md b/docs/cmd/tk_export_source_git.md index 0f35ae2159cb3b1b91f7c0b84b7dc91a3b0cf4fc..cba6b379d1c32ab20deffefc16eabb04ddf7bd5a 100644 --- a/docs/cmd/tk_export_source_git.md +++ b/docs/cmd/tk_export_source_git.md @@ -14,10 +14,10 @@ tk export source git [name] [flags] ``` # Export all GitRepository sources - export source git --all > sources.yaml + tk export source git --all > sources.yaml # Export a GitRepository source including the SSH key pair or basic auth credentials - export source git my-private-repo --with-credentials > source.yaml + tk export source git my-private-repo --with-credentials > source.yaml ``` diff --git a/docs/cmd/tk_export_source_helm.md b/docs/cmd/tk_export_source_helm.md new file mode 100644 index 0000000000000000000000000000000000000000..1561ecf9dfe0df2d1b9c250b211f768ccab5bd1c --- /dev/null +++ b/docs/cmd/tk_export_source_helm.md @@ -0,0 +1,44 @@ +## tk export source helm + +Export HelmRepository sources in YAML format + +### Synopsis + +The export source git command exports on or all HelmRepository sources in YAML format. + +``` +tk export source helm [name] [flags] +``` + +### Examples + +``` + # Export all HelmRepository sources + tk export source helm --all > sources.yaml + + # Export a HelmRepository source including the basic auth credentials + tk export source helm my-private-repo --with-credentials > source.yaml + +``` + +### Options + +``` + -h, --help help for helm +``` + +### Options inherited from parent commands + +``` + --all select all resources + --kubeconfig string path to the kubeconfig file (default "~/.kube/config") + --namespace string the namespace scope for this operation (default "gitops-system") + --timeout duration timeout for this operation (default 5m0s) + --verbose print generated objects + --with-credentials include credential secrets +``` + +### SEE ALSO + +* [tk export source](tk_export_source.md) - Export sources + diff --git a/docs/cmd/tk_get.md b/docs/cmd/tk_get.md index 49f4a28064e20af63336c66ae095fc225fd714c3..fa42a9f4b49c1fc38e4248336b439ef973a159f1 100644 --- a/docs/cmd/tk_get.md +++ b/docs/cmd/tk_get.md @@ -24,6 +24,6 @@ The get sub-commands print the statuses of sources and resources. ### SEE ALSO * [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines -* [tk get kustomizations](tk_get_kustomizations.md) - Get Kustomization source statuses +* [tk get kustomizations](tk_get_kustomizations.md) - Get Kustomization statuses * [tk get sources](tk_get_sources.md) - Get source statuses diff --git a/docs/cmd/tk_get_kustomizations.md b/docs/cmd/tk_get_kustomizations.md index 90ad1d4ffa032d07a3cfe28b4c4ef639320f1586..b82d5234a5bbfd97f4d9d3cd2f58a3797c5db749 100644 --- a/docs/cmd/tk_get_kustomizations.md +++ b/docs/cmd/tk_get_kustomizations.md @@ -1,6 +1,6 @@ ## tk get kustomizations -Get Kustomization source statuses +Get Kustomization statuses ### Synopsis @@ -10,6 +10,14 @@ The get kustomizations command prints the statuses of the resources. tk get kustomizations [flags] ``` +### Examples + +``` + # List all kustomizations and their status + tk get kustomizations + +``` + ### Options ``` diff --git a/docs/cmd/tk_get_sources.md b/docs/cmd/tk_get_sources.md index cea416e2bb934c11ca74af114df0bf1659c1ae72..0d867e4a0df8cc7c2f088248369d23cd19d00a3d 100644 --- a/docs/cmd/tk_get_sources.md +++ b/docs/cmd/tk_get_sources.md @@ -25,4 +25,5 @@ The get source sub-commands print the statuses of the sources. * [tk get](tk_get.md) - Get sources and resources * [tk get sources git](tk_get_sources_git.md) - Get GitRepository source statuses +* [tk get sources helm](tk_get_sources_helm.md) - Get HelmRepository source statuses diff --git a/docs/cmd/tk_get_sources_git.md b/docs/cmd/tk_get_sources_git.md index cc91d54aa1ccfae8d54df04debdf2860adae801c..41e64fc03317620846550480322d2d264ae86079 100644 --- a/docs/cmd/tk_get_sources_git.md +++ b/docs/cmd/tk_get_sources_git.md @@ -10,6 +10,14 @@ The get sources git command prints the status of the GitRepository sources. tk get sources git [flags] ``` +### Examples + +``` + # List all Git repositories and their status + tk get sources git + +``` + ### Options ``` diff --git a/docs/cmd/tk_get_sources_helm.md b/docs/cmd/tk_get_sources_helm.md new file mode 100644 index 0000000000000000000000000000000000000000..198f3c7b860494ecc6f091562091758f1d5bfd19 --- /dev/null +++ b/docs/cmd/tk_get_sources_helm.md @@ -0,0 +1,39 @@ +## tk get sources helm + +Get HelmRepository source statuses + +### Synopsis + +The get sources helm command prints the status of the HelmRepository sources. + +``` +tk get sources helm [flags] +``` + +### Examples + +``` + # List all Helm repositories and their status + tk get sources helm + +``` + +### Options + +``` + -h, --help help for helm +``` + +### Options inherited from parent commands + +``` + --kubeconfig string path to the kubeconfig file (default "~/.kube/config") + --namespace string the namespace scope for this operation (default "gitops-system") + --timeout duration timeout for this operation (default 5m0s) + --verbose print generated objects +``` + +### SEE ALSO + +* [tk get sources](tk_get_sources.md) - Get source statuses + diff --git a/docs/cmd/tk_reconcile_source_helm.md b/docs/cmd/tk_reconcile_source_helm.md index 3f884990559aa8a8b55fecd8097d5713bb6e8ae3..b5ba734c559703d2511775cdbba4c9856e4d6ffa 100644 --- a/docs/cmd/tk_reconcile_source_helm.md +++ b/docs/cmd/tk_reconcile_source_helm.md @@ -13,7 +13,7 @@ tk reconcile source helm [name] [flags] ### Examples ``` - # Trigger a helm repo update for an existing source + # Trigger a reconciliation for an existing source tk reconcile source helm podinfo ``` diff --git a/docs/cmd/tk_resume_helmrelease.md b/docs/cmd/tk_resume_helmrelease.md index 7d5269846bd6c95e10d1cbf98dcb8c96a0037ec5..d365961bcb9f57a5726a88cfc0dbb7d49169a15b 100644 --- a/docs/cmd/tk_resume_helmrelease.md +++ b/docs/cmd/tk_resume_helmrelease.md @@ -11,6 +11,14 @@ finish the apply. tk resume helmrelease [name] [flags] ``` +### Examples + +``` + # Resume reconciliation for an existing Helm release + tk resume hr podinfo + +``` + ### Options ``` diff --git a/docs/cmd/tk_resume_kustomization.md b/docs/cmd/tk_resume_kustomization.md index 8f2d3a555a70d10ec02274c31c326fddcc88723d..5f16f38798923d68e6f31f41228a4d7f93e8a727 100644 --- a/docs/cmd/tk_resume_kustomization.md +++ b/docs/cmd/tk_resume_kustomization.md @@ -11,6 +11,14 @@ finish the apply. tk resume kustomization [name] [flags] ``` +### Examples + +``` + # Resume reconciliation for an existing Kustomization + tk resume ks podinfo + +``` + ### Options ``` diff --git a/docs/cmd/tk_suspend_helmrelease.md b/docs/cmd/tk_suspend_helmrelease.md index 45a2f11aade6a76f6b5f61196397c44ffbf08f2e..65029bcc330e0b107e618536b6d976e9e841a0bb 100644 --- a/docs/cmd/tk_suspend_helmrelease.md +++ b/docs/cmd/tk_suspend_helmrelease.md @@ -10,6 +10,14 @@ The suspend command disables the reconciliation of a HelmRelease resource. tk suspend helmrelease [name] [flags] ``` +### Examples + +``` + # Suspend reconciliation for an existing Helm release + tk suspend hr podinfo + +``` + ### Options ``` diff --git a/docs/cmd/tk_suspend_kustomization.md b/docs/cmd/tk_suspend_kustomization.md index 4906678e264783f82575c9a372600d103d776595..0df77d106b38f4bb5d04b0e11da4a30885ddfd13 100644 --- a/docs/cmd/tk_suspend_kustomization.md +++ b/docs/cmd/tk_suspend_kustomization.md @@ -10,6 +10,14 @@ The suspend command disables the reconciliation of a Kustomization resource. tk suspend kustomization [name] [flags] ``` +### Examples + +``` + # Suspend reconciliation for an existing Kustomization + tk suspend ks podinfo + +``` + ### Options ``` diff --git a/docs/cmd/tk_uninstall.md b/docs/cmd/tk_uninstall.md index a98581f5d3999e70dd4c22e722e1c969d8de2873..c264377401e198d51a8c3b4fd33dab535864cf9b 100644 --- a/docs/cmd/tk_uninstall.md +++ b/docs/cmd/tk_uninstall.md @@ -14,10 +14,10 @@ tk uninstall [flags] ``` # Dry-run uninstall of all components - uninstall --dry-run --namespace=gitops-system + tk uninstall --dry-run --namespace=gitops-system # Uninstall all components and delete custom resource definitions - uninstall --crds --namespace=gitops-system + tk uninstall --crds --namespace=gitops-system ``` diff --git a/docs/get-started/index.md b/docs/get-started/index.md index 06a7edea653b8bd803a66e480096d54bb0799c26..8ace250dc309dee991e7cb5e6bd9646fa8964428 100644 --- a/docs/get-started/index.md +++ b/docs/get-started/index.md @@ -227,7 +227,7 @@ If you delete a kustomization from the `fleet-infra` repo, the reconciler will r were previously applied from that kustomization. If you alter the webapp deployment using `kubectl edit`, the changes will be reverted to match -the state described in git. When dealing with an incident, you can pause the recitation of a +the state described in git. When dealing with an incident, you can pause the reconciliation of a kustomization with `tk suspend kustomization <name>`. Once the debugging session is over, you can re-enable the reconciliation with `tk resume kustomization <name>`. diff --git a/mkdocs.yml b/mkdocs.yml index 299b039409f64098523c21d6fbff79fa3a21a69d..dbee6ccee925429bce6a3460b7327aa137c35c4a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -75,18 +75,22 @@ nav: - Create kustomization: cmd/tk_create_kustomization.md - Create source: cmd/tk_create_source.md - Create source git: cmd/tk_create_source_git.md + - Create source helm: cmd/tk_create_source_helm.md - Delete: cmd/tk_delete.md - Delete kustomization: cmd/tk_delete_kustomization.md - Delete source: cmd/tk_delete_source.md - Delete source git: cmd/tk_delete_source_git.md + - Delete source helm: cmd/tk_delete_source_helm.md - Export: cmd/tk_export.md - Export kustomization: cmd/tk_export_kustomization.md - Export source: cmd/tk_export_source.md - Export source git: cmd/tk_export_source_git.md + - Export source helm: cmd/tk_export_source_helm.md - Get: cmd/tk_get.md - Get kustomizations: cmd/tk_get_kustomizations.md - Get sources: cmd/tk_get_sources.md - Get sources git: cmd/tk_get_sources_git.md + - Get sources helm: cmd/tk_get_sources_helm.md - Install: cmd/tk_install.md - Resume: cmd/tk_resume.md - Resume kustomization: cmd/tk_resume_kustomization.md