Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
422724bd2d | ||
|
|
6cb7897f25 | ||
|
|
499ba15004 | ||
|
|
b04abe989e | ||
|
|
ea576179f9 |
54
.github/workflows/release.yaml
vendored
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 }}
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@
|
|||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
bin/
|
bin/
|
||||||
|
output/
|
||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"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"
|
||||||
@@ -43,11 +44,15 @@ If a previous version is installed, then an in-place upgrade will be performed.`
|
|||||||
|
|
||||||
# Dry-run install with manifests preview
|
# Dry-run install with manifests preview
|
||||||
tk 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
|
||||||
@@ -55,6 +60,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
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", defaultVersion,
|
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaultVersion,
|
||||||
@@ -84,7 +91,9 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
if !installExport {
|
||||||
logger.Generatef("generating manifests")
|
logger.Generatef("generating manifests")
|
||||||
|
}
|
||||||
if kustomizePath == "" {
|
if kustomizePath == "" {
|
||||||
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
|
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -104,6 +113,12 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.Successf("manifests build completed")
|
logger.Successf("manifests build completed")
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ tk install [flags]
|
|||||||
# Dry-run install with manifests preview
|
# Dry-run install with manifests preview
|
||||||
tk install --dry-run --verbose
|
tk install --dry-run --verbose
|
||||||
|
|
||||||
|
# Write install manifests to file
|
||||||
|
tk install --export > gitops-system.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
@@ -30,6 +33,7 @@ tk install [flags]
|
|||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
--dry-run only print the object that would be applied
|
--dry-run only print the object that would be applied
|
||||||
|
--export write the install manifests to stdout and exit
|
||||||
-h, --help help for install
|
-h, --help help for install
|
||||||
--manifests string path to the manifest directory, dev only
|
--manifests string path to the manifest directory, dev only
|
||||||
-v, --version string toolkit tag or branch (default "master")
|
-v, --version string toolkit tag or branch (default "master")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Manage Helm releases
|
# Manage Helm Releases
|
||||||
|
|
||||||
The [helm-controller](../components/helm/controller.md) allows you to
|
The [helm-controller](../components/helm/controller.md) allows you to
|
||||||
declaratively manage Helm chart releases with Kubernetes manifests.
|
declaratively manage Helm chart releases with Kubernetes manifests.
|
||||||
@@ -93,7 +93,7 @@ helm-controller.
|
|||||||
See the [`HelmRelease` CRD docs](../components/helm/helmreleases.md)
|
See the [`HelmRelease` CRD docs](../components/helm/helmreleases.md)
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
## Receive notifications
|
## Configure notifications
|
||||||
|
|
||||||
The default toolkit installation configures the helm-controller to
|
The default toolkit installation configures the helm-controller to
|
||||||
broadcast events to the [notification-controller](../components/notification/controller.md).
|
broadcast events to the [notification-controller](../components/notification/controller.md).
|
||||||
@@ -126,3 +126,67 @@ apiVersion: notification.fluxcd.io/v1alpha1
|
|||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Configure webhook receivers
|
||||||
|
|
||||||
|
When using semver ranges for Helm releases, you may want to trigger an update
|
||||||
|
as soon as a new chart version is published to your Helm repository.
|
||||||
|
In order to notify source-controller about a chart update,
|
||||||
|
you can [setup webhook receivers](webhook-receivers.md).
|
||||||
|
|
||||||
|
First generate a random string and create a secret with a `token` field:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
TOKEN=$(head -c 12 /dev/urandom | shasum | cut -d ' ' -f1)
|
||||||
|
echo $TOKEN
|
||||||
|
|
||||||
|
kubectl -n gitops-system create secret generic webhook-token \
|
||||||
|
--from-literal=token=$TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
When using [Harbor](https://goharbor.io/) as your Helm repository, you can define a receiver with:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: notification.fluxcd.io/v1alpha1
|
||||||
|
kind: Receiver
|
||||||
|
metadata:
|
||||||
|
name: helm-podinfo
|
||||||
|
namespace: gitops-system
|
||||||
|
spec:
|
||||||
|
type: harbor
|
||||||
|
secretRef:
|
||||||
|
name: webhook-token
|
||||||
|
resources:
|
||||||
|
- kind: HelmRepository
|
||||||
|
name: podinfo
|
||||||
|
```
|
||||||
|
|
||||||
|
The notification-controller generates a unique URL using the provided token and the receiver name/namespace.
|
||||||
|
|
||||||
|
Find the URL with:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ kubectl -n gitops-system get receiver/helm-podinfo
|
||||||
|
|
||||||
|
NAME READY STATUS
|
||||||
|
helm-podinfo True Receiver initialised with URL: /hook/bed6d00b5555b1603e1f59b94d7fdbca58089cb5663633fb83f2815dc626d92b
|
||||||
|
```
|
||||||
|
|
||||||
|
Log in to the Harbor interface, go to Projects, select a project, and select Webhooks.
|
||||||
|
Fill the form with:
|
||||||
|
|
||||||
|
* Endpoint URL: compose the address using the receiver LB and the generated URL `http://<LoadBalancerAddress>/<ReceiverURL>`
|
||||||
|
* Auth Header: use the `token` string
|
||||||
|
|
||||||
|
With the above settings, when you upload a chart, the following happens:
|
||||||
|
|
||||||
|
* Harbor sends the chart push event to the receiver address
|
||||||
|
* Notification controller validates the authenticity of the payload using the auth header
|
||||||
|
* Source controller is notified about the changes
|
||||||
|
* Source controller pulls the changes into the cluster and updates the `HelmChart` version
|
||||||
|
* Helm controller is notified about the version change and upgrades the release
|
||||||
|
|
||||||
|
!!! hint "Note"
|
||||||
|
Besides Harbor, you can define receivers for **GitHub**, **GitLab**, **Bitbucket**
|
||||||
|
and any other system that supports webhooks e.g. Jenkins, CircleCI, etc.
|
||||||
|
See the [Receiver CRD docs](../components/notification/receiver.md) for more details.
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ nav:
|
|||||||
- Introduction: index.md
|
- Introduction: index.md
|
||||||
- Get Started: get-started/index.md
|
- Get Started: get-started/index.md
|
||||||
- Guides:
|
- Guides:
|
||||||
- Manage Helm releases: guides/helmreleases.md
|
- Manage Helm Releases: guides/helmreleases.md
|
||||||
- Setup Notifications: guides/notifications.md
|
- Setup Notifications: guides/notifications.md
|
||||||
- Setup Webhook Receivers: guides/webhook-receivers.md
|
- Setup Webhook Receivers: guides/webhook-receivers.md
|
||||||
- Toolkit Components:
|
- Toolkit Components:
|
||||||
|
|||||||
Reference in New Issue
Block a user