Compare commits
124 Commits
v0.0.1-bet
...
v0.0.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3abf4a49cd | ||
|
|
38825bf96a | ||
|
|
faa69da28d | ||
|
|
5cf524e2fd | ||
|
|
88802a44e7 | ||
|
|
94498d862d | ||
|
|
9418b24e8f | ||
|
|
b92cbcd7e7 | ||
|
|
9ef2ff92df | ||
|
|
422724bd2d | ||
|
|
6cb7897f25 | ||
|
|
499ba15004 | ||
|
|
b04abe989e | ||
|
|
ea576179f9 | ||
|
|
116d53a978 | ||
|
|
32adbf2ec8 | ||
|
|
c664484fda | ||
|
|
06906eba4c | ||
|
|
d387ebf32d | ||
|
|
f75556f33c | ||
|
|
2cf09e4de6 | ||
|
|
a5a3a9c586 | ||
|
|
746dfbd955 | ||
|
|
a8cbe4b05f | ||
|
|
fe86da0cde | ||
|
|
4c86a2c191 | ||
|
|
8dc5db17ac | ||
|
|
549c3a190e | ||
|
|
7a68c4ccf3 | ||
|
|
bf8831b833 | ||
|
|
394227571f | ||
|
|
bf67577073 | ||
|
|
e180611024 | ||
|
|
43cfc55368 | ||
|
|
c03b7ea15d | ||
|
|
ddfedfb590 | ||
|
|
24418370f1 | ||
|
|
02521b6964 | ||
|
|
16f693148b | ||
|
|
0bf46cb63f | ||
|
|
2e38855396 | ||
|
|
97592a1387 | ||
|
|
c61bf76c80 | ||
|
|
e95b137011 | ||
|
|
ad655183e0 | ||
|
|
789fd34c4a | ||
|
|
87bbbaa475 | ||
|
|
a4ca813cf5 | ||
|
|
e8eef73212 | ||
|
|
512d4a43cb | ||
|
|
b9f7b1d175 | ||
|
|
b7727e2659 | ||
|
|
229d1d8c6e | ||
|
|
c0b18f85aa | ||
|
|
b11b9588f8 | ||
|
|
633d028841 | ||
|
|
a744b304a0 | ||
|
|
e594350307 | ||
|
|
ecf7a1eac1 | ||
|
|
4621afcb31 | ||
|
|
006c949941 | ||
|
|
72e06ab337 | ||
|
|
f4b2a32a23 | ||
|
|
329e21fd78 | ||
|
|
5499d15402 | ||
|
|
d7f8a05612 | ||
|
|
1f99a75049 | ||
|
|
21fd436621 | ||
|
|
ebcbe98684 | ||
|
|
0e437c1105 | ||
|
|
4b18f56f00 | ||
|
|
fd7ab0a7fd | ||
|
|
c3c84d0ea0 | ||
|
|
43b00c5696 | ||
|
|
a9f4536de4 | ||
|
|
892230280c | ||
|
|
0969a0c42a | ||
|
|
185143ecf6 | ||
|
|
6e06f94a91 | ||
|
|
9af0bc31c3 | ||
|
|
6bcbb13bfb | ||
|
|
9a6d48d038 | ||
|
|
0e81f6c3af | ||
|
|
353a2dd92b | ||
|
|
ee749236e1 | ||
|
|
cf45401250 | ||
|
|
15429160c7 | ||
|
|
3ea7f31797 | ||
|
|
dbfa2f9944 | ||
|
|
98cf176c81 | ||
|
|
39b00797d6 | ||
|
|
1df5a36f84 | ||
|
|
1db3bb3d33 | ||
|
|
807848b6bb | ||
|
|
917598acf8 | ||
|
|
b8bddf6a39 | ||
|
|
da95b7559d | ||
|
|
041b475f49 | ||
|
|
c0a8604f90 | ||
|
|
ce80bd521a | ||
|
|
e92615b3a8 | ||
|
|
3d7349ee53 | ||
|
|
0935a637f9 | ||
|
|
c23d40ca71 | ||
|
|
9ffe908c66 | ||
|
|
45003436bf | ||
|
|
5074ff2889 | ||
|
|
c1d7582461 | ||
|
|
186c7d5786 | ||
|
|
7a87d353cb | ||
|
|
badd2a102f | ||
|
|
d0a79c2b4c | ||
|
|
bd781bbcfb | ||
|
|
f3d50e158a | ||
|
|
34ada4113f | ||
|
|
4f43b504f4 | ||
|
|
62e4b03342 | ||
|
|
dca7b0ba91 | ||
|
|
2a61befbfd | ||
|
|
287be26190 | ||
|
|
4992e11383 | ||
|
|
727734850e | ||
|
|
e042d25062 | ||
|
|
ba7a11d0e5 |
44
.github/workflows/docs.yaml
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
name: Publish docs via GitHub Pages
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- docs*
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Deploy docs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout master
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Copy assets
|
||||||
|
run: |
|
||||||
|
# source-controller CRDs
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/source-controller/master/docs/api/source.md > docs/components/source/api.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/source-controller/master/docs/spec/v1alpha1/gitrepositories.md > docs/components/source/gitrepositories.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/source-controller/master/docs/spec/v1alpha1/helmrepositories.md > docs/components/source/helmrepositories.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/source-controller/master/docs/spec/v1alpha1/helmcharts.md > docs/components/source/helmcharts.md
|
||||||
|
|
||||||
|
# kustomize-controller CRDs
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/kustomize-controller/master/docs/api/kustomize.md > docs/components/kustomize/api.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/kustomize-controller/master/docs/spec/v1alpha1/kustomization.md > docs/components/kustomize/kustomization.md
|
||||||
|
|
||||||
|
# helm-controller CRDs
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/helm-controller/master/docs/api/helmrelease.md > docs/components/helm/api.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/helm-controller/master/docs/spec/v2alpha1/helmreleases.md > docs/components/helm/helmreleases.md
|
||||||
|
|
||||||
|
# notification-controller CRDs
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/notification-controller/master/docs/api/notification.md > docs/components/notification/api.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/notification-controller/master/docs/spec/v1alpha1/event.md > docs/components/notification/event.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/notification-controller/master/docs/spec/v1alpha1/alert.md > docs/components/notification/alert.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/notification-controller/master/docs/spec/v1alpha1/provider.md > docs/components/notification/provider.md
|
||||||
|
curl https://raw.githubusercontent.com/fluxcd/notification-controller/master/docs/spec/v1alpha1/receiver.md > docs/components/notification/receiver.md
|
||||||
|
|
||||||
|
# install script
|
||||||
|
cp install/tk.sh docs/install.sh
|
||||||
|
- name: Deploy docs
|
||||||
|
uses: mhausenblas/mkdocs-deploy-gh-pages@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
CUSTOM_DOMAIN: toolkit.fluxcd.io
|
||||||
5
.github/workflows/e2e.yaml
vendored
@@ -30,6 +30,7 @@ jobs:
|
|||||||
- name: Check if working tree is dirty
|
- name: Check if working tree is dirty
|
||||||
run: |
|
run: |
|
||||||
if [[ $(git diff --stat) != '' ]]; then
|
if [[ $(git diff --stat) != '' ]]; then
|
||||||
|
git diff
|
||||||
echo 'run make test and commit changes'
|
echo 'run make test and commit changes'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -40,7 +41,7 @@ jobs:
|
|||||||
./bin/tk check --pre
|
./bin/tk check --pre
|
||||||
- name: tk install --version
|
- name: tk install --version
|
||||||
run: |
|
run: |
|
||||||
./bin/tk install --version=master --namespace=test --verbose
|
./bin/tk install --version=master --namespace=test --verbose --components="source-controller,kustomize-controller"
|
||||||
- name: tk uninstall
|
- name: tk uninstall
|
||||||
run: |
|
run: |
|
||||||
./bin/tk uninstall --namespace=test --crds --silent
|
./bin/tk uninstall --namespace=test --crds --silent
|
||||||
@@ -68,7 +69,7 @@ jobs:
|
|||||||
--health-check-timeout=3m
|
--health-check-timeout=3m
|
||||||
- name: tk sync kustomization --with-source
|
- name: tk sync kustomization --with-source
|
||||||
run: |
|
run: |
|
||||||
./bin/tk sync kustomization podinfo --with-source
|
./bin/tk reconcile kustomization podinfo --with-source
|
||||||
- name: tk get kustomizations
|
- name: tk get kustomizations
|
||||||
run: |
|
run: |
|
||||||
./bin/tk get kustomizations
|
./bin/tk get kustomizations
|
||||||
|
|||||||
54
.github/workflows/release.yaml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
- name: Unshallow
|
- name: Unshallow
|
||||||
run: git fetch --prune --unshallow
|
run: git fetch --prune --unshallow
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2-beta
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.14.x
|
go-version: 1.14.x
|
||||||
- name: Download release notes utility
|
- name: Download release notes utility
|
||||||
@@ -25,10 +25,60 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo 'CHANGELOG' > /tmp/release.txt
|
echo 'CHANGELOG' > /tmp/release.txt
|
||||||
github-release-notes -org fluxcd -repo toolkit -since-latest-release >> /tmp/release.txt
|
github-release-notes -org fluxcd -repo toolkit -since-latest-release >> /tmp/release.txt
|
||||||
|
- name: Setup Kustomize
|
||||||
|
uses: ./.github/actions/kustomize
|
||||||
|
- name: Generate manifests tarball
|
||||||
|
run: |
|
||||||
|
mkdir -p ./output
|
||||||
|
files=""
|
||||||
|
|
||||||
|
# build controllers
|
||||||
|
for controller in ./manifests/bases/*/; do
|
||||||
|
output_path="./output/$(basename $controller).yaml"
|
||||||
|
echo "building $controller to $output_path"
|
||||||
|
|
||||||
|
kustomize build $controller > $output_path
|
||||||
|
files+=" $(basename $output_path)"
|
||||||
|
done
|
||||||
|
|
||||||
|
# build rbac
|
||||||
|
rbac_path="./manifests/rbac"
|
||||||
|
rbac_output_path="./output/rbac.yaml"
|
||||||
|
echo "building $rbac_path to $rbac_output_path"
|
||||||
|
kustomize build $rbac_path > $rbac_output_path
|
||||||
|
files+=" $(basename $rbac_output_path)"
|
||||||
|
|
||||||
|
# build policies
|
||||||
|
policies_path="./manifests/policies"
|
||||||
|
policies_output_path="./output/policies.yaml"
|
||||||
|
echo "building $policies_path to $policies_output_path"
|
||||||
|
kustomize build $policies_path > $policies_output_path
|
||||||
|
files+=" $(basename $policies_output_path)"
|
||||||
|
|
||||||
|
# create tarball
|
||||||
|
cd ./output && tar -cvzf manifests.tar.gz $files
|
||||||
|
- name: Create release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@latest
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: ${{ github.ref }}
|
||||||
|
- name: Upload artifacts
|
||||||
|
id: upload-release-asset
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./output/manifests.tar.gz
|
||||||
|
asset_name: manifests.tar.gz
|
||||||
|
asset_content_type: application/gzip
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v1
|
uses: goreleaser/goreleaser-action@v1
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --release-notes=/tmp/release.txt
|
args: release --release-notes=/tmp/release.txt --skip-validate
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
3
.gitignore
vendored
@@ -13,4 +13,5 @@
|
|||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
bin/
|
bin/
|
||||||
|
output/
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
FluxCD toolkit is [Apache 2.0 licensed](LICENSE) and accepts contributions
|
The GitOps Toolkit is [Apache 2.0 licensed](https://github.com/fluxcd/toolkit/blob/master/LICENSE)
|
||||||
via GitHub pull requests. This document outlines some of the conventions on
|
and accepts contributions via GitHub pull requests. This document outlines
|
||||||
to make it easier to get your contribution accepted.
|
some of the conventions on to make it easier to get your contribution accepted.
|
||||||
|
|
||||||
We gratefully welcome improvements to issues and documentation as well as to
|
We gratefully welcome improvements to issues and documentation as well as to
|
||||||
code.
|
code.
|
||||||
@@ -14,13 +14,13 @@ Origin (DCO). This document was created by the Linux Kernel community and is a
|
|||||||
simple statement that you, as a contributor, have the legal right to make the
|
simple statement that you, as a contributor, have the legal right to make the
|
||||||
contribution. No action from you is required, but it's a good idea to see the
|
contribution. No action from you is required, but it's a good idea to see the
|
||||||
[DCO](DCO) file for details before you start contributing code to FluxCD
|
[DCO](DCO) file for details before you start contributing code to FluxCD
|
||||||
toolkit.
|
organization.
|
||||||
|
|
||||||
## Communications
|
## Communications
|
||||||
|
|
||||||
The project uses Slack: To join the conversation, simply join the
|
The project uses Slack: To join the conversation, simply join the
|
||||||
[CNCF](https://slack.cncf.io/) Slack workspace and use the
|
[CNCF](https://slack.cncf.io/) Slack workspace and use the
|
||||||
[#flux](https://cloud-native.slack.com/messages/flux/) channel.
|
[#flux-dev](https://cloud-native.slack.com/messages/flux-dev/) channel.
|
||||||
|
|
||||||
The developers use a mailing list to discuss development as well.
|
The developers use a mailing list to discuss development as well.
|
||||||
Simply subscribe to [flux-dev on cncf.io](https://lists.cncf.io/g/cncf-flux-dev)
|
Simply subscribe to [flux-dev on cncf.io](https://lists.cncf.io/g/cncf-flux-dev)
|
||||||
@@ -57,7 +57,7 @@ get asked to resubmit the PR or divide the changes into more than one PR.
|
|||||||
|
|
||||||
### Format of the Commit Message
|
### Format of the Commit Message
|
||||||
|
|
||||||
For Source Controller we prefer the following rules for good commit messages:
|
For the GitOps Toolkit controllers we prefer the following rules for good commit messages:
|
||||||
|
|
||||||
- Limit the subject to 50 characters and write as the continuation
|
- Limit the subject to 50 characters and write as the continuation
|
||||||
of the sentence "If applied, this commit will ..."
|
of the sentence "If applied, this commit will ..."
|
||||||
@@ -66,3 +66,16 @@ For Source Controller we prefer the following rules for good commit messages:
|
|||||||
|
|
||||||
The [following article](https://chris.beams.io/posts/git-commit/#seven-rules)
|
The [following article](https://chris.beams.io/posts/git-commit/#seven-rules)
|
||||||
has some more helpful advice on documenting your work.
|
has some more helpful advice on documenting your work.
|
||||||
|
|
||||||
|
## Understanding the GitOps Toolkit
|
||||||
|
|
||||||
|
If you are entirely new to the GitOps Toolkit,
|
||||||
|
you might want to take a look at the [introductory talk and demo](https://www.youtube.com/watch?v=qQBtSkgl7tI).
|
||||||
|
|
||||||
|
This project is composed of:
|
||||||
|
|
||||||
|
- [/f/toolkit](https://github.com/fluxcd/toolkit): The GitOps Toolkit CLI
|
||||||
|
- [/f/source-manager](https://github.com/fluxcd/source-controller): Kubernetes operator for managing sources
|
||||||
|
- [/f/kustomize-controller](https://github.com/fluxcd/kustomize-controller): Kubernetes operator for building GitOps pipelines with Kustomize
|
||||||
|
- [/f/helm-controller](https://github.com/fluxcd/helm-controller): Kubernetes operator for building GitOps pipelines with Helm
|
||||||
|
- [/f/notification-controller](https://github.com/fluxcd/notification-controller): Kubernetes operator for handling inbound and outbound events
|
||||||
|
|||||||
2
Makefile
@@ -11,7 +11,7 @@ fmt:
|
|||||||
vet:
|
vet:
|
||||||
go vet ./...
|
go vet ./...
|
||||||
|
|
||||||
test: tidy fmt vet
|
test: tidy fmt vet docs
|
||||||
go test ./... -coverprofile cover.out
|
go test ./... -coverprofile cover.out
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|||||||
11
README.md
@@ -1,4 +1,4 @@
|
|||||||
# toolkit
|
# GitOps Toolkit
|
||||||
|
|
||||||
[](https://github.com/fluxcd/toolkit/actions)
|
[](https://github.com/fluxcd/toolkit/actions)
|
||||||
[](https://goreportcard.com/report/github.com/fluxcd/toolkit)
|
[](https://goreportcard.com/report/github.com/fluxcd/toolkit)
|
||||||
@@ -7,11 +7,6 @@
|
|||||||
|
|
||||||
Experimental toolkit for assembling CD pipelines the GitOps way.
|
Experimental toolkit for assembling CD pipelines the GitOps way.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Components:
|
To get started with the toolkit please read the [docs](https://toolkit.fluxcd.io/).
|
||||||
* [Toolkit CLI](docs/cmd/tk.md)
|
|
||||||
* [Source Controller](https://github.com/fluxcd/source-controller)
|
|
||||||
* [Kustomize Controller](https://github.com/fluxcd/kustomize-controller)
|
|
||||||
|
|
||||||
To install the toolkit CLI, follow the [instructions](install/README.md).
|
|
||||||
|
|||||||
@@ -1,20 +1,252 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1"
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bootstrapCmd = &cobra.Command{
|
var bootstrapCmd = &cobra.Command{
|
||||||
Use: "bootstrap",
|
Use: "bootstrap",
|
||||||
Short: "Bootstrap commands",
|
Short: "Bootstrap toolkit components",
|
||||||
|
Long: "The bootstrap sub-commands bootstrap the toolkit components on the targeted Git provider.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
bootstrapVersion string
|
bootstrapVersion string
|
||||||
|
bootstrapComponents []string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
bootstrapBranch = "master"
|
||||||
|
bootstrapInstallManifest = "toolkit-components.yaml"
|
||||||
|
bootstrapSourceManifest = "toolkit-source.yaml"
|
||||||
|
bootstrapKustomizationManifest = "toolkit-kustomization.yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapVersion, "version", "master", "toolkit tag or branch")
|
bootstrapCmd.PersistentFlags().StringVarP(&bootstrapVersion, "version", "v", defaultVersion,
|
||||||
|
"toolkit version")
|
||||||
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapComponents, "components", defaultComponents,
|
||||||
|
"list of components, accepts comma-separated values")
|
||||||
|
|
||||||
rootCmd.AddCommand(bootstrapCmd)
|
rootCmd.AddCommand(bootstrapCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generateInstallManifests(targetPath, namespace, tmpDir string) (string, error) {
|
||||||
|
tkDir := path.Join(tmpDir, ".tk")
|
||||||
|
defer os.RemoveAll(tkDir)
|
||||||
|
|
||||||
|
if err := os.MkdirAll(tkDir, os.ModePerm); err != nil {
|
||||||
|
return "", fmt.Errorf("generating manifests failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents, tkDir); err != nil {
|
||||||
|
return "", fmt.Errorf("generating manifests failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
manifestsDir := path.Join(tmpDir, targetPath, namespace)
|
||||||
|
if err := os.MkdirAll(manifestsDir, os.ModePerm); err != nil {
|
||||||
|
return "", fmt.Errorf("generating manifests failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest := path.Join(manifestsDir, bootstrapInstallManifest)
|
||||||
|
if err := buildKustomization(tkDir, manifest); err != nil {
|
||||||
|
return "", fmt.Errorf("build kustomization failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return manifest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func applyInstallManifests(ctx context.Context, manifestPath string, components []string) error {
|
||||||
|
command := fmt.Sprintf("kubectl apply -f %s", manifestPath)
|
||||||
|
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
||||||
|
return fmt.Errorf("install failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, deployment := range components {
|
||||||
|
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
||||||
|
namespace, deployment, timeout.String())
|
||||||
|
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
||||||
|
return fmt.Errorf("install failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateSyncManifests(url, name, namespace, targetPath, tmpDir string, interval time.Duration) error {
|
||||||
|
gvk := sourcev1.GroupVersion.WithKind("GitRepository")
|
||||||
|
gitRepository := sourcev1.GitRepository{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: namespace,
|
||||||
|
},
|
||||||
|
Spec: sourcev1.GitRepositorySpec{
|
||||||
|
URL: url,
|
||||||
|
Interval: metav1.Duration{
|
||||||
|
Duration: interval,
|
||||||
|
},
|
||||||
|
Reference: &sourcev1.GitRepositoryRef{
|
||||||
|
Branch: "master",
|
||||||
|
},
|
||||||
|
SecretRef: &corev1.LocalObjectReference{
|
||||||
|
Name: name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
gitData, err := yaml.Marshal(gitRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := utils.writeFile(string(gitData), filepath.Join(tmpDir, targetPath, namespace, bootstrapSourceManifest)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
gvk = kustomizev1.GroupVersion.WithKind("Kustomization")
|
||||||
|
kustomization := kustomizev1.Kustomization{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: namespace,
|
||||||
|
},
|
||||||
|
Spec: kustomizev1.KustomizationSpec{
|
||||||
|
Interval: metav1.Duration{
|
||||||
|
Duration: 10 * time.Minute,
|
||||||
|
},
|
||||||
|
Path: fmt.Sprintf("./%s", strings.TrimPrefix(targetPath, "./")),
|
||||||
|
Prune: true,
|
||||||
|
SourceRef: kustomizev1.CrossNamespaceObjectReference{
|
||||||
|
Kind: sourcev1.GitRepositoryKind,
|
||||||
|
Name: name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
ksData, err := yaml.Marshal(kustomization)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := utils.writeFile(string(ksData), filepath.Join(tmpDir, targetPath, namespace, bootstrapKustomizationManifest)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func applySyncManifests(ctx context.Context, kubeClient client.Client, name, namespace, targetPath, tmpDir string) error {
|
||||||
|
command := fmt.Sprintf("kubectl apply -f %s", filepath.Join(tmpDir, targetPath, namespace))
|
||||||
|
if _, err := utils.execCommand(ctx, ModeStderrOS, command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for cluster sync")
|
||||||
|
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func shouldInstallManifests(ctx context.Context, kubeClient client.Client, namespace string) bool {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: namespace,
|
||||||
|
}
|
||||||
|
var kustomization kustomizev1.Kustomization
|
||||||
|
if err := kubeClient.Get(ctx, namespacedName, &kustomization); err != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return kustomization.Status.LastAppliedRevision == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func shouldCreateDeployKey(ctx context.Context, kubeClient client.Client, namespace string) bool {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: namespace,
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing corev1.Secret
|
||||||
|
if err := kubeClient.Get(ctx, namespacedName, &existing); err != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateDeployKey(ctx context.Context, kubeClient client.Client, url *url.URL, namespace string) (string, error) {
|
||||||
|
pair, err := generateKeyPair(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
hostKey, err := scanHostKey(ctx, url)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret := corev1.Secret{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: namespace,
|
||||||
|
Namespace: namespace,
|
||||||
|
},
|
||||||
|
StringData: map[string]string{
|
||||||
|
"identity": string(pair.PrivateKey),
|
||||||
|
"identity.pub": string(pair.PublicKey),
|
||||||
|
"known_hosts": string(hostKey),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if err := upsertSecret(ctx, kubeClient, secret); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(pair.PublicKey), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -7,34 +23,19 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"sigs.k8s.io/yaml"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
|
||||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
|
||||||
"github.com/google/go-github/v32/github"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
||||||
|
|
||||||
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1"
|
"github.com/fluxcd/pkg/git"
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var bootstrapGitHubCmd = &cobra.Command{
|
var bootstrapGitHubCmd = &cobra.Command{
|
||||||
Use: "github",
|
Use: "github",
|
||||||
Short: "Bootstrap GitHub repository",
|
Short: "Bootstrap toolkit components in a GitHub repository",
|
||||||
Long: `
|
Long: `The bootstrap github command creates the GitHub repository if it doesn't exists and
|
||||||
The bootstrap command creates the GitHub repository if it doesn't exists and
|
|
||||||
commits the toolkit components manifests to the master branch.
|
commits the toolkit components manifests to the master branch.
|
||||||
Then it configure the target cluster to synchronize with the repository.
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
If the toolkit components are present on the cluster,
|
If the toolkit components are present on the cluster,
|
||||||
the bootstrap command will perform an upgrade if needed.`,
|
the bootstrap command will perform an upgrade if needed.`,
|
||||||
Example: ` # Create a GitHub personal access token and export it as an env var
|
Example: ` # Create a GitHub personal access token and export it as an env var
|
||||||
@@ -43,6 +44,12 @@ the bootstrap command will perform an upgrade if needed.`,
|
|||||||
# Run bootstrap for a private repo owned by a GitHub organization
|
# Run bootstrap for a private repo owned by a GitHub organization
|
||||||
bootstrap github --owner=<organization> --repository=<repo name>
|
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>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster
|
||||||
|
|
||||||
# Run bootstrap for a public repository on a personal account
|
# Run bootstrap for a public repository on a personal account
|
||||||
bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true
|
bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true
|
||||||
|
|
||||||
@@ -59,37 +66,41 @@ var (
|
|||||||
ghPersonal bool
|
ghPersonal bool
|
||||||
ghPrivate bool
|
ghPrivate bool
|
||||||
ghHostname string
|
ghHostname string
|
||||||
|
ghPath string
|
||||||
|
ghTeams []string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ghTokenName = "GITHUB_TOKEN"
|
ghDefaultPermission = "maintain"
|
||||||
ghBranch = "master"
|
|
||||||
ghInstallManifest = "toolkit.yaml"
|
|
||||||
ghSourceManifest = "toolkit-source.yaml"
|
|
||||||
ghKustomizationManifest = "toolkit-kustomization.yaml"
|
|
||||||
ghDefaultHostname = "github.com"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
bootstrapGitHubCmd.Flags().StringVar(&ghOwner, "owner", "", "GitHub user or organization name")
|
bootstrapGitHubCmd.Flags().StringVar(&ghOwner, "owner", "", "GitHub user or organization name")
|
||||||
bootstrapGitHubCmd.Flags().StringVar(&ghRepository, "repository", "", "GitHub repository name")
|
bootstrapGitHubCmd.Flags().StringVar(&ghRepository, "repository", "", "GitHub repository name")
|
||||||
|
bootstrapGitHubCmd.Flags().StringArrayVar(&ghTeams, "team", []string{}, "GitHub team to be given maintainer access")
|
||||||
bootstrapGitHubCmd.Flags().BoolVar(&ghPersonal, "personal", false, "is personal repository")
|
bootstrapGitHubCmd.Flags().BoolVar(&ghPersonal, "personal", false, "is personal repository")
|
||||||
bootstrapGitHubCmd.Flags().BoolVar(&ghPrivate, "private", true, "is private repository")
|
bootstrapGitHubCmd.Flags().BoolVar(&ghPrivate, "private", true, "is private repository")
|
||||||
bootstrapGitHubCmd.Flags().DurationVar(&ghInterval, "interval", time.Minute, "sync interval")
|
bootstrapGitHubCmd.Flags().DurationVar(&ghInterval, "interval", time.Minute, "sync interval")
|
||||||
bootstrapGitHubCmd.Flags().StringVar(&ghHostname, "hostname", ghDefaultHostname, "GitHub hostname")
|
bootstrapGitHubCmd.Flags().StringVar(&ghHostname, "hostname", git.GitHubDefaultHostname, "GitHub hostname")
|
||||||
|
bootstrapGitHubCmd.Flags().StringVar(&ghPath, "path", "", "repository path, when specified the cluster sync will be scoped to this path")
|
||||||
|
|
||||||
bootstrapCmd.AddCommand(bootstrapGitHubCmd)
|
bootstrapCmd.AddCommand(bootstrapGitHubCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
ghToken := os.Getenv(ghTokenName)
|
ghToken := os.Getenv(git.GitHubTokenName)
|
||||||
if ghToken == "" {
|
if ghToken == "" {
|
||||||
return fmt.Errorf("%s environment variable not found", ghTokenName)
|
return fmt.Errorf("%s environment variable not found", git.GitHubTokenName)
|
||||||
}
|
}
|
||||||
|
|
||||||
ghURL := fmt.Sprintf("https://%s/%s/%s", ghHostname, ghOwner, ghRepository)
|
repository, err := git.NewRepository(ghRepository, ghOwner, ghHostname, ghToken, "tk", ghOwner+"@users.noreply.github.com")
|
||||||
sshURL := fmt.Sprintf("ssh://git@%s/%s/%s", ghHostname, ghOwner, ghRepository)
|
if err != nil {
|
||||||
if ghOwner == "" || ghRepository == "" {
|
return err
|
||||||
return fmt.Errorf("owner and repository are required")
|
}
|
||||||
|
|
||||||
|
provider := &git.GithubProvider{
|
||||||
|
IsPrivate: ghPrivate,
|
||||||
|
IsPersonal: ghPersonal,
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeClient, err := utils.kubeClient(kubeconfig)
|
kubeClient, err := utils.kubeClient(kubeconfig)
|
||||||
@@ -107,428 +118,123 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// create GitHub repository if doesn't exists
|
// create GitHub repository if doesn't exists
|
||||||
logAction("connecting to %s", ghHostname)
|
logger.Actionf("connecting to %s", ghHostname)
|
||||||
if err := createGitHubRepository(ctx, ghHostname, ghOwner, ghRepository, ghToken, ghPrivate, ghPersonal); err != nil {
|
changed, err := provider.CreateRepository(ctx, repository)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// clone repository and checkout the master branch
|
|
||||||
repo, err := checkoutGitHubRepository(ctx, ghURL, ghBranch, ghToken, tmpDir)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("repository cloned")
|
if changed {
|
||||||
|
logger.Successf("repository created")
|
||||||
|
}
|
||||||
|
|
||||||
|
withErrors := false
|
||||||
|
// add teams to org repository
|
||||||
|
if !ghPersonal {
|
||||||
|
for _, team := range ghTeams {
|
||||||
|
if changed, err := provider.AddTeam(ctx, repository, team, ghDefaultPermission); err != nil {
|
||||||
|
logger.Failuref(err.Error())
|
||||||
|
withErrors = true
|
||||||
|
} else if changed {
|
||||||
|
logger.Successf("%s team access granted", team)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// clone repository and checkout the master branch
|
||||||
|
if err := repository.Checkout(ctx, bootstrapBranch, tmpDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("repository cloned")
|
||||||
|
|
||||||
// generate install manifests
|
// generate install manifests
|
||||||
logGenerate("generating manifests")
|
logger.Generatef("generating manifests")
|
||||||
manifest, err := generateGitHubInstall(namespace, tmpDir)
|
manifest, err := generateInstallManifests(ghPath, namespace, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// stage install manifests
|
// stage install manifests
|
||||||
changed, err := commitGitHubManifests(repo, namespace)
|
changed, err = repository.Commit(ctx, path.Join(ghPath, namespace), "Add manifests")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// push install manifests
|
// push install manifests
|
||||||
if changed {
|
if changed {
|
||||||
if err := pushGitHubRepository(ctx, repo, ghToken); err != nil {
|
if err := repository.Push(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("components manifests pushed")
|
logger.Successf("components manifests pushed")
|
||||||
} else {
|
} else {
|
||||||
logSuccess("components are up to date")
|
logger.Successf("components are up to date")
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine if repo synchronization is working
|
// determine if repo synchronization is working
|
||||||
isInstall := shouldInstallGitHub(ctx, kubeClient, namespace)
|
isInstall := shouldInstallManifests(ctx, kubeClient, namespace)
|
||||||
|
|
||||||
if isInstall {
|
if isInstall {
|
||||||
// apply install manifests
|
// apply install manifests
|
||||||
logAction("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
command := fmt.Sprintf("kubectl apply -f %s", manifest)
|
if err := applyInstallManifests(ctx, manifest, bootstrapComponents); err != nil {
|
||||||
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
return err
|
||||||
return fmt.Errorf("install failed")
|
|
||||||
}
|
|
||||||
logSuccess("install completed")
|
|
||||||
|
|
||||||
// check installation
|
|
||||||
logWaiting("verifying installation")
|
|
||||||
for _, deployment := range components {
|
|
||||||
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
|
||||||
namespace, deployment, timeout.String())
|
|
||||||
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
|
||||||
return fmt.Errorf("install failed")
|
|
||||||
} else {
|
|
||||||
logSuccess("%s ready", deployment)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
logger.Successf("install completed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup SSH deploy key
|
// setup SSH deploy key
|
||||||
if shouldCreateGitHubDeployKey(ctx, kubeClient, namespace) {
|
if shouldCreateDeployKey(ctx, kubeClient, namespace) {
|
||||||
logAction("configuring deploy key")
|
logger.Actionf("configuring deploy key")
|
||||||
u, err := url.Parse(sshURL)
|
u, err := url.Parse(repository.GetSSH())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("git URL parse failed: %w", err)
|
return fmt.Errorf("git URL parse failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
key, err := generateGitHubDeployKey(ctx, kubeClient, u, namespace)
|
key, err := generateDeployKey(ctx, kubeClient, u, namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("generating deploy key failed: %w", err)
|
return fmt.Errorf("generating deploy key failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := createGitHubDeployKey(ctx, key, ghHostname, ghOwner, ghRepository, ghToken, ghPersonal); err != nil {
|
keyName := "tk"
|
||||||
return err
|
if ghPath != "" {
|
||||||
|
keyName = fmt.Sprintf("tk-%s", ghPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if changed, err := provider.AddDeployKey(ctx, repository, key, keyName); err != nil {
|
||||||
|
return err
|
||||||
|
} else if changed {
|
||||||
|
logger.Successf("deploy key configured")
|
||||||
}
|
}
|
||||||
logSuccess("deploy key configured")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure repo synchronization
|
// configure repo synchronization
|
||||||
if isInstall {
|
if isInstall {
|
||||||
// generate source and kustomization manifests
|
// generate source and kustomization manifests
|
||||||
logAction("generating sync manifests")
|
logger.Actionf("generating sync manifests")
|
||||||
if err := generateGitHubKustomization(sshURL, namespace, namespace, tmpDir, ghInterval); err != nil {
|
if err := generateSyncManifests(repository.GetSSH(), namespace, namespace, ghPath, tmpDir, ghInterval); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// stage manifests
|
// commit and push manifests
|
||||||
changed, err = commitGitHubManifests(repo, namespace)
|
if changed, err = repository.Commit(ctx, path.Join(ghPath, namespace), "Add manifests"); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
} else if changed {
|
||||||
|
if err := repository.Push(ctx); err != nil {
|
||||||
// push manifests
|
|
||||||
if changed {
|
|
||||||
if err := pushGitHubRepository(ctx, repo, ghToken); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
logger.Successf("sync manifests pushed")
|
||||||
}
|
}
|
||||||
logSuccess("sync manifests pushed")
|
|
||||||
|
|
||||||
// apply manifests and waiting for sync
|
// apply manifests and waiting for sync
|
||||||
logAction("applying sync manifests")
|
logger.Actionf("applying sync manifests")
|
||||||
if err := applyGitHubKustomization(ctx, kubeClient, namespace, namespace, tmpDir); err != nil {
|
if err := applySyncManifests(ctx, kubeClient, namespace, namespace, ghPath, tmpDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("bootstrap finished")
|
if withErrors {
|
||||||
return nil
|
return fmt.Errorf("bootstrap completed with errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeGitHubClient(hostname, token string) (*github.Client, error) {
|
logger.Successf("bootstrap finished")
|
||||||
auth := github.BasicAuthTransport{
|
|
||||||
Username: "git",
|
|
||||||
Password: token,
|
|
||||||
}
|
|
||||||
|
|
||||||
gh := github.NewClient(auth.Client())
|
|
||||||
if hostname != ghDefaultHostname {
|
|
||||||
baseURL := fmt.Sprintf("https://%s/api/v3/", hostname)
|
|
||||||
uploadURL := fmt.Sprintf("https://%s/api/uploads/", hostname)
|
|
||||||
if g, err := github.NewEnterpriseClient(baseURL, uploadURL, auth.Client()); err == nil {
|
|
||||||
gh = g
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("github client error: %w", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return gh, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func createGitHubRepository(ctx context.Context, hostname, owner, name, token string, isPrivate, isPersonal bool) error {
|
|
||||||
gh, err := makeGitHubClient(hostname, token)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
org := ""
|
|
||||||
if !isPersonal {
|
|
||||||
org = owner
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, _, err := gh.Repositories.Get(ctx, org, name); err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
autoInit := true
|
|
||||||
_, _, err = gh.Repositories.Create(ctx, org, &github.Repository{
|
|
||||||
AutoInit: &autoInit,
|
|
||||||
Name: &name,
|
|
||||||
Private: &isPrivate,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
if !strings.Contains(err.Error(), "name already exists on this account") {
|
|
||||||
return fmt.Errorf("github create repository error: %w", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logSuccess("repository created")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkoutGitHubRepository(ctx context.Context, url, branch, token, path string) (*git.Repository, error) {
|
|
||||||
auth := &http.BasicAuth{
|
|
||||||
Username: "git",
|
|
||||||
Password: token,
|
|
||||||
}
|
|
||||||
repo, err := git.PlainCloneContext(ctx, path, false, &git.CloneOptions{
|
|
||||||
URL: url,
|
|
||||||
Auth: auth,
|
|
||||||
RemoteName: git.DefaultRemoteName,
|
|
||||||
ReferenceName: plumbing.NewBranchReferenceName(branch),
|
|
||||||
SingleBranch: true,
|
|
||||||
NoCheckout: false,
|
|
||||||
Progress: nil,
|
|
||||||
Tags: git.NoTags,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("git clone error: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = repo.Head()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("git resolve HEAD error: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return repo, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateGitHubInstall(namespace, tmpDir string) (string, error) {
|
|
||||||
tkDir := path.Join(tmpDir, ".tk")
|
|
||||||
defer os.RemoveAll(tkDir)
|
|
||||||
|
|
||||||
if err := os.MkdirAll(tkDir, os.ModePerm); err != nil {
|
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := genInstallManifests(bootstrapVersion, namespace, components, tkDir); err != nil {
|
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
manifestsDir := path.Join(tmpDir, namespace)
|
|
||||||
if err := os.MkdirAll(manifestsDir, os.ModePerm); err != nil {
|
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
manifest := path.Join(manifestsDir, ghInstallManifest)
|
|
||||||
if err := buildKustomization(tkDir, manifest); err != nil {
|
|
||||||
return "", fmt.Errorf("build kustomization failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return manifest, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func commitGitHubManifests(repo *git.Repository, namespace string) (bool, error) {
|
|
||||||
w, err := repo.Worktree()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = w.Add(namespace)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
status, err := w.Status()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !status.IsClean() {
|
|
||||||
if _, err := w.Commit("Add manifests", &git.CommitOptions{
|
|
||||||
Author: &object.Signature{
|
|
||||||
Name: "tk",
|
|
||||||
Email: "tk@users.noreply.github.com",
|
|
||||||
When: time.Now(),
|
|
||||||
},
|
|
||||||
}); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func pushGitHubRepository(ctx context.Context, repo *git.Repository, token string) error {
|
|
||||||
auth := &http.BasicAuth{
|
|
||||||
Username: "git",
|
|
||||||
Password: token,
|
|
||||||
}
|
|
||||||
err := repo.PushContext(ctx, &git.PushOptions{
|
|
||||||
Auth: auth,
|
|
||||||
Progress: nil,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("git push error: %w", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateGitHubKustomization(url, name, namespace, tmpDir string, interval time.Duration) error {
|
|
||||||
gvk := sourcev1.GroupVersion.WithKind("GitRepository")
|
|
||||||
gitRepository := sourcev1.GitRepository{
|
|
||||||
TypeMeta: metav1.TypeMeta{
|
|
||||||
Kind: gvk.Kind,
|
|
||||||
APIVersion: gvk.GroupVersion().String(),
|
|
||||||
},
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: name,
|
|
||||||
Namespace: namespace,
|
|
||||||
},
|
|
||||||
Spec: sourcev1.GitRepositorySpec{
|
|
||||||
URL: url,
|
|
||||||
Interval: metav1.Duration{
|
|
||||||
Duration: interval,
|
|
||||||
},
|
|
||||||
Reference: &sourcev1.GitRepositoryRef{
|
|
||||||
Branch: "master",
|
|
||||||
},
|
|
||||||
SecretRef: &corev1.LocalObjectReference{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
gitData, err := yaml.Marshal(gitRepository)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.writeFile(string(gitData), filepath.Join(tmpDir, namespace, ghSourceManifest)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
gvk = kustomizev1.GroupVersion.WithKind("Kustomization")
|
|
||||||
emptyAPIGroup := ""
|
|
||||||
kustomization := kustomizev1.Kustomization{
|
|
||||||
TypeMeta: metav1.TypeMeta{
|
|
||||||
Kind: gvk.Kind,
|
|
||||||
APIVersion: gvk.GroupVersion().String(),
|
|
||||||
},
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: name,
|
|
||||||
Namespace: namespace,
|
|
||||||
},
|
|
||||||
Spec: kustomizev1.KustomizationSpec{
|
|
||||||
Interval: metav1.Duration{
|
|
||||||
Duration: 10 * time.Minute,
|
|
||||||
},
|
|
||||||
Path: "./",
|
|
||||||
Prune: true,
|
|
||||||
SourceRef: corev1.TypedLocalObjectReference{
|
|
||||||
APIGroup: &emptyAPIGroup,
|
|
||||||
Kind: "GitRepository",
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
ksData, err := yaml.Marshal(kustomization)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.writeFile(string(ksData), filepath.Join(tmpDir, namespace, ghKustomizationManifest)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func applyGitHubKustomization(ctx context.Context, kubeClient client.Client, name, namespace, tmpDir string) error {
|
|
||||||
command := fmt.Sprintf("kubectl apply -f %s", filepath.Join(tmpDir, namespace))
|
|
||||||
if _, err := utils.execCommand(ctx, ModeStderrOS, command); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
logWaiting("waiting for cluster sync")
|
|
||||||
|
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
|
||||||
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
|
||||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func shouldInstallGitHub(ctx context.Context, kubeClient client.Client, namespace string) bool {
|
|
||||||
namespacedName := types.NamespacedName{
|
|
||||||
Namespace: namespace,
|
|
||||||
Name: namespace,
|
|
||||||
}
|
|
||||||
var kustomization kustomizev1.Kustomization
|
|
||||||
if err := kubeClient.Get(ctx, namespacedName, &kustomization); err != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return kustomization.Status.LastAppliedRevision == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func shouldCreateGitHubDeployKey(ctx context.Context, kubeClient client.Client, namespace string) bool {
|
|
||||||
namespacedName := types.NamespacedName{
|
|
||||||
Namespace: namespace,
|
|
||||||
Name: namespace,
|
|
||||||
}
|
|
||||||
|
|
||||||
var existing corev1.Secret
|
|
||||||
if err := kubeClient.Get(ctx, namespacedName, &existing); err != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateGitHubDeployKey(ctx context.Context, kubeClient client.Client, url *url.URL, namespace string) (string, error) {
|
|
||||||
pair, err := generateKeyPair(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
hostKey, err := scanHostKey(ctx, url)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
secret := corev1.Secret{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: namespace,
|
|
||||||
Namespace: namespace,
|
|
||||||
},
|
|
||||||
StringData: map[string]string{
|
|
||||||
"identity": string(pair.PrivateKey),
|
|
||||||
"identity.pub": string(pair.PublicKey),
|
|
||||||
"known_hosts": string(hostKey),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if err := upsertSecret(ctx, kubeClient, secret); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(pair.PublicKey), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func createGitHubDeployKey(ctx context.Context, key, hostname, owner, name, token string, isPersonal bool) error {
|
|
||||||
gh, err := makeGitHubClient(hostname, token)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
keyName := fmt.Sprintf("tk-%s", namespace)
|
|
||||||
isReadOnly := true
|
|
||||||
_, _, err = gh.Repositories.CreateKey(ctx, owner, name, &github.Key{
|
|
||||||
Title: &keyName,
|
|
||||||
Key: &key,
|
|
||||||
ReadOnly: &isReadOnly,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("github create deploy key error: %w", err)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
214
cmd/tk/bootstrap_gitlab.go
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/git"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapGitLabCmd = &cobra.Command{
|
||||||
|
Use: "gitlab",
|
||||||
|
Short: "Bootstrap toolkit components in a GitLab repository",
|
||||||
|
Long: `The bootstrap gitlab command creates the GitLab repository if it doesn't exists and
|
||||||
|
commits the toolkit components manifests to the master branch.
|
||||||
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
|
If the toolkit components are present on the cluster,
|
||||||
|
the bootstrap command will perform an upgrade if needed.`,
|
||||||
|
Example: ` # Create a GitLab API token and export it as an env var
|
||||||
|
export GITLAB_TOKEN=<my-token>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repo owned by a GitLab group
|
||||||
|
bootstrap gitlab --owner=<group> --repository=<repo name>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
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
|
||||||
|
|
||||||
|
# Run bootstrap for a private repo hosted on a GitLab server
|
||||||
|
bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain>
|
||||||
|
`,
|
||||||
|
RunE: bootstrapGitLabCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
glOwner string
|
||||||
|
glRepository string
|
||||||
|
glInterval time.Duration
|
||||||
|
glPersonal bool
|
||||||
|
glPrivate bool
|
||||||
|
glHostname string
|
||||||
|
glPath string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&glOwner, "owner", "", "GitLab user or group name")
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&glRepository, "repository", "", "GitLab repository name")
|
||||||
|
bootstrapGitLabCmd.Flags().BoolVar(&glPersonal, "personal", false, "is personal repository")
|
||||||
|
bootstrapGitLabCmd.Flags().BoolVar(&glPrivate, "private", true, "is private repository")
|
||||||
|
bootstrapGitLabCmd.Flags().DurationVar(&glInterval, "interval", time.Minute, "sync interval")
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&glHostname, "hostname", git.GitLabDefaultHostname, "GitLab hostname")
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&glPath, "path", "", "repository path, when specified the cluster sync will be scoped to this path")
|
||||||
|
|
||||||
|
bootstrapCmd.AddCommand(bootstrapGitLabCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
glToken := os.Getenv(git.GitLabTokenName)
|
||||||
|
if glToken == "" {
|
||||||
|
return fmt.Errorf("%s environment variable not found", git.GitLabTokenName)
|
||||||
|
}
|
||||||
|
|
||||||
|
repository, err := git.NewRepository(glRepository, glOwner, glHostname, glToken, "tk", glOwner+"@users.noreply.gitlab.com")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
provider := &git.GitLabProvider{
|
||||||
|
IsPrivate: glPrivate,
|
||||||
|
IsPersonal: glPersonal,
|
||||||
|
}
|
||||||
|
|
||||||
|
kubeClient, err := utils.kubeClient(kubeconfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpDir, err := ioutil.TempDir("", namespace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
// create GitLab project if doesn't exists
|
||||||
|
logger.Actionf("connecting to %s", glHostname)
|
||||||
|
changed, err := provider.CreateRepository(ctx, repository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if changed {
|
||||||
|
logger.Successf("repository created")
|
||||||
|
}
|
||||||
|
|
||||||
|
// clone repository and checkout the master branch
|
||||||
|
if err := repository.Checkout(ctx, bootstrapBranch, tmpDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("repository cloned")
|
||||||
|
|
||||||
|
// generate install manifests
|
||||||
|
logger.Generatef("generating manifests")
|
||||||
|
manifest, err := generateInstallManifests(glPath, namespace, tmpDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// stage install manifests
|
||||||
|
changed, err = repository.Commit(ctx, path.Join(glPath, namespace), "Add manifests")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// push install manifests
|
||||||
|
if changed {
|
||||||
|
if err := repository.Push(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("components manifests pushed")
|
||||||
|
} else {
|
||||||
|
logger.Successf("components are up to date")
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine if repo synchronization is working
|
||||||
|
isInstall := shouldInstallManifests(ctx, kubeClient, namespace)
|
||||||
|
|
||||||
|
if isInstall {
|
||||||
|
// apply install manifests
|
||||||
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
|
if err := applyInstallManifests(ctx, manifest, bootstrapComponents); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("install completed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup SSH deploy key
|
||||||
|
if shouldCreateDeployKey(ctx, kubeClient, namespace) {
|
||||||
|
logger.Actionf("configuring deploy key")
|
||||||
|
u, err := url.Parse(repository.GetSSH())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("git URL parse failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
key, err := generateDeployKey(ctx, kubeClient, u, namespace)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("generating deploy key failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
keyName := "tk"
|
||||||
|
if glPath != "" {
|
||||||
|
keyName = fmt.Sprintf("tk-%s", glPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if changed, err := provider.AddDeployKey(ctx, repository, key, keyName); err != nil {
|
||||||
|
return err
|
||||||
|
} else if changed {
|
||||||
|
logger.Successf("deploy key configured")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// configure repo synchronization
|
||||||
|
if isInstall {
|
||||||
|
// generate source and kustomization manifests
|
||||||
|
logger.Actionf("generating sync manifests")
|
||||||
|
if err := generateSyncManifests(repository.GetSSH(), namespace, namespace, glPath, tmpDir, glInterval); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit and push manifests
|
||||||
|
if changed, err = repository.Commit(ctx, path.Join(glPath, namespace), "Add manifests"); err != nil {
|
||||||
|
return err
|
||||||
|
} else if changed {
|
||||||
|
if err := repository.Push(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("sync manifests pushed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply manifests and waiting for sync
|
||||||
|
logger.Actionf("applying sync manifests")
|
||||||
|
if err := applySyncManifests(ctx, kubeClient, namespace, namespace, glPath, tmpDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("bootstrap finished")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -16,26 +32,27 @@ import (
|
|||||||
var checkCmd = &cobra.Command{
|
var checkCmd = &cobra.Command{
|
||||||
Use: "check",
|
Use: "check",
|
||||||
Short: "Check requirements and installation",
|
Short: "Check requirements and installation",
|
||||||
Long: `
|
Long: `The check command will perform a series of checks to validate that
|
||||||
The check command will perform a series of checks to validate that
|
|
||||||
the local environment is configured correctly and if the installed components are healthy.`,
|
the local environment is configured correctly and if the installed components are healthy.`,
|
||||||
Example: ` # Run pre-installation checks
|
Example: ` # Run pre-installation checks
|
||||||
check --pre
|
tk check --pre
|
||||||
|
|
||||||
# Run installation checks
|
# Run installation checks
|
||||||
check
|
tk check
|
||||||
`,
|
`,
|
||||||
RunE: runCheckCmd,
|
RunE: runCheckCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
checkPre bool
|
checkPre bool
|
||||||
|
checkComponents []string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
checkCmd.Flags().BoolVarP(&checkPre, "pre", "", false,
|
checkCmd.Flags().BoolVarP(&checkPre, "pre", "", false,
|
||||||
"only run pre-installation checks")
|
"only run pre-installation checks")
|
||||||
|
checkCmd.Flags().StringSliceVar(&checkComponents, "components", defaultComponents,
|
||||||
|
"list of components, accepts comma-separated values")
|
||||||
rootCmd.AddCommand(checkCmd)
|
rootCmd.AddCommand(checkCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +60,7 @@ func runCheckCmd(cmd *cobra.Command, args []string) error {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
logAction("checking prerequisites")
|
logger.Actionf("checking prerequisites")
|
||||||
checkFailed := false
|
checkFailed := false
|
||||||
|
|
||||||
if !kubectlCheck(ctx, ">=1.18.0") {
|
if !kubectlCheck(ctx, ">=1.18.0") {
|
||||||
@@ -58,83 +75,83 @@ func runCheckCmd(cmd *cobra.Command, args []string) error {
|
|||||||
if checkFailed {
|
if checkFailed {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
logSuccess("prerequisites checks passed")
|
logger.Successf("prerequisites checks passed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("checking controllers")
|
logger.Actionf("checking controllers")
|
||||||
if !componentsCheck() {
|
if !componentsCheck() {
|
||||||
checkFailed = true
|
checkFailed = true
|
||||||
}
|
}
|
||||||
if checkFailed {
|
if checkFailed {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
logSuccess("all checks passed")
|
logger.Successf("all checks passed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func kubectlCheck(ctx context.Context, version string) bool {
|
func kubectlCheck(ctx context.Context, version string) bool {
|
||||||
_, err := exec.LookPath("kubectl")
|
_, err := exec.LookPath("kubectl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubectl not found")
|
logger.Failuref("kubectl not found")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
command := "kubectl version --client --short | awk '{ print $3 }'"
|
command := "kubectl version --client --short | awk '{ print $3 }'"
|
||||||
output, err := utils.execCommand(ctx, ModeCapture, command)
|
output, err := utils.execCommand(ctx, ModeCapture, command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubectl version can't be determined")
|
logger.Failuref("kubectl version can't be determined")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := semver.ParseTolerant(output)
|
v, err := semver.ParseTolerant(output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubectl version can't be parsed")
|
logger.Failuref("kubectl version can't be parsed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
rng, _ := semver.ParseRange(version)
|
rng, _ := semver.ParseRange(version)
|
||||||
if !rng(v) {
|
if !rng(v) {
|
||||||
logFailure("kubectl version must be %s", version)
|
logger.Failuref("kubectl version must be %s", version)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("kubectl %s %s", v.String(), version)
|
logger.Successf("kubectl %s %s", v.String(), version)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func kubernetesCheck(version string) bool {
|
func kubernetesCheck(version string) bool {
|
||||||
cfg, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
|
cfg, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubernetes client initialization failed: %s", err.Error())
|
logger.Failuref("Kubernetes client initialization failed: %s", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := kubernetes.NewForConfig(cfg)
|
client, err := kubernetes.NewForConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubernetes client initialization failed: %s", err.Error())
|
logger.Failuref("Kubernetes client initialization failed: %s", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
ver, err := client.Discovery().ServerVersion()
|
ver, err := client.Discovery().ServerVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubernetes API call failed %s", err.Error())
|
logger.Failuref("Kubernetes API call failed: %s", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := semver.ParseTolerant(ver.String())
|
v, err := semver.ParseTolerant(ver.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFailure("kubernetes version can't be determined")
|
logger.Failuref("Kubernetes version can't be determined")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
rng, _ := semver.ParseRange(version)
|
rng, _ := semver.ParseRange(version)
|
||||||
if !rng(v) {
|
if !rng(v) {
|
||||||
logFailure("kubernetes version must be %s", version)
|
logger.Failuref("Kubernetes version must be %s", version)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("kubernetes %s %s", v.String(), version)
|
logger.Successf("Kubernetes %s %s", v.String(), version)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,14 +160,14 @@ func componentsCheck() bool {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
ok := true
|
ok := true
|
||||||
for _, deployment := range components {
|
for _, deployment := range checkComponents {
|
||||||
command := fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
command := fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
||||||
namespace, deployment, timeout.String())
|
namespace, deployment, timeout.String())
|
||||||
if output, err := utils.execCommand(ctx, ModeCapture, command); err != nil {
|
if output, err := utils.execCommand(ctx, ModeCapture, command); err != nil {
|
||||||
logFailure("%s: %s", deployment, strings.TrimSuffix(output, "\n"))
|
logger.Failuref("%s: %s", deployment, strings.TrimSuffix(output, "\n"))
|
||||||
ok = false
|
ok = false
|
||||||
} else {
|
} else {
|
||||||
logSuccess("%s is healthy", deployment)
|
logger.Successf("%s is healthy", deployment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok
|
return ok
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -8,7 +24,8 @@ import (
|
|||||||
|
|
||||||
var createCmd = &cobra.Command{
|
var createCmd = &cobra.Command{
|
||||||
Use: "create",
|
Use: "create",
|
||||||
Short: "Create commands",
|
Short: "Create or update sources and resources",
|
||||||
|
Long: "The create sub-commands generate sources and resources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -18,6 +35,6 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createCmd.PersistentFlags().DurationVarP(&interval, "interval", "", time.Minute, "source sync interval")
|
createCmd.PersistentFlags().DurationVarP(&interval, "interval", "", time.Minute, "source sync interval")
|
||||||
createCmd.PersistentFlags().BoolVar(&export, "export", false, "export in yaml format to stdout")
|
createCmd.PersistentFlags().BoolVar(&export, "export", false, "export in YAML format to stdout")
|
||||||
rootCmd.AddCommand(createCmd)
|
rootCmd.AddCommand(createCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -21,11 +37,9 @@ import (
|
|||||||
var createKsCmd = &cobra.Command{
|
var createKsCmd = &cobra.Command{
|
||||||
Use: "kustomization [name]",
|
Use: "kustomization [name]",
|
||||||
Aliases: []string{"ks"},
|
Aliases: []string{"ks"},
|
||||||
Short: "Create or update a kustomization resource",
|
Short: "Create or update a Kustomization resource",
|
||||||
Long: `
|
Long: "The kustomization source create command generates a Kustomize resource for a given GitRepository source.",
|
||||||
The kustomization source command generates a kustomization.kustomize.fluxcd.io resource for a given GitRepository source.
|
Example: ` # Create a Kustomization resource from a source at a given path
|
||||||
API spec: https://github.com/fluxcd/kustomize-controller/tree/master/docs/spec/v1alpha1`,
|
|
||||||
Example: ` # Create a kustomization from a source at a given path
|
|
||||||
create kustomization contour \
|
create kustomization contour \
|
||||||
--source=contour \
|
--source=contour \
|
||||||
--path="./examples/contour/" \
|
--path="./examples/contour/" \
|
||||||
@@ -36,7 +50,7 @@ API spec: https://github.com/fluxcd/kustomize-controller/tree/master/docs/spec/v
|
|||||||
--health-check="DaemonSet/envoy.projectcontour" \
|
--health-check="DaemonSet/envoy.projectcontour" \
|
||||||
--health-check-timeout=3m
|
--health-check-timeout=3m
|
||||||
|
|
||||||
# Create a kustomization that depends on the previous one
|
# Create a Kustomization resource that depends on the previous one
|
||||||
create kustomization webapp \
|
create kustomization webapp \
|
||||||
--depends-on=contour \
|
--depends-on=contour \
|
||||||
--source=webapp \
|
--source=webapp \
|
||||||
@@ -45,7 +59,7 @@ API spec: https://github.com/fluxcd/kustomize-controller/tree/master/docs/spec/v
|
|||||||
--interval=5m \
|
--interval=5m \
|
||||||
--validate=client
|
--validate=client
|
||||||
|
|
||||||
# Create a kustomization that runs under a service account
|
# Create a Kustomization resource that runs under a service account
|
||||||
create kustomization webapp \
|
create kustomization webapp \
|
||||||
--source=webapp \
|
--source=webapp \
|
||||||
--path="./deploy/overlays/staging" \
|
--path="./deploy/overlays/staging" \
|
||||||
@@ -72,12 +86,12 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createKsCmd.Flags().StringVar(&ksSource, "source", "", "GitRepository name")
|
createKsCmd.Flags().StringVar(&ksSource, "source", "", "GitRepository name")
|
||||||
createKsCmd.Flags().StringVar(&ksPath, "path", "./", "path to the directory containing the kustomization file")
|
createKsCmd.Flags().StringVar(&ksPath, "path", "./", "path to the directory containing the Kustomization file")
|
||||||
createKsCmd.Flags().BoolVar(&ksPrune, "prune", false, "enable garbage collection")
|
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 '<kind>/<name>.<namespace>'")
|
createKsCmd.Flags().StringArrayVar(&ksHealthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
|
||||||
createKsCmd.Flags().DurationVar(&ksHealthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations")
|
createKsCmd.Flags().DurationVar(&ksHealthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations")
|
||||||
createKsCmd.Flags().StringVar(&ksValidate, "validate", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'")
|
createKsCmd.Flags().StringVar(&ksValidate, "validate", "", "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")
|
createKsCmd.Flags().StringArrayVar(&ksDependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied")
|
||||||
createKsCmd.Flags().StringVar(&ksSAName, "sa-name", "", "service account name")
|
createKsCmd.Flags().StringVar(&ksSAName, "sa-name", "", "service account name")
|
||||||
createKsCmd.Flags().StringVar(&ksSANamespace, "sa-namespace", "", "service account namespace")
|
createKsCmd.Flags().StringVar(&ksSANamespace, "sa-namespace", "", "service account namespace")
|
||||||
createCmd.AddCommand(createKsCmd)
|
createCmd.AddCommand(createKsCmd)
|
||||||
@@ -108,10 +122,9 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !export {
|
if !export {
|
||||||
logGenerate("generating kustomization")
|
logger.Generatef("generating kustomization")
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyAPIGroup := ""
|
|
||||||
kustomization := kustomizev1.Kustomization{
|
kustomization := kustomizev1.Kustomization{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
@@ -124,10 +137,9 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
},
|
},
|
||||||
Path: ksPath,
|
Path: ksPath,
|
||||||
Prune: ksPrune,
|
Prune: ksPrune,
|
||||||
SourceRef: corev1.TypedLocalObjectReference{
|
SourceRef: kustomizev1.CrossNamespaceObjectReference{
|
||||||
APIGroup: &emptyAPIGroup,
|
Kind: sourcev1.GitRepositoryKind,
|
||||||
Kind: "GitRepository",
|
Name: ksSource,
|
||||||
Name: ksSource,
|
|
||||||
},
|
},
|
||||||
Suspend: false,
|
Suspend: false,
|
||||||
Validation: ksValidate,
|
Validation: ksValidate,
|
||||||
@@ -178,18 +190,18 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return exportKs(kustomization)
|
return exportKs(kustomization)
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("applying kustomization")
|
logger.Actionf("applying kustomization")
|
||||||
if err := upsertKustomization(ctx, kubeClient, kustomization); err != nil {
|
if err := upsertKustomization(ctx, kubeClient, kustomization); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logWaiting("waiting for kustomization sync")
|
logger.Waitingf("waiting for kustomization sync")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("kustomization %s is ready", name)
|
logger.Successf("kustomization %s is ready", name)
|
||||||
|
|
||||||
namespacedName := types.NamespacedName{
|
namespacedName := types.NamespacedName{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
@@ -201,7 +213,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if kustomization.Status.LastAppliedRevision != "" {
|
if kustomization.Status.LastAppliedRevision != "" {
|
||||||
logSuccess("applied revision %s", kustomization.Status.LastAppliedRevision)
|
logger.Successf("applied revision %s", kustomization.Status.LastAppliedRevision)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("kustomization sync failed")
|
return fmt.Errorf("kustomization sync failed")
|
||||||
}
|
}
|
||||||
@@ -222,7 +234,7 @@ func upsertKustomization(ctx context.Context, kubeClient client.Client, kustomiz
|
|||||||
if err := kubeClient.Create(ctx, &kustomization); err != nil {
|
if err := kubeClient.Create(ctx, &kustomization); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
logSuccess("kustomization created")
|
logger.Successf("kustomization created")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +246,7 @@ func upsertKustomization(ctx context.Context, kubeClient client.Client, kustomiz
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("kustomization updated")
|
logger.Successf("kustomization updated")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var createSourceCmd = &cobra.Command{
|
var createSourceCmd = &cobra.Command{
|
||||||
Use: "source",
|
Use: "source",
|
||||||
Short: "Create source commands",
|
Short: "Create or update sources",
|
||||||
|
Long: "The create source sub-commands generate sources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -19,14 +35,14 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
"github.com/fluxcd/toolkit/pkg/ssh"
|
"github.com/fluxcd/pkg/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createSourceGitCmd = &cobra.Command{
|
var createSourceGitCmd = &cobra.Command{
|
||||||
Use: "git [name]",
|
Use: "git [name]",
|
||||||
Short: "Create or update a git source",
|
Short: "Create or update a GitRepository source",
|
||||||
Long: `
|
Long: `
|
||||||
The create source command generates a GitRepository resource and waits for it to sync.
|
The create source git command generates a GitRepository resource and waits for it to sync.
|
||||||
For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret.
|
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.`,
|
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
|
Example: ` # Create a source from a public Git repository master branch
|
||||||
@@ -150,7 +166,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
withAuth := false
|
withAuth := false
|
||||||
// TODO(hidde): move all auth prep to separate func?
|
// TODO(hidde): move all auth prep to separate func?
|
||||||
if u.Scheme == "ssh" {
|
if u.Scheme == "ssh" {
|
||||||
logAction("generating deploy key pair")
|
logger.Actionf("generating deploy key pair")
|
||||||
pair, err := generateKeyPair(ctx)
|
pair, err := generateKeyPair(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -165,15 +181,15 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return fmt.Errorf("aborting")
|
return fmt.Errorf("aborting")
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("collecting preferred public key from SSH server")
|
logger.Actionf("collecting preferred public key from SSH server")
|
||||||
hostKey, err := scanHostKey(ctx, u)
|
hostKey, err := scanHostKey(ctx, u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("collected public key from SSH server:")
|
logger.Successf("collected public key from SSH server:")
|
||||||
fmt.Printf("%s", hostKey)
|
fmt.Printf("%s", hostKey)
|
||||||
|
|
||||||
logAction("applying secret with keys")
|
logger.Actionf("applying secret with keys")
|
||||||
secret := corev1.Secret{
|
secret := corev1.Secret{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
@@ -190,7 +206,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
withAuth = true
|
withAuth = true
|
||||||
} else if sourceGitUsername != "" && sourceGitPassword != "" {
|
} else if sourceGitUsername != "" && sourceGitPassword != "" {
|
||||||
logAction("applying secret with basic auth credentials")
|
logger.Actionf("applying secret with basic auth credentials")
|
||||||
secret := corev1.Secret{
|
secret := corev1.Secret{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
@@ -208,10 +224,10 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if withAuth {
|
if withAuth {
|
||||||
logSuccess("authentication configured")
|
logger.Successf("authentication configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
logGenerate("generating source")
|
logger.Generatef("generating source")
|
||||||
|
|
||||||
if withAuth {
|
if withAuth {
|
||||||
gitRepository.Spec.SecretRef = &corev1.LocalObjectReference{
|
gitRepository.Spec.SecretRef = &corev1.LocalObjectReference{
|
||||||
@@ -219,18 +235,18 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("applying source")
|
logger.Actionf("applying source")
|
||||||
if err := upsertGitRepository(ctx, kubeClient, gitRepository); err != nil {
|
if err := upsertGitRepository(ctx, kubeClient, gitRepository); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logWaiting("waiting for git sync")
|
logger.Waitingf("waiting for git sync")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("git sync completed")
|
logger.Successf("git sync completed")
|
||||||
|
|
||||||
namespacedName := types.NamespacedName{
|
namespacedName := types.NamespacedName{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
@@ -242,7 +258,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if gitRepository.Status.Artifact != nil {
|
if gitRepository.Status.Artifact != nil {
|
||||||
logSuccess("fetched revision %s", gitRepository.Status.Artifact.Revision)
|
logger.Successf("fetched revision: %s", gitRepository.Status.Artifact.Revision)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("git sync failed, artifact not found")
|
return fmt.Errorf("git sync failed, artifact not found")
|
||||||
}
|
}
|
||||||
@@ -252,7 +268,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
func generateKeyPair(ctx context.Context) (*ssh.KeyPair, error) {
|
func generateKeyPair(ctx context.Context) (*ssh.KeyPair, error) {
|
||||||
var keyGen ssh.KeyPairGenerator
|
var keyGen ssh.KeyPairGenerator
|
||||||
switch sourceGitKeyAlgorithm.String() {
|
switch algorithm := sourceGitKeyAlgorithm.String(); algorithm {
|
||||||
case "rsa":
|
case "rsa":
|
||||||
keyGen = ssh.NewRSAGenerator(int(sourceGitRSABits))
|
keyGen = ssh.NewRSAGenerator(int(sourceGitRSABits))
|
||||||
case "ecdsa":
|
case "ecdsa":
|
||||||
@@ -260,11 +276,11 @@ func generateKeyPair(ctx context.Context) (*ssh.KeyPair, error) {
|
|||||||
case "ed25519":
|
case "ed25519":
|
||||||
keyGen = ssh.NewEd25519Generator()
|
keyGen = ssh.NewEd25519Generator()
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported public key algorithm '%s'", sourceGitKeyAlgorithm.String())
|
return nil, fmt.Errorf("unsupported public key algorithm: %s", algorithm)
|
||||||
}
|
}
|
||||||
pair, err := keyGen.Generate()
|
pair, err := keyGen.Generate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("key pair generation failed: %w", err)
|
return nil, fmt.Errorf("key pair generation failed, error: %w", err)
|
||||||
}
|
}
|
||||||
return pair, nil
|
return pair, nil
|
||||||
}
|
}
|
||||||
@@ -276,7 +292,7 @@ func scanHostKey(ctx context.Context, url *url.URL) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
hostKey, err := ssh.ScanHostKey(host, 30*time.Second)
|
hostKey, err := ssh.ScanHostKey(host, 30*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("SSH key scan for host '%s' failed: %w", host, err)
|
return nil, fmt.Errorf("SSH key scan for host %s failed, error: %w", host, err)
|
||||||
}
|
}
|
||||||
return hostKey, nil
|
return hostKey, nil
|
||||||
}
|
}
|
||||||
@@ -320,7 +336,7 @@ func upsertGitRepository(ctx context.Context, kubeClient client.Client, gitRepos
|
|||||||
if err := kubeClient.Create(ctx, &gitRepository); err != nil {
|
if err := kubeClient.Create(ctx, &gitRepository); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
logSuccess("source created")
|
logger.Successf("source created")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,7 +348,7 @@ func upsertGitRepository(ctx context.Context, kubeClient client.Client, gitRepos
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("source updated")
|
logger.Successf("source updated")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var deleteCmd = &cobra.Command{
|
var deleteCmd = &cobra.Command{
|
||||||
Use: "delete",
|
Use: "delete",
|
||||||
Short: "Delete commands",
|
Short: "Delete sources and resources",
|
||||||
|
Long: "The delete sub-commands delete sources and resources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -13,7 +29,8 @@ import (
|
|||||||
var deleteKsCmd = &cobra.Command{
|
var deleteKsCmd = &cobra.Command{
|
||||||
Use: "kustomization [name]",
|
Use: "kustomization [name]",
|
||||||
Aliases: []string{"ks"},
|
Aliases: []string{"ks"},
|
||||||
Short: "Delete kustomization",
|
Short: "Delete a Kustomization resource",
|
||||||
|
Long: "The delete kustomization command deletes the given Kustomization from the cluster.",
|
||||||
RunE: deleteKsCmdRun,
|
RunE: deleteKsCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +65,7 @@ func deleteKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
if !deleteSilent {
|
if !deleteSilent {
|
||||||
if !kustomization.Spec.Suspend {
|
if !kustomization.Spec.Suspend {
|
||||||
logWaiting("This action will remove the Kubernetes objects previously applied by the %s kustomization!", name)
|
logger.Waitingf("This action will remove the Kubernetes objects previously applied by the %s kustomization!", name)
|
||||||
}
|
}
|
||||||
prompt := promptui.Prompt{
|
prompt := promptui.Prompt{
|
||||||
Label: "Are you sure you want to delete this kustomization",
|
Label: "Are you sure you want to delete this kustomization",
|
||||||
@@ -59,12 +76,12 @@ func deleteKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("deleting kustomization %s in %s namespace", name, namespace)
|
logger.Actionf("deleting kustomization %s in %s namespace", name, namespace)
|
||||||
err = kubeClient.Delete(ctx, &kustomization)
|
err = kubeClient.Delete(ctx, &kustomization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("kustomization deleted")
|
logger.Successf("kustomization deleted")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var deleteSourceCmd = &cobra.Command{
|
var deleteSourceCmd = &cobra.Command{
|
||||||
Use: "source",
|
Use: "source",
|
||||||
Short: "Delete sources commands",
|
Short: "Delete sources",
|
||||||
|
Long: "The delete source sub-commands delete sources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -12,7 +28,8 @@ import (
|
|||||||
|
|
||||||
var deleteSourceGitCmd = &cobra.Command{
|
var deleteSourceGitCmd = &cobra.Command{
|
||||||
Use: "git [name]",
|
Use: "git [name]",
|
||||||
Short: "Delete git source",
|
Short: "Delete a GitRepository source",
|
||||||
|
Long: "The delete source git command deletes the given GitRepository from the cluster.",
|
||||||
RunE: deleteSourceGitCmdRun,
|
RunE: deleteSourceGitCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,12 +72,12 @@ func deleteSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("deleting source %s in %s namespace", name, namespace)
|
logger.Actionf("deleting source %s in %s namespace", name, namespace)
|
||||||
err = kubeClient.Delete(ctx, &git)
|
err = kubeClient.Delete(ctx, &git)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("source deleted")
|
logger.Successf("source deleted")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var exportCmd = &cobra.Command{
|
var exportCmd = &cobra.Command{
|
||||||
Use: "export",
|
Use: "export",
|
||||||
Short: "Export commands",
|
Short: "Export resources in YAML format",
|
||||||
|
Long: "The export sub-commands export resources in YAML format.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -15,11 +31,12 @@ import (
|
|||||||
var exportKsCmd = &cobra.Command{
|
var exportKsCmd = &cobra.Command{
|
||||||
Use: "kustomization [name]",
|
Use: "kustomization [name]",
|
||||||
Aliases: []string{"ks"},
|
Aliases: []string{"ks"},
|
||||||
Short: "Export kustomization in YAML format",
|
Short: "Export Kustomization resources in YAML format",
|
||||||
Example: ` # Export all kustomizations
|
Long: "The export kustomization command exports one or all Kustomization resources in YAML format.",
|
||||||
|
Example: ` # Export all Kustomization resources
|
||||||
export kustomization --all > kustomizations.yaml
|
export kustomization --all > kustomizations.yaml
|
||||||
|
|
||||||
# Export a kustomization
|
# Export a Kustomization
|
||||||
export kustomization my-app > kustomization.yaml
|
export kustomization my-app > kustomization.yaml
|
||||||
`,
|
`,
|
||||||
RunE: exportKsCmdRun,
|
RunE: exportKsCmdRun,
|
||||||
@@ -50,7 +67,7 @@ func exportKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(list.Items) == 0 {
|
if len(list.Items) == 0 {
|
||||||
logFailure("no kustomizations found in %s namespace", namespace)
|
logger.Failuref("no kustomizations found in %s namespace", namespace)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var exportSourceCmd = &cobra.Command{
|
var exportSourceCmd = &cobra.Command{
|
||||||
Use: "source",
|
Use: "source",
|
||||||
Short: "Export source commands",
|
Short: "Export sources",
|
||||||
|
Long: "The export source sub-commands export sources in YAML format.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -15,11 +31,12 @@ import (
|
|||||||
|
|
||||||
var exportSourceGitCmd = &cobra.Command{
|
var exportSourceGitCmd = &cobra.Command{
|
||||||
Use: "git [name]",
|
Use: "git [name]",
|
||||||
Short: "Export git sources in YAML format",
|
Short: "Export GitRepository sources in YAML format",
|
||||||
Example: ` # Export all git sources
|
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
|
export source git --all > sources.yaml
|
||||||
|
|
||||||
# Export a git source including the SSH keys or basic auth credentials
|
# Export a GitRepository source including the SSH key pair or basic auth credentials
|
||||||
export source git my-private-repo --with-credentials > source.yaml
|
export source git my-private-repo --with-credentials > source.yaml
|
||||||
`,
|
`,
|
||||||
RunE: exportSourceGitCmdRun,
|
RunE: exportSourceGitCmdRun,
|
||||||
@@ -50,7 +67,7 @@ func exportSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(list.Items) == 0 {
|
if len(list.Items) == 0 {
|
||||||
logFailure("no source found in %s namespace", namespace)
|
logger.Failuref("no source found in %s namespace", namespace)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,16 +126,16 @@ func exportGit(source sourcev1.GitRepository) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportGitCredentials(ctx context.Context, kubeClinet client.Client, source sourcev1.GitRepository) error {
|
func exportGitCredentials(ctx context.Context, kubeClient client.Client, source sourcev1.GitRepository) error {
|
||||||
if source.Spec.SecretRef != nil {
|
if source.Spec.SecretRef != nil {
|
||||||
namespacedName := types.NamespacedName{
|
namespacedName := types.NamespacedName{
|
||||||
Namespace: source.Namespace,
|
Namespace: source.Namespace,
|
||||||
Name: source.Spec.SecretRef.Name,
|
Name: source.Spec.SecretRef.Name,
|
||||||
}
|
}
|
||||||
var cred corev1.Secret
|
var cred corev1.Secret
|
||||||
err := kubeClinet.Get(ctx, namespacedName, &cred)
|
err := kubeClient.Get(ctx, namespacedName, &cred)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get secret failed: %w", err)
|
return fmt.Errorf("failed to retrieve secret %s, error: %w", namespacedName.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
exported := corev1.Secret{
|
exported := corev1.Secret{
|
||||||
|
|||||||
@@ -1,8 +1,25 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -108,5 +125,6 @@ func ecdsaCurves() []string {
|
|||||||
for k := range supportedECDSACurves {
|
for k := range supportedECDSACurves {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var getCmd = &cobra.Command{
|
var getCmd = &cobra.Command{
|
||||||
Use: "get",
|
Use: "get",
|
||||||
Short: "Get commands",
|
Short: "Get sources and resources",
|
||||||
|
Long: "The get sub-commands print the statuses of sources and resources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -12,10 +28,9 @@ import (
|
|||||||
var getKsCmd = &cobra.Command{
|
var getKsCmd = &cobra.Command{
|
||||||
Use: "kustomizations",
|
Use: "kustomizations",
|
||||||
Aliases: []string{"ks"},
|
Aliases: []string{"ks"},
|
||||||
Short: "Get kustomizations status",
|
Short: "Get Kustomization source statuses",
|
||||||
Long: `
|
Long: "The get kustomizations command prints the statuses of the resources.",
|
||||||
The get kustomizations command prints the status of the resources.`,
|
RunE: getKsCmdRun,
|
||||||
RunE: getKsCmdRun,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -38,29 +53,33 @@ func getKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(list.Items) == 0 {
|
if len(list.Items) == 0 {
|
||||||
logFailure("no kustomizations found in %s namespace", namespace)
|
logger.Failuref("no kustomizations found in %s namespace", namespace)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, kustomization := range list.Items {
|
for _, kustomization := range list.Items {
|
||||||
if kustomization.Spec.Suspend {
|
if kustomization.Spec.Suspend {
|
||||||
logSuccess("%s is suspended", kustomization.GetName())
|
logger.Successf("%s is suspended", kustomization.GetName())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
isInitialized := false
|
isInitialized := false
|
||||||
for _, condition := range kustomization.Status.Conditions {
|
for _, condition := range kustomization.Status.Conditions {
|
||||||
if condition.Type == kustomizev1.ReadyCondition {
|
if condition.Type == kustomizev1.ReadyCondition {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
if condition.Status != corev1.ConditionFalse {
|
||||||
logSuccess("%s last applied revision %s", kustomization.GetName(), kustomization.Status.LastAppliedRevision)
|
if kustomization.Status.LastAppliedRevision != "" {
|
||||||
|
logger.Successf("%s last applied revision %s", kustomization.GetName(), kustomization.Status.LastAppliedRevision)
|
||||||
|
} else {
|
||||||
|
logger.Successf("%s reconciling", kustomization.GetName())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logFailure("%s %s", kustomization.GetName(), condition.Message)
|
logger.Failuref("%s %s", kustomization.GetName(), condition.Message)
|
||||||
}
|
}
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logFailure("%s is not ready", kustomization.GetName())
|
logger.Failuref("%s is not ready", kustomization.GetName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var getSourceCmd = &cobra.Command{
|
var getSourceCmd = &cobra.Command{
|
||||||
Use: "sources",
|
Use: "sources",
|
||||||
Short: "Get sources commands",
|
Short: "Get source statuses",
|
||||||
|
Long: "The get source sub-commands print the statuses of the sources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -11,10 +27,9 @@ import (
|
|||||||
|
|
||||||
var getSourceGitCmd = &cobra.Command{
|
var getSourceGitCmd = &cobra.Command{
|
||||||
Use: "git",
|
Use: "git",
|
||||||
Short: "Get git sources status",
|
Short: "Get GitRepository source statuses",
|
||||||
Long: `
|
Long: "The get sources git command prints the status of the GitRepository sources.",
|
||||||
The get sources command prints the status of the git resources.`,
|
RunE: getSourceGitCmdRun,
|
||||||
RunE: getSourceGitCmdRun,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -37,7 +52,7 @@ func getSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(list.Items) == 0 {
|
if len(list.Items) == 0 {
|
||||||
logFailure("no sources found in %s namespace", namespace)
|
logger.Failuref("no sources found in %s namespace", namespace)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,16 +61,16 @@ func getSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
for _, condition := range source.Status.Conditions {
|
for _, condition := range source.Status.Conditions {
|
||||||
if condition.Type == sourcev1.ReadyCondition {
|
if condition.Type == sourcev1.ReadyCondition {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
if condition.Status != corev1.ConditionFalse {
|
||||||
logSuccess("%s last fetched revision %s", source.GetName(), source.Status.Artifact.Revision)
|
logger.Successf("%s last fetched revision: %s", source.GetName(), source.Status.Artifact.Revision)
|
||||||
} else {
|
} else {
|
||||||
logFailure("%s %s", source.GetName(), condition.Message)
|
logger.Failuref("%s %s", source.GetName(), condition.Message)
|
||||||
}
|
}
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logFailure("%s is not ready", source.GetName())
|
logger.Failuref("%s is not ready", source.GetName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,13 +1,32 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/fluxcd/pkg/untar"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
@@ -17,32 +36,40 @@ import (
|
|||||||
var installCmd = &cobra.Command{
|
var installCmd = &cobra.Command{
|
||||||
Use: "install",
|
Use: "install",
|
||||||
Short: "Install the toolkit components",
|
Short: "Install the toolkit components",
|
||||||
Long: `
|
Long: `The install command deploys the toolkit components in the specified namespace.
|
||||||
The install command deploys the toolkit components in the specified namespace.
|
|
||||||
If a previous version is installed, then an in-place upgrade will be performed.`,
|
If a previous version is installed, then an in-place upgrade will be performed.`,
|
||||||
Example: ` # Install the latest version in the gitops-systems namespace
|
Example: ` # Install the latest version in the gitops-systems namespace
|
||||||
install --version=master --namespace=gitops-systems
|
tk install --version=latest --namespace=gitops-systems
|
||||||
|
|
||||||
# Dry-run install for a specific version and a series of components
|
# Dry-run install for a specific version and a series of components
|
||||||
install --dry-run --version=0.0.1 --components="source-controller,kustomize-controller"
|
tk install --dry-run --version=v0.0.7 --components="source-controller,kustomize-controller"
|
||||||
|
|
||||||
# Dry-run install with manifests preview
|
# Dry-run install with manifests preview
|
||||||
install --dry-run --verbose
|
tk install --dry-run --verbose
|
||||||
|
|
||||||
|
# Write install manifests to file
|
||||||
|
tk install --export > gitops-system.yaml
|
||||||
`,
|
`,
|
||||||
RunE: installCmdRun,
|
RunE: installCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
installExport bool
|
||||||
installDryRun bool
|
installDryRun bool
|
||||||
installManifestsPath string
|
installManifestsPath string
|
||||||
installVersion string
|
installVersion string
|
||||||
|
installComponents []string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
installCmd.Flags().BoolVar(&installExport, "export", false,
|
||||||
|
"write the install manifests to stdout and exit")
|
||||||
installCmd.Flags().BoolVarP(&installDryRun, "dry-run", "", false,
|
installCmd.Flags().BoolVarP(&installDryRun, "dry-run", "", false,
|
||||||
"only print the object that would be applied")
|
"only print the object that would be applied")
|
||||||
installCmd.Flags().StringVarP(&installVersion, "version", "v", "master",
|
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaultVersion,
|
||||||
"toolkit tag or branch")
|
"toolkit version")
|
||||||
|
installCmd.Flags().StringSliceVar(&installComponents, "components", defaultComponents,
|
||||||
|
"list of components, accepts comma-separated values")
|
||||||
installCmd.Flags().StringVarP(&installManifestsPath, "manifests", "", "",
|
installCmd.Flags().StringVarP(&installManifestsPath, "manifests", "", "",
|
||||||
"path to the manifest directory, dev only")
|
"path to the manifest directory, dev only")
|
||||||
rootCmd.AddCommand(installCmd)
|
rootCmd.AddCommand(installCmd)
|
||||||
@@ -66,9 +93,11 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
logGenerate("generating manifests")
|
if !installExport {
|
||||||
|
logger.Generatef("generating manifests")
|
||||||
|
}
|
||||||
if kustomizePath == "" {
|
if kustomizePath == "" {
|
||||||
err = genInstallManifests(installVersion, namespace, components, tmpDir)
|
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("install failed: %w", err)
|
return fmt.Errorf("install failed: %w", err)
|
||||||
}
|
}
|
||||||
@@ -86,11 +115,17 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
} else {
|
} else {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Print(yaml)
|
fmt.Print(yaml)
|
||||||
|
} else if installExport {
|
||||||
|
fmt.Println("---")
|
||||||
|
fmt.Println("# GitOps Toolkit revision", installVersion, time.Now().Format(time.RFC3339))
|
||||||
|
fmt.Print(yaml)
|
||||||
|
fmt.Println("---")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logSuccess("manifests build completed")
|
logger.Successf("manifests build completed")
|
||||||
|
|
||||||
logAction("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
applyOutput := ModeStderrOS
|
applyOutput := ModeStderrOS
|
||||||
if verbose {
|
if verbose {
|
||||||
applyOutput = ModeOS
|
applyOutput = ModeOS
|
||||||
@@ -106,24 +141,24 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if installDryRun {
|
if installDryRun {
|
||||||
logSuccess("install dry-run finished")
|
logger.Successf("install dry-run finished")
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
logSuccess("install completed")
|
logger.Successf("install completed")
|
||||||
}
|
}
|
||||||
|
|
||||||
logWaiting("verifying installation")
|
logger.Waitingf("verifying installation")
|
||||||
for _, deployment := range components {
|
for _, deployment := range installComponents {
|
||||||
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
||||||
namespace, deployment, timeout.String())
|
namespace, deployment, timeout.String())
|
||||||
if _, err := utils.execCommand(ctx, applyOutput, command); err != nil {
|
if _, err := utils.execCommand(ctx, applyOutput, command); err != nil {
|
||||||
return fmt.Errorf("install failed")
|
return fmt.Errorf("install failed")
|
||||||
} else {
|
} else {
|
||||||
logSuccess("%s ready", deployment)
|
logger.Successf("%s ready", deployment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("install finished")
|
logger.Successf("install finished")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,10 +191,10 @@ transformers:
|
|||||||
- labels.yaml
|
- labels.yaml
|
||||||
resources:
|
resources:
|
||||||
- namespace.yaml
|
- namespace.yaml
|
||||||
|
- policies.yaml
|
||||||
- roles
|
- roles
|
||||||
- github.com/fluxcd/toolkit/manifests/policies?ref={{$version}}
|
|
||||||
{{- range .Components }}
|
{{- range .Components }}
|
||||||
- github.com/fluxcd/toolkit/manifests/bases/{{.}}?ref={{$version}}
|
- {{.}}.yaml
|
||||||
{{- end }}
|
{{- end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -167,10 +202,44 @@ var kustomizationRolesTmpl = `---
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- github.com/fluxcd/toolkit/manifests/rbac?ref={{.Version}}
|
- rbac.yaml
|
||||||
nameSuffix: -{{.Namespace}}
|
nameSuffix: -{{.Namespace}}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
func downloadManifests(version string, tmpDir string) error {
|
||||||
|
ghURL := "https://github.com/fluxcd/toolkit/releases/latest/download/manifests.tar.gz"
|
||||||
|
if strings.HasPrefix(version, "v") {
|
||||||
|
ghURL = fmt.Sprintf("https://github.com/fluxcd/toolkit/releases/download/%s/manifests.tar.gz", version)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", ghURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create HTTP request for %s, error: %w", ghURL, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// download
|
||||||
|
resp, err := http.DefaultClient.Do(req.WithContext(ctx))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to download artifact from %s, error: %w", ghURL, err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// check response
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return fmt.Errorf("faild to download artifact from %s, status: %s", ghURL, resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract
|
||||||
|
if _, err = untar.Untar(resp.Body, tmpDir); err != nil {
|
||||||
|
return fmt.Errorf("faild to untar manifests from %s, error: %w", ghURL, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func genInstallManifests(version string, namespace string, components []string, tmpDir string) error {
|
func genInstallManifests(version string, namespace string, components []string, tmpDir string) error {
|
||||||
model := struct {
|
model := struct {
|
||||||
Version string
|
Version string
|
||||||
@@ -182,6 +251,10 @@ func genInstallManifests(version string, namespace string, components []string,
|
|||||||
Components: components,
|
Components: components,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := downloadManifests(version, tmpDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := utils.execTemplate(model, namespaceTmpl, path.Join(tmpDir, "namespace.yaml")); err != nil {
|
if err := utils.execTemplate(model, namespaceTmpl, path.Join(tmpDir, "namespace.yaml")); err != nil {
|
||||||
return fmt.Errorf("generate namespace failed: %w", err)
|
return fmt.Errorf("generate namespace failed: %w", err)
|
||||||
}
|
}
|
||||||
@@ -202,6 +275,10 @@ func genInstallManifests(version string, namespace string, components []string,
|
|||||||
return fmt.Errorf("generate roles failed: %w", err)
|
return fmt.Errorf("generate roles failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := utils.copyFile(filepath.Join(tmpDir, "rbac.yaml"), filepath.Join(tmpDir, "roles/rbac.yaml")); err != nil {
|
||||||
|
return fmt.Errorf("generate rbac failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,41 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func logAction(format string, a ...interface{}) {
|
type printLogger struct{}
|
||||||
|
|
||||||
|
func (l printLogger) Actionf(format string, a ...interface{}) {
|
||||||
fmt.Println(`►`, fmt.Sprintf(format, a...))
|
fmt.Println(`►`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logGenerate(format string, a ...interface{}) {
|
func (l printLogger) Generatef(format string, a ...interface{}) {
|
||||||
fmt.Println(`✚`, fmt.Sprintf(format, a...))
|
fmt.Println(`✚`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logWaiting(format string, a ...interface{}) {
|
func (l printLogger) Waitingf(format string, a ...interface{}) {
|
||||||
fmt.Println(`◎`, fmt.Sprintf(format, a...))
|
fmt.Println(`◎`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logSuccess(format string, a ...interface{}) {
|
func (l printLogger) Successf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✔`, fmt.Sprintf(format, a...))
|
fmt.Println(`✔`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logFailure(format string, a ...interface{}) {
|
func (l printLogger) Failuref(format string, a ...interface{}) {
|
||||||
fmt.Println(`✗`, fmt.Sprintf(format, a...))
|
fmt.Println(`✗`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -9,6 +25,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/cobra/doc"
|
"github.com/spf13/cobra/doc"
|
||||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||||
|
|
||||||
|
tklog "github.com/fluxcd/toolkit/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VERSION = "0.0.0-dev.0"
|
var VERSION = "0.0.0-dev.0"
|
||||||
@@ -32,16 +50,16 @@ var rootCmd = &cobra.Command{
|
|||||||
--branch=master \
|
--branch=master \
|
||||||
--interval=3m
|
--interval=3m
|
||||||
|
|
||||||
# List git sources and their status
|
# List GitRepository sources and their status
|
||||||
tk get sources git
|
tk get sources git
|
||||||
|
|
||||||
# Trigger a git sync
|
# Trigger a GitRepository source sync
|
||||||
tk sync source git webapp-latest
|
tk sync source git webapp-latest
|
||||||
|
|
||||||
# Export git sources in YAML format
|
# Export GitRepository sources in YAML format
|
||||||
tk export source git --all > sources.yaml
|
tk export source git --all > sources.yaml
|
||||||
|
|
||||||
# Create a kustomization for deploying a series of microservices
|
# Create a Kustomization for deploying a series of microservices
|
||||||
tk create kustomization webapp-dev \
|
tk create kustomization webapp-dev \
|
||||||
--source=webapp-latest \
|
--source=webapp-latest \
|
||||||
--path="./deploy/webapp/" \
|
--path="./deploy/webapp/" \
|
||||||
@@ -52,22 +70,22 @@ var rootCmd = &cobra.Command{
|
|||||||
--health-check="Deployment/frontend.webapp" \
|
--health-check="Deployment/frontend.webapp" \
|
||||||
--health-check-timeout=2m
|
--health-check-timeout=2m
|
||||||
|
|
||||||
# Trigger a git sync and apply changes if any
|
# Trigger a git sync of the Kustomization's source and apply changes
|
||||||
tk sync kustomization webapp-dev --with-source
|
tk reconcile kustomization webapp-dev --with-source
|
||||||
|
|
||||||
# Suspend a kustomization reconciliation
|
# Suspend a Kustomization reconciliation
|
||||||
tk suspend kustomization webapp-dev
|
tk suspend kustomization webapp-dev
|
||||||
|
|
||||||
# Export kustomizations in YAML format
|
# Export Kustomizations in YAML format
|
||||||
tk export kustomization --all > kustomizations.yaml
|
tk export kustomization --all > kustomizations.yaml
|
||||||
|
|
||||||
# Resume a kustomization reconciliation
|
# Resume a Kustomization reconciliation
|
||||||
tk resume kustomization webapp-dev
|
tk resume kustomization webapp-dev
|
||||||
|
|
||||||
# Delete a kustomization
|
# Delete a Kustomization
|
||||||
tk delete kustomization webapp-dev
|
tk delete kustomization webapp-dev
|
||||||
|
|
||||||
# Delete a git source
|
# Delete a GitRepository source
|
||||||
tk delete source git webapp-latest
|
tk delete source git webapp-latest
|
||||||
|
|
||||||
# Uninstall the toolkit and delete CRDs
|
# Uninstall the toolkit and delete CRDs
|
||||||
@@ -80,21 +98,24 @@ var (
|
|||||||
namespace string
|
namespace string
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
verbose bool
|
verbose bool
|
||||||
components []string
|
|
||||||
utils Utils
|
utils Utils
|
||||||
pollInterval = 2 * time.Second
|
pollInterval = 2 * time.Second
|
||||||
|
logger tklog.Logger = printLogger{}
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"}
|
||||||
|
defaultVersion = "latest"
|
||||||
|
defaultNamespace = "gitops-system"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringVarP(&namespace, "namespace", "", "gitops-system",
|
rootCmd.PersistentFlags().StringVar(&namespace, "namespace", defaultNamespace,
|
||||||
"the namespace scope for this operation")
|
"the namespace scope for this operation")
|
||||||
rootCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "", 5*time.Minute,
|
rootCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "", 5*time.Minute,
|
||||||
"timeout for this operation")
|
"timeout for this operation")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "", false,
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "", false,
|
||||||
"print generated objects")
|
"print generated objects")
|
||||||
rootCmd.PersistentFlags().StringSliceVar(&components, "components",
|
|
||||||
[]string{"source-controller", "kustomize-controller"},
|
|
||||||
"list of components, accepts comma-separated values")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -102,7 +123,7 @@ func main() {
|
|||||||
generateDocs()
|
generateDocs()
|
||||||
kubeconfigFlag()
|
kubeconfigFlag()
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
logFailure("%v", err)
|
logger.Failuref("%v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +136,10 @@ func kubeconfigFlag() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "",
|
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "",
|
||||||
"absolute path to the kubeconfig file")
|
"absolute path to the kubeconfig file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(os.Getenv("KUBECONFIG")) > 0 {
|
||||||
|
kubeconfig = os.Getenv("KUBECONFIG")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateDocs() {
|
func generateDocs() {
|
||||||
@@ -122,6 +147,7 @@ func generateDocs() {
|
|||||||
if len(args) > 0 && args[0] == "docgen" {
|
if len(args) > 0 && args[0] == "docgen" {
|
||||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "~/.kube/config",
|
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "~/.kube/config",
|
||||||
"path to the kubeconfig file")
|
"path to the kubeconfig file")
|
||||||
|
rootCmd.DisableAutoGenTag = true
|
||||||
err := doc.GenMarkdownTree(rootCmd, "./docs/cmd")
|
err := doc.GenMarkdownTree(rootCmd, "./docs/cmd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
31
cmd/tk/reconcile.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileCmd = &cobra.Command{
|
||||||
|
Use: "reconcile",
|
||||||
|
Short: "Reconcile sources and resources",
|
||||||
|
Long: "The reconcile sub-commands trigger a reconciliation of sources and resources.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(reconcileCmd)
|
||||||
|
}
|
||||||
148
cmd/tk/reconcile_helmrelease.go
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
helmv2 "github.com/fluxcd/helm-controller/api/v2alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileHrCmd = &cobra.Command{
|
||||||
|
Use: "helmrelease [name]",
|
||||||
|
Aliases: []string{"hr"},
|
||||||
|
Short: "Reconcile a HelmRelease resource",
|
||||||
|
Long: `
|
||||||
|
The reconcile kustomization command triggers a reconciliation of a HelmRelease resource and waits for it to finish.`,
|
||||||
|
Example: ` # Trigger a HelmRelease apply outside of the reconciliation interval
|
||||||
|
tk reconcile hr podinfo
|
||||||
|
|
||||||
|
# Trigger a reconciliation of the HelmRelease's source and apply changes
|
||||||
|
tk reconcile hr podinfo --with-source
|
||||||
|
`,
|
||||||
|
RunE: reconcileHrCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
syncHrWithSource bool
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileHrCmd.Flags().BoolVar(&syncHrWithSource, "with-source", false, "reconcile HelmRelease source")
|
||||||
|
|
||||||
|
reconcileCmd.AddCommand(reconcileHrCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func reconcileHrCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("HelmRelease 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 helmRelease helmv2.HelmRelease
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if syncHrWithSource {
|
||||||
|
err := syncSourceHelmCmdRun(nil, []string{helmRelease.Spec.Chart.SourceRef.Name})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Actionf("annotating HelmRelease %s in %s namespace", name, namespace)
|
||||||
|
if helmRelease.Annotations == nil {
|
||||||
|
helmRelease.Annotations = map[string]string{
|
||||||
|
helmv2.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
helmRelease.Annotations[helmv2.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
if err := kubeClient.Update(ctx, &helmRelease); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("HelmRelease annotated")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for HelmRelease reconciliation")
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isHelmReleaseReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("HelmRelease reconciliation completed")
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmRelease.Status.LastAppliedRevision != "" {
|
||||||
|
logger.Successf("reconciled revision %s", helmRelease.Status.LastAppliedRevision)
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("HelmRelease reconciliation failed")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isHelmReleaseReady(ctx context.Context, kubeClient client.Client, name, namespace string) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
var helmRelease helmv2.HelmRelease
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, condition := range helmRelease.Status.Conditions {
|
||||||
|
if condition.Type == helmv2.ReadyCondition {
|
||||||
|
if condition.Status == corev1.ConditionTrue {
|
||||||
|
return true, nil
|
||||||
|
} else if condition.Status == corev1.ConditionFalse {
|
||||||
|
return false, fmt.Errorf(condition.Message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
119
cmd/tk/reconcile_kustomization.go
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileKsCmd = &cobra.Command{
|
||||||
|
Use: "kustomization [name]",
|
||||||
|
Aliases: []string{"ks"},
|
||||||
|
Short: "Reconcile a Kustomization resource",
|
||||||
|
Long: `
|
||||||
|
The reconcile kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.`,
|
||||||
|
Example: ` # Trigger a Kustomization apply outside of the reconciliation interval
|
||||||
|
tk reconcile kustomization podinfo
|
||||||
|
|
||||||
|
# Trigger a sync of the Kustomization's source and apply changes
|
||||||
|
tk reconcile kustomization podinfo --with-source
|
||||||
|
`,
|
||||||
|
RunE: reconcileKsCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
syncKsWithSource bool
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileKsCmd.Flags().BoolVar(&syncKsWithSource, "with-source", false, "reconcile kustomization source")
|
||||||
|
|
||||||
|
reconcileCmd.AddCommand(reconcileKsCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func reconcileKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("kustomization 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 kustomization kustomizev1.Kustomization
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if syncKsWithSource {
|
||||||
|
err := syncSourceGitCmdRun(nil, []string{kustomization.Spec.SourceRef.Name})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Actionf("annotating kustomization %s in %s namespace", name, namespace)
|
||||||
|
if kustomization.Annotations == nil {
|
||||||
|
kustomization.Annotations = map[string]string{
|
||||||
|
kustomizev1.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
kustomization.Annotations[kustomizev1.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("kustomization annotated")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for kustomization reconciliation")
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("kustomization reconciliation completed")
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if kustomization.Status.LastAppliedRevision != "" {
|
||||||
|
logger.Successf("reconciled revision %s", kustomization.Status.LastAppliedRevision)
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("kustomization sync failed")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
31
cmd/tk/reconcile_source.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileSourceCmd = &cobra.Command{
|
||||||
|
Use: "source",
|
||||||
|
Short: "Reconcile sources",
|
||||||
|
Long: "The reconcile source sub-commands trigger a reconciliation of sources.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileCmd.AddCommand(reconcileSourceCmd)
|
||||||
|
}
|
||||||
100
cmd/tk/reconcile_source_git.go
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileSourceGitCmd = &cobra.Command{
|
||||||
|
Use: "git [name]",
|
||||||
|
Short: "Reconcile a GitRepository source",
|
||||||
|
Long: `The reconcile source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`,
|
||||||
|
Example: ` # Trigger a git pull for an existing source
|
||||||
|
tk reconcile source git podinfo
|
||||||
|
`,
|
||||||
|
RunE: syncSourceGitCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileSourceCmd.AddCommand(reconcileSourceGitCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func syncSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("source 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,
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating source %s in %s namespace", name, namespace)
|
||||||
|
var gitRepository sourcev1.GitRepository
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &gitRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if gitRepository.Annotations == nil {
|
||||||
|
gitRepository.Annotations = map[string]string{
|
||||||
|
sourcev1.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gitRepository.Annotations[sourcev1.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
if err := kubeClient.Update(ctx, &gitRepository); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("source annotated")
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for reconciliation")
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("git reconciliation completed")
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &gitRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if gitRepository.Status.Artifact != nil {
|
||||||
|
logger.Successf("fetched revision %s", gitRepository.Status.Artifact.Revision)
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("git reconciliation failed, artifact not found")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
130
cmd/tk/reconcile_source_helm.go
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
tk reconcile source helm podinfo
|
||||||
|
`,
|
||||||
|
RunE: syncSourceHelmCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileSourceCmd.AddCommand(reconcileSourceHelmCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func syncSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("source 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,
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating source %s in %s namespace", name, namespace)
|
||||||
|
var helmRepository sourcev1.HelmRepository
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmRepository.Annotations == nil {
|
||||||
|
helmRepository.Annotations = map[string]string{
|
||||||
|
sourcev1.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
helmRepository.Annotations[sourcev1.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
if err := kubeClient.Update(ctx, &helmRepository); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("source annotated")
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for reconciliation")
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isHelmRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("helm reconciliation completed")
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmRepository.Status.Artifact != nil {
|
||||||
|
logger.Successf("fetched revision %s", helmRepository.Status.Artifact.Revision)
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("helm reconciliation failed, artifact not found")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isHelmRepositoryReady(ctx context.Context, kubeClient client.Client, name, namespace string) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
var helmRepository sourcev1.HelmRepository
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &helmRepository)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, condition := range helmRepository.Status.Conditions {
|
||||||
|
if condition.Type == sourcev1.ReadyCondition {
|
||||||
|
if condition.Status == corev1.ConditionTrue {
|
||||||
|
return true, nil
|
||||||
|
} else if condition.Status == corev1.ConditionFalse {
|
||||||
|
return false, fmt.Errorf(condition.Message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var resumeCmd = &cobra.Command{
|
var resumeCmd = &cobra.Command{
|
||||||
Use: "resume",
|
Use: "resume",
|
||||||
Short: "Resume commands",
|
Short: "Resume suspended resources",
|
||||||
|
Long: "The resume sub-commands resume a suspended resource.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
126
cmd/tk/resume_helmrelease.go
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
helmv2 "github.com/fluxcd/helm-controller/api/v2alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var resumeHrCmd = &cobra.Command{
|
||||||
|
Use: "helmrelease [name]",
|
||||||
|
Aliases: []string{"hr"},
|
||||||
|
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.`,
|
||||||
|
RunE: resumeHrCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
resumeCmd.AddCommand(resumeHrCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func resumeHrCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("HelmRelease 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 helmRelease helmv2.HelmRelease
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("resuming HelmRelease %s in %s namespace", name, namespace)
|
||||||
|
helmRelease.Spec.Suspend = false
|
||||||
|
if err := kubeClient.Update(ctx, &helmRelease); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("HelmRelease resumed")
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for HelmRelease reconciliation")
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isHelmReleaseResumed(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("HelmRelease reconciliation completed")
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmRelease.Status.LastAppliedRevision != "" {
|
||||||
|
logger.Successf("applied revision %s", helmRelease.Status.LastAppliedRevision)
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("HelmRelease reconciliation failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isHelmReleaseResumed(ctx context.Context, kubeClient client.Client, name, namespace string) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
var helmRelease helmv2.HelmRelease
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, condition := range helmRelease.Status.Conditions {
|
||||||
|
if condition.Type == helmv2.ReadyCondition {
|
||||||
|
if condition.Status == corev1.ConditionTrue {
|
||||||
|
return true, nil
|
||||||
|
} else if condition.Status == corev1.ConditionFalse {
|
||||||
|
if condition.Reason == helmv2.SuspendedReason {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, fmt.Errorf(condition.Message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -16,9 +32,10 @@ import (
|
|||||||
var resumeKsCmd = &cobra.Command{
|
var resumeKsCmd = &cobra.Command{
|
||||||
Use: "kustomization [name]",
|
Use: "kustomization [name]",
|
||||||
Aliases: []string{"ks"},
|
Aliases: []string{"ks"},
|
||||||
Short: "Resume kustomization",
|
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.",
|
Long: `The resume command marks a previously suspended Kustomization resource for reconciliation and waits for it to
|
||||||
RunE: resumeKsCmdRun,
|
finish the apply.`,
|
||||||
|
RunE: resumeKsCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -49,20 +66,20 @@ func resumeKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("resuming kustomization %s in %s namespace", name, namespace)
|
logger.Actionf("resuming kustomization %s in %s namespace", name, namespace)
|
||||||
kustomization.Spec.Suspend = false
|
kustomization.Spec.Suspend = false
|
||||||
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("kustomization resumed")
|
logger.Successf("kustomization resumed")
|
||||||
|
|
||||||
logWaiting("waiting for kustomization sync")
|
logger.Waitingf("waiting for kustomization sync")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
isKustomizationResumed(ctx, kubeClient, name, namespace)); err != nil {
|
isKustomizationResumed(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("kustomization sync completed")
|
logger.Successf("kustomization sync completed")
|
||||||
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -70,7 +87,7 @@ func resumeKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if kustomization.Status.LastAppliedRevision != "" {
|
if kustomization.Status.LastAppliedRevision != "" {
|
||||||
logSuccess("applied revision %s", kustomization.Status.LastAppliedRevision)
|
logger.Successf("applied revision %s", kustomization.Status.LastAppliedRevision)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("kustomization sync failed")
|
return fmt.Errorf("kustomization sync failed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,7 +22,8 @@ import (
|
|||||||
|
|
||||||
var suspendCmd = &cobra.Command{
|
var suspendCmd = &cobra.Command{
|
||||||
Use: "suspend",
|
Use: "suspend",
|
||||||
Short: "Suspend commands",
|
Short: "Suspend resources",
|
||||||
|
Long: "The suspend sub-commands suspend the reconciliation of a resource.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
73
cmd/tk/suspend_helmrelease.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
helmv2 "github.com/fluxcd/helm-controller/api/v2alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var suspendHrCmd = &cobra.Command{
|
||||||
|
Use: "helmrelease [name]",
|
||||||
|
Aliases: []string{"hr"},
|
||||||
|
Short: "Suspend reconciliation of HelmRelease",
|
||||||
|
Long: "The suspend command disables the reconciliation of a HelmRelease resource.",
|
||||||
|
RunE: suspendHrCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
suspendCmd.AddCommand(suspendHrCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func suspendHrCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("HelmRelease 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 helmRelease helmv2.HelmRelease
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("suspending HelmRelease %s in %s namespace", name, namespace)
|
||||||
|
helmRelease.Spec.Suspend = true
|
||||||
|
if err := kubeClient.Update(ctx, &helmRelease); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("HelmRelease suspended")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -11,7 +27,7 @@ import (
|
|||||||
var suspendKsCmd = &cobra.Command{
|
var suspendKsCmd = &cobra.Command{
|
||||||
Use: "kustomization [name]",
|
Use: "kustomization [name]",
|
||||||
Aliases: []string{"ks"},
|
Aliases: []string{"ks"},
|
||||||
Short: "Suspend kustomization",
|
Short: "Suspend reconciliation of Kustomization",
|
||||||
Long: "The suspend command disables the reconciliation of a Kustomization resource.",
|
Long: "The suspend command disables the reconciliation of a Kustomization resource.",
|
||||||
RunE: suspendKsCmdRun,
|
RunE: suspendKsCmdRun,
|
||||||
}
|
}
|
||||||
@@ -44,12 +60,12 @@ func suspendKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("suspending kustomization %s in %s namespace", name, namespace)
|
logger.Actionf("suspending kustomization %s in %s namespace", name, namespace)
|
||||||
kustomization.Spec.Suspend = true
|
kustomization.Spec.Suspend = true
|
||||||
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logSuccess("kustomization suspended")
|
logger.Successf("kustomization suspended")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var syncCmd = &cobra.Command{
|
|
||||||
Use: "sync",
|
|
||||||
Short: "Synchronize commands",
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
rootCmd.AddCommand(syncCmd)
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
)
|
|
||||||
|
|
||||||
var syncKsCmd = &cobra.Command{
|
|
||||||
Use: "kustomization [name]",
|
|
||||||
Aliases: []string{"ks"},
|
|
||||||
Short: "Synchronize kustomization",
|
|
||||||
Long: `
|
|
||||||
The sync kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.`,
|
|
||||||
Example: ` # Trigger a kustomization apply outside of the reconciliation interval
|
|
||||||
sync kustomization podinfo
|
|
||||||
|
|
||||||
# Trigger a git sync of the kustomization source and apply changes
|
|
||||||
sync kustomization podinfo --with-source
|
|
||||||
`,
|
|
||||||
RunE: syncKsCmdRun,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
syncKsWithSource bool
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
syncKsCmd.Flags().BoolVar(&syncKsWithSource, "with-source", false, "synchronize kustomization source")
|
|
||||||
|
|
||||||
syncCmd.AddCommand(syncKsCmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
func syncKsCmdRun(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) < 1 {
|
|
||||||
return fmt.Errorf("kustomization 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 kustomization kustomizev1.Kustomization
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if syncKsWithSource {
|
|
||||||
err := syncSourceGitCmdRun(nil, []string{kustomization.Spec.SourceRef.Name})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logAction("annotating kustomization %s in %s namespace", name, namespace)
|
|
||||||
if kustomization.Annotations == nil {
|
|
||||||
kustomization.Annotations = map[string]string{
|
|
||||||
kustomizev1.SyncAtAnnotation: time.Now().String(),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
kustomization.Annotations[kustomizev1.SyncAtAnnotation] = time.Now().String()
|
|
||||||
}
|
|
||||||
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
logSuccess("kustomization annotated")
|
|
||||||
}
|
|
||||||
|
|
||||||
logWaiting("waiting for kustomization sync")
|
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
|
||||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
logSuccess("kustomization sync completed")
|
|
||||||
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if kustomization.Status.LastAppliedRevision != "" {
|
|
||||||
logSuccess("applied revision %s", kustomization.Status.LastAppliedRevision)
|
|
||||||
} else {
|
|
||||||
return fmt.Errorf("kustomization sync failed")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var syncSourceCmd = &cobra.Command{
|
|
||||||
Use: "source",
|
|
||||||
Short: "Synchronize source commands",
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
syncCmd.AddCommand(syncSourceCmd)
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var syncSourceGitCmd = &cobra.Command{
|
|
||||||
Use: "git [name]",
|
|
||||||
Short: "Synchronize git source",
|
|
||||||
Long: `
|
|
||||||
The sync source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`,
|
|
||||||
Example: ` # Trigger a git pull for an existing source
|
|
||||||
sync source git podinfo
|
|
||||||
`,
|
|
||||||
RunE: syncSourceGitCmdRun,
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
syncSourceCmd.AddCommand(syncSourceGitCmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
func syncSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) < 1 {
|
|
||||||
return fmt.Errorf("source 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,
|
|
||||||
}
|
|
||||||
|
|
||||||
logAction("annotating source %s in %s namespace", name, namespace)
|
|
||||||
var gitRepository sourcev1.GitRepository
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, &gitRepository)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if gitRepository.Annotations == nil {
|
|
||||||
gitRepository.Annotations = map[string]string{
|
|
||||||
sourcev1.SyncAtAnnotation: time.Now().String(),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gitRepository.Annotations[sourcev1.SyncAtAnnotation] = time.Now().String()
|
|
||||||
}
|
|
||||||
if err := kubeClient.Update(ctx, &gitRepository); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
logSuccess("source annotated")
|
|
||||||
|
|
||||||
logWaiting("waiting for git sync")
|
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
|
||||||
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
logSuccess("git sync completed")
|
|
||||||
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, &gitRepository)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if gitRepository.Status.Artifact != nil {
|
|
||||||
logSuccess("fetched revision %s", gitRepository.Status.Artifact.Revision)
|
|
||||||
} else {
|
|
||||||
return fmt.Errorf("git sync failed, artifact not found")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,25 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/manifoldco/promptui"
|
"github.com/manifoldco/promptui"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -11,9 +28,7 @@ import (
|
|||||||
var uninstallCmd = &cobra.Command{
|
var uninstallCmd = &cobra.Command{
|
||||||
Use: "uninstall",
|
Use: "uninstall",
|
||||||
Short: "Uninstall the toolkit components",
|
Short: "Uninstall the toolkit components",
|
||||||
Long: `
|
Long: "The uninstall command removes the namespace, cluster roles, cluster role bindings and CRDs from the cluster.",
|
||||||
The uninstall command removes the namespace, cluster roles,
|
|
||||||
cluster role bindings and CRDs.`,
|
|
||||||
Example: ` # Dry-run uninstall of all components
|
Example: ` # Dry-run uninstall of all components
|
||||||
uninstall --dry-run --namespace=gitops-system
|
uninstall --dry-run --namespace=gitops-system
|
||||||
|
|
||||||
@@ -24,12 +39,15 @@ cluster role bindings and CRDs.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
uninstallCRDs bool
|
uninstallCRDs bool
|
||||||
uninstallDryRun bool
|
uninstallKustomizations bool
|
||||||
uninstallSilent bool
|
uninstallDryRun bool
|
||||||
|
uninstallSilent bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
uninstallCmd.Flags().BoolVarP(&uninstallKustomizations, "kustomizations", "", false,
|
||||||
|
"removes all Kustomizations previously installed")
|
||||||
uninstallCmd.Flags().BoolVarP(&uninstallCRDs, "crds", "", false,
|
uninstallCmd.Flags().BoolVarP(&uninstallCRDs, "crds", "", false,
|
||||||
"removes all CRDs previously installed")
|
"removes all CRDs previously installed")
|
||||||
uninstallCmd.Flags().BoolVarP(&uninstallDryRun, "dry-run", "", false,
|
uninstallCmd.Flags().BoolVarP(&uninstallDryRun, "dry-run", "", false,
|
||||||
@@ -57,18 +75,32 @@ func uninstallCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if uninstallKustomizations {
|
||||||
|
logger.Actionf("uninstalling kustomizations")
|
||||||
|
command := fmt.Sprintf("kubectl -n %s delete kustomizations --all --timeout=%s %s",
|
||||||
|
namespace, timeout.String(), dryRun)
|
||||||
|
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
||||||
|
return fmt.Errorf("uninstall failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: use the kustomizations snapshots to create a list of objects
|
||||||
|
// that are subject to deletion and wait for all of them to be terminated
|
||||||
|
logger.Waitingf("waiting on GC")
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
kinds := "namespace,clusterroles,clusterrolebindings"
|
kinds := "namespace,clusterroles,clusterrolebindings"
|
||||||
if uninstallCRDs {
|
if uninstallCRDs {
|
||||||
kinds += ",crds"
|
kinds += ",crds"
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("uninstalling components")
|
logger.Actionf("uninstalling components")
|
||||||
command := fmt.Sprintf("kubectl delete %s -l app.kubernetes.io/instance=%s --timeout=%s %s",
|
command := fmt.Sprintf("kubectl delete %s -l app.kubernetes.io/instance=%s --timeout=%s %s",
|
||||||
kinds, namespace, timeout.String(), dryRun)
|
kinds, namespace, timeout.String(), dryRun)
|
||||||
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
||||||
return fmt.Errorf("uninstall failed")
|
return fmt.Errorf("uninstall failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
logSuccess("uninstall finished")
|
logger.Successf("uninstall finished")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -95,7 +111,7 @@ func (*Utils) execTemplate(obj interface{}, tmpl, filename string) error {
|
|||||||
func (*Utils) kubeClient(config string) (client.Client, error) {
|
func (*Utils) kubeClient(config string) (client.Client, error) {
|
||||||
cfg, err := clientcmd.BuildConfigFromFlags("", config)
|
cfg, err := clientcmd.BuildConfigFromFlags("", config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("kubernetes client initialization failed: %w", err)
|
return nil, fmt.Errorf("Kubernetes client initialization failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
@@ -107,7 +123,7 @@ func (*Utils) kubeClient(config string) (client.Client, error) {
|
|||||||
Scheme: scheme,
|
Scheme: scheme,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("kubernetes client initialization failed: %w", err)
|
return nil, fmt.Errorf("Kubernetes client initialization failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return kubeClient, nil
|
return kubeClient, nil
|
||||||
@@ -127,3 +143,23 @@ func (*Utils) writeFile(content, filename string) error {
|
|||||||
|
|
||||||
return file.Sync()
|
return file.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Utils) copyFile(src, dst string) error {
|
||||||
|
in, err := os.Open(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer in.Close()
|
||||||
|
|
||||||
|
out, err := os.Create(dst)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
_, err = io.Copy(out, in)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return out.Close()
|
||||||
|
}
|
||||||
|
|||||||
22
docs/_files/flux-icon.svg
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg width="64px" height="64px" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<!-- Generator: Sketch 56.3 (81716) - https://sketch.com -->
|
||||||
|
<title>flux-icon</title>
|
||||||
|
<desc>Created with Sketch.</desc>
|
||||||
|
<g id="flux-icon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||||
|
<g id="Group" transform="translate(11.000000, 2.000000)">
|
||||||
|
<path d="M0.803134615,15.7791346 C-0.246288462,15.0966346 -0.246288462,13.5602885 0.803134615,12.8783654 L20.1819808,0.279519231 C20.7554423,-0.0931730769 21.4944808,-0.0931730769 22.0679423,0.279519231 L41.4473654,12.8783654 C42.4967885,13.5602885 42.4967885,15.0966346 41.4473654,15.7791346 L22.0679423,28.3779808 C21.4944808,28.7506731 20.7554423,28.7506731 20.1819808,28.3779808 L0.803134615,15.7791346 Z" id="Fill-1" fill="#326CE5"></path>
|
||||||
|
<path d="M24.1851346,18.0023077 L25.5293654,18.0023077 C26.3145577,18.0023077 26.8055192,17.1525 26.4126346,16.4728846 L22.0084038,8.84423077 C21.6160962,8.16461538 20.63475,8.16461538 20.2418654,8.84423077 L15.8376346,16.4728846 C15.4453269,17.1525 15.9357115,18.0023077 16.7209038,18.0023077 L18.0657115,18.0023077 C18.6287885,18.0023077 19.0851346,18.4592308 19.0851346,19.0223077 L19.0851346,27.7298077 L19.9874423,28.3165385 C20.6791731,28.7665385 21.5710962,28.7665385 22.2628269,28.3165385 L23.1651346,27.7298077 L23.1651346,19.0223077 C23.1651346,18.4592308 23.6214808,18.0023077 24.1851346,18.0023077" id="Fill-3" fill="#C1D2F7"></path>
|
||||||
|
<path d="M27.8390769,34.8375577 L23.1648462,31.7989038 L23.1648462,33.2389038 C24.6902308,33.8919808 26.2588846,34.4008269 27.8390769,34.8375577" id="Fill-5" fill="#326CE5"></path>
|
||||||
|
<path d="M23.1650769,35.8280192 L23.1650769,37.8495577 C24.7095,38.3209038 26.2723846,38.7080192 27.8191154,39.0893654 C32.8706538,40.3349423 37.6418077,41.5107115 41.4783462,45.3478269 C41.6733462,45.54225 41.8562308,45.7407115 42.0373846,45.93975 C42.4308462,45.1880192 42.2335385,44.1957115 41.4466154,43.6845577 L33.8560385,38.7489808 C32.0133462,38.1409038 30.1360385,37.6759038 28.2806538,37.2189808 C26.5308462,36.7874423 24.8196923,36.3570577 23.1650769,35.8280192" id="Fill-7" fill="#326CE5"></path>
|
||||||
|
<path d="M19.08525,34.1699423 C18.4304423,33.8318654 17.7854423,33.4689808 17.1629423,33.0489808 L15.4269808,34.1774423 C16.5975577,35.0382115 17.8235192,35.7362885 19.08525,36.3212885 L19.08525,34.1699423 Z" id="Fill-9" fill="#326CE5"></path>
|
||||||
|
<path d="M24.8941731,40.6051154 C24.3137885,40.4620385 23.7374423,40.3195385 23.1651346,40.1735769 L23.1651346,42.1605 C23.5885962,42.2666538 24.0114808,42.3722308 24.4326346,42.4760769 C29.4841731,43.7210769 34.2553269,44.8968462 38.0924423,48.7339615 C38.0987885,48.7408846 38.1045577,48.7472308 38.1114808,48.7541538 L39.75225,47.6868462 C39.6524423,47.5824231 39.5584038,47.4751154 39.4545577,47.3718462 C35.2384038,43.1551154 29.9791731,41.8587692 24.8941731,40.6051154" id="Fill-11" fill="#326CE5"></path>
|
||||||
|
<path d="M19.08525,38.9907115 C16.8900577,38.2389808 14.8096731,37.2714808 12.9115962,35.8124423 L11.2119808,36.9178269 C13.6287115,38.9110962 16.3194808,40.1203269 19.08525,41.0168654 L19.08525,38.9907115 Z" id="Fill-13" fill="#326CE5"></path>
|
||||||
|
<path d="M19.08525,43.3809808 C15.3069808,42.3909808 11.7537115,41.18175 8.71794231,38.5388654 L7.04717308,39.6252115 C10.6125577,42.9102115 14.8540962,44.2832885 19.08525,45.3707885 L19.08525,43.3809808 Z" id="Fill-15" fill="#326CE5"></path>
|
||||||
|
<path d="M23.1650769,46.3935 C27.1175769,47.4140769 30.8341154,48.6342692 33.9823846,51.4381154 L35.6439231,50.3581154 C31.9654615,46.9000385 27.5514231,45.5194615 23.1650769,44.4048462 L23.1650769,46.3935 Z" id="Fill-17" fill="#326CE5"></path>
|
||||||
|
<path d="M4.57875,41.2299231 L2.92990385,42.3018462 C2.98759615,42.3612692 3.04009615,42.423 3.09951923,42.4818462 C7.31625,46.6985769 12.5743269,47.9949231 17.6599038,49.2485769 C22.0641346,50.3337692 26.2543269,51.3687692 29.7989423,54.1581923 L31.4893269,53.0591538 C27.4958654,49.6968462 22.7385577,48.5158846 18.1214423,47.3781923 C13.1206731,46.1453077 8.39567308,44.9758846 4.57875,41.2299231" id="Fill-19" fill="#326CE5"></path>
|
||||||
|
<path d="M1.07555769,44.5060962 C0.883442308,44.3139808 0.702865385,44.1184038 0.524019231,43.9216731 C-0.227711538,44.6745577 -0.139442308,45.9726346 0.80325,46.5853269 L6.50959615,50.2955192 C9.03536538,51.3409038 11.6765192,51.9945577 14.2738269,52.6349423 C18.3284423,53.6341731 22.2019038,54.5924423 25.5578654,56.9157115 L27.2834423,55.7930192 C23.4676731,52.9245577 19.0403654,51.8255192 14.7347885,50.7639808 C9.68382692,49.5189808 4.91267308,48.3432115 1.07555769,44.5060962" id="Fill-21" fill="#326CE5"></path>
|
||||||
|
<path d="M19.6441154,58.8342692 C20.0243077,59.0188846 20.3998846,59.2133077 20.7691154,59.4221538 C21.2093077,59.5150385 21.6771923,59.4383077 22.0683462,59.1838846 L23.0260385,58.5613846 C19.9493077,56.5035 16.5287308,55.461 13.1196923,54.5927308 L19.6441154,58.8342692 Z" id="Fill-23" fill="#326CE5"></path>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.1 KiB |
BIN
docs/_files/flux-icon@2x.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
docs/_files/helm-controller.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
docs/_files/kustomize-controller.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
docs/_files/notification-controller.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
docs/_files/source-controller.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
docs/_files/toolkit-icon.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
24
docs/_static/custom.css
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
@import url("https://fonts.googleapis.com/css?family=Montserrat&display=swap");
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: "Montserrat", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-logo {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
padding-top: 2px;
|
||||||
|
}
|
||||||
|
.md-logo img {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-header, .md-footer-nav {
|
||||||
|
background-image: linear-gradient(45deg, rgb(0, 150, 225) 0%, rgb(27, 141, 226) 24%, rgb(42, 125, 227) 53%, rgb(53, 112, 227) 78%, rgb(53, 112, 227) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-header-nav__title {
|
||||||
|
font-size: .85rem;
|
||||||
|
}
|
||||||
@@ -21,16 +21,16 @@ Command line utility for assembling Kubernetes CD pipelines the GitOps way.
|
|||||||
--branch=master \
|
--branch=master \
|
||||||
--interval=3m
|
--interval=3m
|
||||||
|
|
||||||
# List git sources and their status
|
# List GitRepository sources and their status
|
||||||
tk get sources git
|
tk get sources git
|
||||||
|
|
||||||
# Trigger a git sync
|
# Trigger a GitRepository source sync
|
||||||
tk sync source git webapp-latest
|
tk sync source git webapp-latest
|
||||||
|
|
||||||
# Export git sources in YAML format
|
# Export GitRepository sources in YAML format
|
||||||
tk export source git --all > sources.yaml
|
tk export source git --all > sources.yaml
|
||||||
|
|
||||||
# Create a kustomization for deploying a series of microservices
|
# Create a Kustomization for deploying a series of microservices
|
||||||
tk create kustomization webapp-dev \
|
tk create kustomization webapp-dev \
|
||||||
--source=webapp-latest \
|
--source=webapp-latest \
|
||||||
--path="./deploy/webapp/" \
|
--path="./deploy/webapp/" \
|
||||||
@@ -41,22 +41,22 @@ Command line utility for assembling Kubernetes CD pipelines the GitOps way.
|
|||||||
--health-check="Deployment/frontend.webapp" \
|
--health-check="Deployment/frontend.webapp" \
|
||||||
--health-check-timeout=2m
|
--health-check-timeout=2m
|
||||||
|
|
||||||
# Trigger a git sync and apply changes if any
|
# Trigger a git sync of the Kustomization's source and apply changes
|
||||||
tk sync kustomization webapp-dev --with-source
|
tk reconcile kustomization webapp-dev --with-source
|
||||||
|
|
||||||
# Suspend a kustomization reconciliation
|
# Suspend a Kustomization reconciliation
|
||||||
tk suspend kustomization webapp-dev
|
tk suspend kustomization webapp-dev
|
||||||
|
|
||||||
# Export kustomizations in YAML format
|
# Export Kustomizations in YAML format
|
||||||
tk export kustomization --all > kustomizations.yaml
|
tk export kustomization --all > kustomizations.yaml
|
||||||
|
|
||||||
# Resume a kustomization reconciliation
|
# Resume a Kustomization reconciliation
|
||||||
tk resume kustomization webapp-dev
|
tk resume kustomization webapp-dev
|
||||||
|
|
||||||
# Delete a kustomization
|
# Delete a Kustomization
|
||||||
tk delete kustomization webapp-dev
|
tk delete kustomization webapp-dev
|
||||||
|
|
||||||
# Delete a git source
|
# Delete a GitRepository source
|
||||||
tk delete source git webapp-latest
|
tk delete source git webapp-latest
|
||||||
|
|
||||||
# Uninstall the toolkit and delete CRDs
|
# Uninstall the toolkit and delete CRDs
|
||||||
@@ -67,27 +67,25 @@ Command line utility for assembling Kubernetes CD pipelines the GitOps way.
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
-h, --help help for tk
|
||||||
-h, --help help for tk
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk bootstrap](tk_bootstrap.md) - Bootstrap commands
|
* [tk bootstrap](tk_bootstrap.md) - Bootstrap toolkit components
|
||||||
* [tk check](tk_check.md) - Check requirements and installation
|
* [tk check](tk_check.md) - Check requirements and installation
|
||||||
* [tk completion](tk_completion.md) - Generates bash completion scripts
|
* [tk completion](tk_completion.md) - Generates bash completion scripts
|
||||||
* [tk create](tk_create.md) - Create commands
|
* [tk create](tk_create.md) - Create or update sources and resources
|
||||||
* [tk delete](tk_delete.md) - Delete commands
|
* [tk delete](tk_delete.md) - Delete sources and resources
|
||||||
* [tk export](tk_export.md) - Export commands
|
* [tk export](tk_export.md) - Export resources in YAML format
|
||||||
* [tk get](tk_get.md) - Get commands
|
* [tk get](tk_get.md) - Get sources and resources
|
||||||
* [tk install](tk_install.md) - Install the toolkit components
|
* [tk install](tk_install.md) - Install the toolkit components
|
||||||
* [tk resume](tk_resume.md) - Resume commands
|
* [tk reconcile](tk_reconcile.md) - Reconcile sources and resources
|
||||||
* [tk suspend](tk_suspend.md) - Suspend commands
|
* [tk resume](tk_resume.md) - Resume suspended resources
|
||||||
* [tk sync](tk_sync.md) - Synchronize commands
|
* [tk suspend](tk_suspend.md) - Suspend resources
|
||||||
* [tk uninstall](tk_uninstall.md) - Uninstall the toolkit components
|
* [tk uninstall](tk_uninstall.md) - Uninstall the toolkit components
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
## tk bootstrap
|
## tk bootstrap
|
||||||
|
|
||||||
Bootstrap commands
|
Bootstrap toolkit components
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Bootstrap commands
|
The bootstrap sub-commands bootstrap the toolkit components on the targeted Git provider.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help help for bootstrap
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
--version string toolkit tag or branch (default "master")
|
-h, --help help for bootstrap
|
||||||
|
-v, --version string toolkit version (default "latest")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk bootstrap github](tk_bootstrap_github.md) - Bootstrap GitHub repository
|
* [tk bootstrap github](tk_bootstrap_github.md) - Bootstrap toolkit components in a GitHub repository
|
||||||
|
* [tk bootstrap gitlab](tk_bootstrap_gitlab.md) - Bootstrap toolkit components in a GitLab repository
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
## tk bootstrap github
|
## tk bootstrap github
|
||||||
|
|
||||||
Bootstrap GitHub repository
|
Bootstrap toolkit components in a GitHub repository
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
The bootstrap github command creates the GitHub repository if it doesn't exists and
|
||||||
The bootstrap command creates the GitHub repository if it doesn't exists and
|
|
||||||
commits the toolkit components manifests to the master branch.
|
commits the toolkit components manifests to the master branch.
|
||||||
Then it configure the target cluster to synchronize with the repository.
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
If the toolkit components are present on the cluster,
|
If the toolkit components are present on the cluster,
|
||||||
the bootstrap command will perform an upgrade if needed.
|
the bootstrap command will perform an upgrade if needed.
|
||||||
|
|
||||||
@@ -24,6 +23,12 @@ tk bootstrap github [flags]
|
|||||||
# Run bootstrap for a private repo owned by a GitHub organization
|
# Run bootstrap for a private repo owned by a GitHub organization
|
||||||
bootstrap github --owner=<organization> --repository=<repo name>
|
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>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster
|
||||||
|
|
||||||
# Run bootstrap for a public repository on a personal account
|
# Run bootstrap for a public repository on a personal account
|
||||||
bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true
|
bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true
|
||||||
|
|
||||||
@@ -39,24 +44,25 @@ tk bootstrap github [flags]
|
|||||||
--hostname string GitHub hostname (default "github.com")
|
--hostname string GitHub hostname (default "github.com")
|
||||||
--interval duration sync interval (default 1m0s)
|
--interval duration sync interval (default 1m0s)
|
||||||
--owner string GitHub user or organization name
|
--owner string GitHub user or organization name
|
||||||
|
--path string repository path, when specified the cluster sync will be scoped to this path
|
||||||
--personal is personal repository
|
--personal is personal repository
|
||||||
--private is private repository (default true)
|
--private is private repository (default true)
|
||||||
--repository string GitHub repository name
|
--repository string GitHub repository name
|
||||||
|
--team stringArray GitHub team to be given maintainer access
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--verbose print generated objects
|
--verbose print generated objects
|
||||||
--version string toolkit tag or branch (default "master")
|
-v, --version string toolkit version (default "latest")
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk bootstrap](tk_bootstrap.md) - Bootstrap commands
|
* [tk bootstrap](tk_bootstrap.md) - Bootstrap toolkit components
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
64
docs/cmd/tk_bootstrap_gitlab.md
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
## tk bootstrap gitlab
|
||||||
|
|
||||||
|
Bootstrap toolkit components in a GitLab repository
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The bootstrap gitlab command creates the GitLab repository if it doesn't exists and
|
||||||
|
commits the toolkit components manifests to the master branch.
|
||||||
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
|
If the toolkit components are present on the cluster,
|
||||||
|
the bootstrap command will perform an upgrade if needed.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk bootstrap gitlab [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Create a GitLab API token and export it as an env var
|
||||||
|
export GITLAB_TOKEN=<my-token>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repo owned by a GitLab group
|
||||||
|
bootstrap gitlab --owner=<group> --repository=<repo name>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
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
|
||||||
|
|
||||||
|
# Run bootstrap for a private repo hosted on a GitLab server
|
||||||
|
bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for gitlab
|
||||||
|
--hostname string GitLab hostname (default "gitlab.com")
|
||||||
|
--interval duration sync interval (default 1m0s)
|
||||||
|
--owner string GitLab user or group name
|
||||||
|
--path string repository path, when specified the cluster sync will be scoped to this path
|
||||||
|
--personal is personal repository
|
||||||
|
--private is private repository (default true)
|
||||||
|
--repository string GitLab repository name
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
|
--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
|
||||||
|
-v, --version string toolkit version (default "latest")
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [tk bootstrap](tk_bootstrap.md) - Bootstrap toolkit components
|
||||||
|
|
||||||
@@ -4,7 +4,6 @@ Check requirements and installation
|
|||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
|
||||||
The check command will perform a series of checks to validate that
|
The check command will perform a series of checks to validate that
|
||||||
the local environment is configured correctly and if the installed components are healthy.
|
the local environment is configured correctly and if the installed components are healthy.
|
||||||
|
|
||||||
@@ -16,32 +15,31 @@ tk check [flags]
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Run pre-installation checks
|
# Run pre-installation checks
|
||||||
check --pre
|
tk check --pre
|
||||||
|
|
||||||
# Run installation checks
|
# Run installation checks
|
||||||
check
|
tk check
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help help for check
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
--pre only run pre-installation checks
|
-h, --help help for check
|
||||||
|
--pre only run pre-installation checks
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -33,15 +33,13 @@ To configure your bash shell to load completions for each session add to your ba
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
## tk create
|
## tk create
|
||||||
|
|
||||||
Create commands
|
Create or update sources and resources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Create commands
|
The create sub-commands generate sources and resources.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--export export in yaml format to stdout
|
--export export in YAML format to stdout
|
||||||
-h, --help help for create
|
-h, --help help for create
|
||||||
--interval duration source sync interval (default 1m0s)
|
--interval duration source sync interval (default 1m0s)
|
||||||
```
|
```
|
||||||
@@ -17,17 +17,15 @@ Create commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk create kustomization](tk_create_kustomization.md) - Create or update a kustomization resource
|
* [tk create kustomization](tk_create_kustomization.md) - Create or update a Kustomization resource
|
||||||
* [tk create source](tk_create_source.md) - Create source commands
|
* [tk create source](tk_create_source.md) - Create or update sources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
## tk create kustomization
|
## tk create kustomization
|
||||||
|
|
||||||
Create or update a kustomization resource
|
Create or update a Kustomization resource
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
The kustomization source create command generates a Kustomize resource for a given GitRepository source.
|
||||||
The kustomization source command generates a kustomization.kustomize.fluxcd.io resource for a given GitRepository source.
|
|
||||||
API spec: https://github.com/fluxcd/kustomize-controller/tree/master/docs/spec/v1alpha1
|
|
||||||
|
|
||||||
```
|
```
|
||||||
tk create kustomization [name] [flags]
|
tk create kustomization [name] [flags]
|
||||||
@@ -15,7 +13,7 @@ tk create kustomization [name] [flags]
|
|||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
# Create a kustomization from a source at a given path
|
# Create a Kustomization resource from a source at a given path
|
||||||
create kustomization contour \
|
create kustomization contour \
|
||||||
--source=contour \
|
--source=contour \
|
||||||
--path="./examples/contour/" \
|
--path="./examples/contour/" \
|
||||||
@@ -26,7 +24,7 @@ tk create kustomization [name] [flags]
|
|||||||
--health-check="DaemonSet/envoy.projectcontour" \
|
--health-check="DaemonSet/envoy.projectcontour" \
|
||||||
--health-check-timeout=3m
|
--health-check-timeout=3m
|
||||||
|
|
||||||
# Create a kustomization that depends on the previous one
|
# Create a Kustomization resource that depends on the previous one
|
||||||
create kustomization webapp \
|
create kustomization webapp \
|
||||||
--depends-on=contour \
|
--depends-on=contour \
|
||||||
--source=webapp \
|
--source=webapp \
|
||||||
@@ -35,7 +33,7 @@ tk create kustomization [name] [flags]
|
|||||||
--interval=5m \
|
--interval=5m \
|
||||||
--validate=client
|
--validate=client
|
||||||
|
|
||||||
# Create a kustomization that runs under a service account
|
# Create a Kustomization resource that runs under a service account
|
||||||
create kustomization webapp \
|
create kustomization webapp \
|
||||||
--source=webapp \
|
--source=webapp \
|
||||||
--path="./deploy/overlays/staging" \
|
--path="./deploy/overlays/staging" \
|
||||||
@@ -50,11 +48,11 @@ tk create kustomization [name] [flags]
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--depends-on stringArray kustomization that must be ready before this kustomization can be applied
|
--depends-on stringArray Kustomization that must be ready before this Kustomization can be applied
|
||||||
--health-check stringArray workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'
|
--health-check stringArray workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'
|
||||||
--health-check-timeout duration timeout of health checking operations (default 2m0s)
|
--health-check-timeout duration timeout of health checking operations (default 2m0s)
|
||||||
-h, --help help for kustomization
|
-h, --help help for kustomization
|
||||||
--path string path to the directory containing the kustomization file (default "./")
|
--path string path to the directory containing the Kustomization file (default "./")
|
||||||
--prune enable garbage collection
|
--prune enable garbage collection
|
||||||
--sa-name string service account name
|
--sa-name string service account name
|
||||||
--sa-namespace string service account namespace
|
--sa-namespace string service account namespace
|
||||||
@@ -65,17 +63,15 @@ tk create kustomization [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--export export in YAML format to stdout
|
||||||
--export export in yaml format to stdout
|
--interval duration source sync interval (default 1m0s)
|
||||||
--interval duration source sync interval (default 1m0s)
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk create](tk_create.md) - Create commands
|
* [tk create](tk_create.md) - Create or update sources and resources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk create source
|
## tk create source
|
||||||
|
|
||||||
Create source commands
|
Create or update sources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Create source commands
|
The create source sub-commands generate sources.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -15,18 +15,16 @@ Create source commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--export export in YAML format to stdout
|
||||||
--export export in yaml format to stdout
|
--interval duration source sync interval (default 1m0s)
|
||||||
--interval duration source sync interval (default 1m0s)
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk create](tk_create.md) - Create commands
|
* [tk create](tk_create.md) - Create or update sources and resources
|
||||||
* [tk create source git](tk_create_source_git.md) - Create or update a git source
|
* [tk create source git](tk_create_source_git.md) - Create or update a GitRepository source
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
## tk create source git
|
## tk create source git
|
||||||
|
|
||||||
Create or update a git source
|
Create or update a GitRepository source
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
|
||||||
The create source command generates a GitRepository resource and waits for it to sync.
|
The create source git command generates a GitRepository resource and waits for it to sync.
|
||||||
For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret.
|
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.
|
For private Git repositories, the basic authentication credentials are stored in a Kubernetes secret.
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ tk create source git [name] [flags]
|
|||||||
--branch string git branch (default "master")
|
--branch string git branch (default "master")
|
||||||
-h, --help help for git
|
-h, --help help for git
|
||||||
-p, --password string basic authentication password
|
-p, --password string basic authentication password
|
||||||
--ssh-ecdsa-curve ecdsaCurve SSH ECDSA public key curve (p521, p256, p384) (default p384)
|
--ssh-ecdsa-curve ecdsaCurve SSH ECDSA public key curve (p256, p384, p521) (default p384)
|
||||||
--ssh-key-algorithm publicKeyAlgorithm SSH public key algorithm (rsa, ecdsa, ed25519) (default rsa)
|
--ssh-key-algorithm publicKeyAlgorithm SSH public key algorithm (rsa, ecdsa, ed25519) (default rsa)
|
||||||
--ssh-rsa-bits rsaKeyBits SSH RSA public key bit size (multiplies of 8) (default 2048)
|
--ssh-rsa-bits rsaKeyBits SSH RSA public key bit size (multiplies of 8) (default 2048)
|
||||||
--tag string git tag
|
--tag string git tag
|
||||||
@@ -70,17 +70,15 @@ tk create source git [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--export export in YAML format to stdout
|
||||||
--export export in yaml format to stdout
|
--interval duration source sync interval (default 1m0s)
|
||||||
--interval duration source sync interval (default 1m0s)
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk create source](tk_create_source.md) - Create source commands
|
* [tk create source](tk_create_source.md) - Create or update sources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk delete
|
## tk delete
|
||||||
|
|
||||||
Delete commands
|
Delete sources and resources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Delete commands
|
The delete sub-commands delete sources and resources.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -16,17 +16,15 @@ Delete commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk delete kustomization](tk_delete_kustomization.md) - Delete kustomization
|
* [tk delete kustomization](tk_delete_kustomization.md) - Delete a Kustomization resource
|
||||||
* [tk delete source](tk_delete_source.md) - Delete sources commands
|
* [tk delete source](tk_delete_source.md) - Delete sources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk delete kustomization
|
## tk delete kustomization
|
||||||
|
|
||||||
Delete kustomization
|
Delete a Kustomization resource
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Delete kustomization
|
The delete kustomization command deletes the given Kustomization from the cluster.
|
||||||
|
|
||||||
```
|
```
|
||||||
tk delete kustomization [name] [flags]
|
tk delete kustomization [name] [flags]
|
||||||
@@ -19,16 +19,14 @@ tk delete kustomization [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
-s, --silent delete resource without asking for confirmation
|
||||||
-s, --silent delete resource without asking for confirmation
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk delete](tk_delete.md) - Delete commands
|
* [tk delete](tk_delete.md) - Delete sources and resources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk delete source
|
## tk delete source
|
||||||
|
|
||||||
Delete sources commands
|
Delete sources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Delete sources commands
|
The delete source sub-commands delete sources.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -15,17 +15,15 @@ Delete sources commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
-s, --silent delete resource without asking for confirmation
|
||||||
-s, --silent delete resource without asking for confirmation
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk delete](tk_delete.md) - Delete commands
|
* [tk delete](tk_delete.md) - Delete sources and resources
|
||||||
* [tk delete source git](tk_delete_source_git.md) - Delete git source
|
* [tk delete source git](tk_delete_source_git.md) - Delete a GitRepository source
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk delete source git
|
## tk delete source git
|
||||||
|
|
||||||
Delete git source
|
Delete a GitRepository source
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Delete git source
|
The delete source git command deletes the given GitRepository from the cluster.
|
||||||
|
|
||||||
```
|
```
|
||||||
tk delete source git [name] [flags]
|
tk delete source git [name] [flags]
|
||||||
@@ -19,16 +19,14 @@ tk delete source git [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
-s, --silent delete resource without asking for confirmation
|
||||||
-s, --silent delete resource without asking for confirmation
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk delete source](tk_delete_source.md) - Delete sources commands
|
* [tk delete source](tk_delete_source.md) - Delete sources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk export
|
## tk export
|
||||||
|
|
||||||
Export commands
|
Export resources in YAML format
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Export commands
|
The export sub-commands export resources in YAML format.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -16,17 +16,15 @@ Export commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk export kustomization](tk_export_kustomization.md) - Export kustomization in YAML format
|
* [tk export kustomization](tk_export_kustomization.md) - Export Kustomization resources in YAML format
|
||||||
* [tk export source](tk_export_source.md) - Export source commands
|
* [tk export source](tk_export_source.md) - Export sources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk export kustomization
|
## tk export kustomization
|
||||||
|
|
||||||
Export kustomization in YAML format
|
Export Kustomization resources in YAML format
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Export kustomization in YAML format
|
The export kustomization command exports one or all Kustomization resources in YAML format.
|
||||||
|
|
||||||
```
|
```
|
||||||
tk export kustomization [name] [flags]
|
tk export kustomization [name] [flags]
|
||||||
@@ -13,10 +13,10 @@ tk export kustomization [name] [flags]
|
|||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
# Export all kustomizations
|
# Export all Kustomization resources
|
||||||
export kustomization --all > kustomizations.yaml
|
export kustomization --all > kustomizations.yaml
|
||||||
|
|
||||||
# Export a kustomization
|
# Export a Kustomization
|
||||||
export kustomization my-app > kustomization.yaml
|
export kustomization my-app > kustomization.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -30,16 +30,14 @@ tk export kustomization [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--all select all resources
|
--all select all resources
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk export](tk_export.md) - Export commands
|
* [tk export](tk_export.md) - Export resources in YAML format
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk export source
|
## tk export source
|
||||||
|
|
||||||
Export source commands
|
Export sources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Export source commands
|
The export source sub-commands export sources in YAML format.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -16,17 +16,15 @@ Export source commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--all select all resources
|
--all select all resources
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk export](tk_export.md) - Export commands
|
* [tk export](tk_export.md) - Export resources in YAML format
|
||||||
* [tk export source git](tk_export_source_git.md) - Export git sources in YAML format
|
* [tk export source git](tk_export_source_git.md) - Export GitRepository sources in YAML format
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk export source git
|
## tk export source git
|
||||||
|
|
||||||
Export git sources in YAML format
|
Export GitRepository sources in YAML format
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Export git sources in YAML format
|
The export source git command exports on or all GitRepository sources in YAML format.
|
||||||
|
|
||||||
```
|
```
|
||||||
tk export source git [name] [flags]
|
tk export source git [name] [flags]
|
||||||
@@ -13,10 +13,10 @@ tk export source git [name] [flags]
|
|||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
# Export all git sources
|
# Export all GitRepository sources
|
||||||
export source git --all > sources.yaml
|
export source git --all > sources.yaml
|
||||||
|
|
||||||
# Export a git source including the SSH keys or basic auth credentials
|
# Export a GitRepository source including the SSH key pair or basic auth credentials
|
||||||
export source git my-private-repo --with-credentials > source.yaml
|
export source git my-private-repo --with-credentials > source.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -30,17 +30,15 @@ tk export source git [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--all select all resources
|
--all select all resources
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
--with-credentials include credential secrets
|
||||||
--with-credentials include credential secrets
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk export source](tk_export_source.md) - Export source commands
|
* [tk export source](tk_export_source.md) - Export sources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk get
|
## tk get
|
||||||
|
|
||||||
Get commands
|
Get sources and resources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Get commands
|
The get sub-commands print the statuses of sources and resources.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -15,17 +15,15 @@ Get commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk get kustomizations](tk_get_kustomizations.md) - Get kustomizations status
|
* [tk get kustomizations](tk_get_kustomizations.md) - Get Kustomization source statuses
|
||||||
* [tk get sources](tk_get_sources.md) - Get sources commands
|
* [tk get sources](tk_get_sources.md) - Get source statuses
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
## tk get kustomizations
|
## tk get kustomizations
|
||||||
|
|
||||||
Get kustomizations status
|
Get Kustomization source statuses
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
The get kustomizations command prints the statuses of the resources.
|
||||||
The get kustomizations command prints the status of the resources.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
tk get kustomizations [flags]
|
tk get kustomizations [flags]
|
||||||
@@ -20,15 +19,13 @@ tk get kustomizations [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk get](tk_get.md) - Get commands
|
* [tk get](tk_get.md) - Get sources and resources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk get sources
|
## tk get sources
|
||||||
|
|
||||||
Get sources commands
|
Get source statuses
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Get sources commands
|
The get source sub-commands print the statuses of the sources.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -15,16 +15,14 @@ Get sources commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk get](tk_get.md) - Get commands
|
* [tk get](tk_get.md) - Get sources and resources
|
||||||
* [tk get sources git](tk_get_sources_git.md) - Get git sources status
|
* [tk get sources git](tk_get_sources_git.md) - Get GitRepository source statuses
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
## tk get sources git
|
## tk get sources git
|
||||||
|
|
||||||
Get git sources status
|
Get GitRepository source statuses
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
The get sources git command prints the status of the GitRepository sources.
|
||||||
The get sources command prints the status of the git resources.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
tk get sources git [flags]
|
tk get sources git [flags]
|
||||||
@@ -20,15 +19,13 @@ tk get sources git [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk get sources](tk_get_sources.md) - Get sources commands
|
* [tk get sources](tk_get_sources.md) - Get source statuses
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ Install the toolkit components
|
|||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
|
||||||
The install command deploys the toolkit components in the specified namespace.
|
The install command deploys the toolkit components in the specified namespace.
|
||||||
If a previous version is installed, then an in-place upgrade will be performed.
|
If a previous version is installed, then an in-place upgrade will be performed.
|
||||||
|
|
||||||
@@ -16,37 +15,40 @@ tk install [flags]
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Install the latest version in the gitops-systems namespace
|
# Install the latest version in the gitops-systems namespace
|
||||||
install --version=master --namespace=gitops-systems
|
tk install --version=latest --namespace=gitops-systems
|
||||||
|
|
||||||
# Dry-run install for a specific version and a series of components
|
# Dry-run install for a specific version and a series of components
|
||||||
install --dry-run --version=0.0.1 --components="source-controller,kustomize-controller"
|
tk install --dry-run --version=v0.0.7 --components="source-controller,kustomize-controller"
|
||||||
|
|
||||||
# Dry-run install with manifests preview
|
# Dry-run install with manifests preview
|
||||||
install --dry-run --verbose
|
tk install --dry-run --verbose
|
||||||
|
|
||||||
|
# Write install manifests to file
|
||||||
|
tk install --export > gitops-system.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--dry-run only print the object that would be applied
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
-h, --help help for install
|
--dry-run only print the object that would be applied
|
||||||
--manifests string path to the manifest directory, dev only
|
--export write the install manifests to stdout and exit
|
||||||
-v, --version string toolkit tag or branch (default "master")
|
-h, --help help for install
|
||||||
|
--manifests string path to the manifest directory, dev only
|
||||||
|
-v, --version string toolkit version (default "latest")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
30
docs/cmd/tk_reconcile.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
## tk reconcile
|
||||||
|
|
||||||
|
Reconcile sources and resources
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The reconcile sub-commands trigger a reconciliation of sources and resources.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for reconcile
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
|
* [tk reconcile helmrelease](tk_reconcile_helmrelease.md) - Reconcile a HelmRelease resource
|
||||||
|
* [tk reconcile kustomization](tk_reconcile_kustomization.md) - Reconcile a Kustomization resource
|
||||||
|
* [tk reconcile source](tk_reconcile_source.md) - Reconcile sources
|
||||||
|
|
||||||
44
docs/cmd/tk_reconcile_helmrelease.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## tk reconcile helmrelease
|
||||||
|
|
||||||
|
Reconcile a HelmRelease resource
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
|
||||||
|
The reconcile kustomization command triggers a reconciliation of a HelmRelease resource and waits for it to finish.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk reconcile helmrelease [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Trigger a HelmRelease apply outside of the reconciliation interval
|
||||||
|
tk reconcile hr podinfo
|
||||||
|
|
||||||
|
# Trigger a reconciliation of the HelmRelease's source and apply changes
|
||||||
|
tk reconcile hr podinfo --with-source
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for helmrelease
|
||||||
|
--with-source reconcile HelmRelease source
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 reconcile](tk_reconcile.md) - Reconcile sources and resources
|
||||||
|
|
||||||
44
docs/cmd/tk_reconcile_kustomization.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## tk reconcile kustomization
|
||||||
|
|
||||||
|
Reconcile a Kustomization resource
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
|
||||||
|
The reconcile kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk reconcile kustomization [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Trigger a Kustomization apply outside of the reconciliation interval
|
||||||
|
tk reconcile kustomization podinfo
|
||||||
|
|
||||||
|
# Trigger a sync of the Kustomization's source and apply changes
|
||||||
|
tk reconcile kustomization podinfo --with-source
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for kustomization
|
||||||
|
--with-source reconcile kustomization source
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 reconcile](tk_reconcile.md) - Reconcile sources and resources
|
||||||
|
|
||||||
29
docs/cmd/tk_reconcile_source.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## tk reconcile source
|
||||||
|
|
||||||
|
Reconcile sources
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The reconcile source sub-commands trigger a reconciliation of sources.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for source
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 reconcile](tk_reconcile.md) - Reconcile sources and resources
|
||||||
|
* [tk reconcile source git](tk_reconcile_source_git.md) - Reconcile a GitRepository source
|
||||||
|
* [tk reconcile source helm](tk_reconcile_source_helm.md) - Reconcile a HelmRepository source
|
||||||
|
|
||||||
39
docs/cmd/tk_reconcile_source_git.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## tk reconcile source git
|
||||||
|
|
||||||
|
Reconcile a GitRepository source
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The reconcile source command triggers a reconciliation of a GitRepository resource and waits for it to finish.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk reconcile source git [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Trigger a git pull for an existing source
|
||||||
|
tk reconcile source git podinfo
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for git
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 reconcile source](tk_reconcile_source.md) - Reconcile sources
|
||||||
|
|
||||||
39
docs/cmd/tk_reconcile_source_helm.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## tk reconcile source helm
|
||||||
|
|
||||||
|
Reconcile a HelmRepository source
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The reconcile source command triggers a reconciliation of a HelmRepository resource and waits for it to finish.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk reconcile source helm [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Trigger a helm repo update for an existing source
|
||||||
|
tk reconcile 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")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [tk reconcile source](tk_reconcile_source.md) - Reconcile sources
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk resume
|
## tk resume
|
||||||
|
|
||||||
Resume commands
|
Resume suspended resources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Resume commands
|
The resume sub-commands resume a suspended resource.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -15,16 +15,15 @@ Resume commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk resume kustomization](tk_resume_kustomization.md) - Resume kustomization
|
* [tk resume helmrelease](tk_resume_helmrelease.md) - Resume a suspended HelmRelease
|
||||||
|
* [tk resume kustomization](tk_resume_kustomization.md) - Resume a suspended Kustomization
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
32
docs/cmd/tk_resume_helmrelease.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## tk resume helmrelease
|
||||||
|
|
||||||
|
Resume a suspended HelmRelease
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The resume command marks a previously suspended HelmRelease resource for reconciliation and waits for it to
|
||||||
|
finish the apply.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk resume helmrelease [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for helmrelease
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 resume](tk_resume.md) - Resume suspended resources
|
||||||
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
## tk resume kustomization
|
## tk resume kustomization
|
||||||
|
|
||||||
Resume kustomization
|
Resume a suspended Kustomization
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
The resume command marks a previously suspended Kustomization resource for reconciliation and waits for it to finish the apply.
|
The resume command marks a previously suspended Kustomization resource for reconciliation and waits for it to
|
||||||
|
finish the apply.
|
||||||
|
|
||||||
```
|
```
|
||||||
tk resume kustomization [name] [flags]
|
tk resume kustomization [name] [flags]
|
||||||
@@ -19,15 +20,13 @@ tk resume kustomization [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk resume](tk_resume.md) - Resume commands
|
* [tk resume](tk_resume.md) - Resume suspended resources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
## tk suspend
|
## tk suspend
|
||||||
|
|
||||||
Suspend commands
|
Suspend resources
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Suspend commands
|
The suspend sub-commands suspend the reconciliation of a resource.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@@ -15,16 +15,15 @@ Suspend commands
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [tk suspend kustomization](tk_suspend_kustomization.md) - Suspend kustomization
|
* [tk suspend helmrelease](tk_suspend_helmrelease.md) - Suspend reconciliation of HelmRelease
|
||||||
|
* [tk suspend kustomization](tk_suspend_kustomization.md) - Suspend reconciliation of Kustomization
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
31
docs/cmd/tk_suspend_helmrelease.md
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
## tk suspend helmrelease
|
||||||
|
|
||||||
|
Suspend reconciliation of HelmRelease
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The suspend command disables the reconciliation of a HelmRelease resource.
|
||||||
|
|
||||||
|
```
|
||||||
|
tk suspend helmrelease [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for helmrelease
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 suspend](tk_suspend.md) - Suspend resources
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
## tk suspend kustomization
|
## tk suspend kustomization
|
||||||
|
|
||||||
Suspend kustomization
|
Suspend reconciliation of Kustomization
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
@@ -19,15 +19,13 @@ tk suspend kustomization [name] [flags]
|
|||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk suspend](tk_suspend.md) - Suspend commands
|
* [tk suspend](tk_suspend.md) - Suspend resources
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
## tk sync
|
|
||||||
|
|
||||||
Synchronize commands
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Synchronize commands
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for sync
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
|
||||||
--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](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
|
||||||
* [tk sync kustomization](tk_sync_kustomization.md) - Synchronize kustomization
|
|
||||||
* [tk sync source](tk_sync_source.md) - Synchronize source commands
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
## tk sync kustomization
|
|
||||||
|
|
||||||
Synchronize kustomization
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
|
|
||||||
The sync kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.
|
|
||||||
|
|
||||||
```
|
|
||||||
tk sync kustomization [name] [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
# Trigger a kustomization apply outside of the reconciliation interval
|
|
||||||
sync kustomization podinfo
|
|
||||||
|
|
||||||
# Trigger a git sync of the kustomization source and apply changes
|
|
||||||
sync kustomization podinfo --with-source
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for kustomization
|
|
||||||
--with-source synchronize kustomization source
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
|
||||||
--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 sync](tk_sync.md) - Synchronize commands
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
## tk sync source
|
|
||||||
|
|
||||||
Synchronize source commands
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Synchronize source commands
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for source
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
|
||||||
--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 sync](tk_sync.md) - Synchronize commands
|
|
||||||
* [tk sync source git](tk_sync_source_git.md) - Synchronize git source
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
## tk sync source git
|
|
||||||
|
|
||||||
Synchronize git source
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
|
|
||||||
The sync source command triggers a reconciliation of a GitRepository resource and waits for it to finish.
|
|
||||||
|
|
||||||
```
|
|
||||||
tk sync source git [name] [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
# Trigger a git pull for an existing source
|
|
||||||
sync source git podinfo
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for git
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
|
||||||
--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 sync source](tk_sync_source.md) - Synchronize source commands
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
@@ -4,9 +4,7 @@ Uninstall the toolkit components
|
|||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
|
The uninstall command removes the namespace, cluster roles, cluster role bindings and CRDs from the cluster.
|
||||||
The uninstall command removes the namespace, cluster roles,
|
|
||||||
cluster role bindings and CRDs.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
tk uninstall [flags]
|
tk uninstall [flags]
|
||||||
@@ -26,24 +24,23 @@ tk uninstall [flags]
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--crds removes all CRDs previously installed
|
--crds removes all CRDs previously installed
|
||||||
--dry-run only print the object that would be deleted
|
--dry-run only print the object that would be deleted
|
||||||
-h, --help help for uninstall
|
-h, --help help for uninstall
|
||||||
-s, --silent delete components without asking for confirmation
|
--kustomizations removes all Kustomizations previously installed
|
||||||
|
-s, --silent delete components without asking for confirmation
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--verbose print generated objects
|
||||||
--verbose print generated objects
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Jun-2020
|
|
||||||
|
|||||||
25
docs/components/helm/controller.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Helm Controller
|
||||||
|
|
||||||
|
The Helm Controller is a Kubernetes operator, allowing one to declaratively manage Helm chart
|
||||||
|
releases with Kubernetes manifests.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The desired state of a Helm release is described through a Kubernetes Custom Resource named `HelmRelease`.
|
||||||
|
Based on the creation, mutation or removal of a HelmRelease resource in the cluster,
|
||||||
|
Helm actions are performed by the controller.
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
- Watches for `HelmRelease` objects and generates `HelmChart` objects
|
||||||
|
- Fetches artifacts produced by [source-controller](../source/controller.md) from `HelmChart` objects
|
||||||
|
- Watches `HelmChart` objects for revision changes (semver ranges)
|
||||||
|
- Performs Helm v3 actions including Helm tests as configured in the `HelmRelease` objects
|
||||||
|
- Runs Helm install/upgrade in a specific order, taking into account the depends-on relationship
|
||||||
|
- Prunes Helm releases removed from cluster (garbage collection)
|
||||||
|
- Reports Helm releases status (alerting provided by [notification-controller](../notification/controller.md))
|
||||||
|
|
||||||
|
Links:
|
||||||
|
|
||||||
|
- Source code [fluxcd/helm-controller](https://github.com/fluxcd/helm-controller)
|
||||||
|
- Specification [docs](https://github.com/fluxcd/helm-controller/tree/master/docs/spec)
|
||||||
23
docs/components/kustomize/controller.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Kustomize Controller
|
||||||
|
|
||||||
|
The kustomize-controller is a Kubernetes operator,
|
||||||
|
specialized in running continuous delivery pipelines for infrastructure and
|
||||||
|
workloads defined with Kubernetes manifests and assembled with Kustomize.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
- Reconciles the cluster state from multiple sources (provided by source-controller)
|
||||||
|
- Generates manifests with Kustomize (from plain Kubernetes yamls or Kustomize overlays)
|
||||||
|
- Validates manifests against Kubernetes API
|
||||||
|
- Impersonates service accounts (multi-tenancy RBAC)
|
||||||
|
- Health assessment of the deployed workloads
|
||||||
|
- Runs pipelines in a specific order (depends-on relationship)
|
||||||
|
- Prunes objects removed from source (garbage collection)
|
||||||
|
- Reports cluster state changes (alerting provided by notification-controller)
|
||||||
|
|
||||||
|
Links:
|
||||||
|
|
||||||
|
- Source code [fluxcd/kustomize-controller](https://github.com/fluxcd/kustomize-controller)
|
||||||
|
- Specification [docs](https://github.com/fluxcd/kustomize-controller/tree/master/docs/spec)
|
||||||