Merge pull request #31 from fluxcd/spec-sync
docs: Sync specification with API
This commit is contained in:
commit
4304bbee26
|
@ -11,3 +11,8 @@ type Source interface {
|
||||||
// GetInterval returns the interval at which the source is updated.
|
// GetInterval returns the interval at which the source is updated.
|
||||||
GetInterval() metav1.Duration
|
GetInterval() metav1.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// SyncAtAnnotation is the timestamp corresponding to an on-demand source sync.
|
||||||
|
SyncAtAnnotation string = "source.fluxcd.io/syncAt"
|
||||||
|
)
|
||||||
|
|
|
@ -24,6 +24,8 @@ import (
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/event"
|
"sigs.k8s.io/controller-runtime/pkg/event"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SourceChangePredicate struct {
|
type SourceChangePredicate struct {
|
||||||
|
@ -43,8 +45,8 @@ func (SourceChangePredicate) Update(e event.UpdateEvent) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle force sync
|
// handle force sync
|
||||||
if val, ok := e.MetaNew.GetAnnotations()[ForceSyncAnnotation]; ok {
|
if val, ok := e.MetaNew.GetAnnotations()[sourcev1.SyncAtAnnotation]; ok {
|
||||||
if valOld, okOld := e.MetaOld.GetAnnotations()[ForceSyncAnnotation]; okOld {
|
if valOld, okOld := e.MetaOld.GetAnnotations()[sourcev1.SyncAtAnnotation]; okOld {
|
||||||
if val != valOld {
|
if val != valOld {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -56,10 +58,6 @@ func (SourceChangePredicate) Update(e event.UpdateEvent) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
ForceSyncAnnotation string = "source.fluxcd.io/syncAt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GarbageCollectPredicate struct {
|
type GarbageCollectPredicate struct {
|
||||||
predicate.Funcs
|
predicate.Funcs
|
||||||
Scheme *runtime.Scheme
|
Scheme *runtime.Scheme
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# source.fluxcd.io/v1alpha1
|
# source.fluxcd.io/v1alpha1
|
||||||
|
|
||||||
The is the v1alpha1 API specification for defining the desired state sources of Kubernetes clusters.
|
This is the v1alpha1 API specification for defining the desired state sources of Kubernetes clusters.
|
||||||
|
|
||||||
## Specification
|
## Specification
|
||||||
|
|
||||||
|
@ -12,4 +12,8 @@ The is the v1alpha1 API specification for defining the desired state sources of
|
||||||
|
|
||||||
## Implementation
|
## Implementation
|
||||||
|
|
||||||
* source-controller [v0.0.1-alpha.1](https://github.com/fluxcd/source-controller/releases)
|
* [source-controller](https://github.com/fluxcd/source-controller/)
|
||||||
|
|
||||||
|
## Consumers
|
||||||
|
|
||||||
|
* [kustomize-controller](https://github.com/fluxcd/kustomize-controller/)
|
|
@ -37,12 +37,12 @@ The controller can be told to check for updates right away by setting an annotat
|
||||||
|
|
||||||
```go
|
```go
|
||||||
const (
|
const (
|
||||||
// ForceSyncAnnotation is the timestamp corresponding to an on-demand source sync.
|
// SyncAtAnnotation is the timestamp corresponding to an on-demand source sync.
|
||||||
ForceSyncAnnotation string = "source.fluxcd.io/syncAt"
|
SyncAtAnnotation string = "source.fluxcd.io/syncAt"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Force sync example:
|
Trigger source sync example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl annotate --overwrite gitrepository/podinfo source.fluxcd.io/syncAt="$(date +%s)"
|
kubectl annotate --overwrite gitrepository/podinfo source.fluxcd.io/syncAt="$(date +%s)"
|
||||||
|
@ -143,4 +143,4 @@ const (
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
See the [Git repository](gitrepositories.md) and [Helm chart](helmrepositories.md) APIs.
|
See the [Git repository](gitrepositories.md) and [Helm chart](helmcharts.md) APIs.
|
||||||
|
|
|
@ -297,17 +297,17 @@ Successful sync:
|
||||||
status:
|
status:
|
||||||
artifact:
|
artifact:
|
||||||
lastUpdateTime: "2020-04-07T06:59:23Z"
|
lastUpdateTime: "2020-04-07T06:59:23Z"
|
||||||
path: /data/gitrepository/podinfo-default/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
|
path: /data/gitrepository/default/podinfo/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
|
||||||
revision: master/363a6a8fe6a7f13e05d34c163b0ef02a777da20a
|
revision: master/363a6a8fe6a7f13e05d34c163b0ef02a777da20a
|
||||||
url: http://<host>/gitrepository/podinfo-default/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
|
url: http://<host>/gitrepository/default/podinfo/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
|
||||||
conditions:
|
conditions:
|
||||||
- lastTransitionTime: "2020-04-07T06:59:23Z"
|
- lastTransitionTime: "2020-04-07T06:59:23Z"
|
||||||
message: 'Fetched artifacts are available at
|
message: 'Git repoistory artifacts are available at:
|
||||||
/data/gitrepository/podinfo-default/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz'
|
/data/gitrepository/default/podinfo/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz'
|
||||||
reason: GitOperationSucceed
|
reason: GitOperationSucceed
|
||||||
status: "True"
|
status: "True"
|
||||||
type: Ready
|
type: Ready
|
||||||
url: http://<host>/gitrepository/podinfo-default/latest.tar.gz
|
url: http://<host>/gitrepository/default/podinfo/latest.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
Failed authentication:
|
Failed authentication:
|
||||||
|
@ -335,7 +335,7 @@ status:
|
||||||
type: Ready
|
type: Ready
|
||||||
```
|
```
|
||||||
|
|
||||||
Wait for condition:
|
Wait for ready condition:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl wait gitrepository/podinfo --for=condition=ready --timeout=1m
|
kubectl wait gitrepository/podinfo --for=condition=ready --timeout=1m
|
||||||
|
|
|
@ -66,7 +66,7 @@ const (
|
||||||
|
|
||||||
## Spec examples
|
## Spec examples
|
||||||
|
|
||||||
Pinned version:
|
Pull a specific chart version every five minutes:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: source.fluxcd.io/v1alpha1
|
apiVersion: source.fluxcd.io/v1alpha1
|
||||||
|
@ -82,9 +82,10 @@ spec:
|
||||||
version: 10.5.7
|
version: 10.5.7
|
||||||
helmRepositoryRef:
|
helmRepositoryRef:
|
||||||
name: stable
|
name: stable
|
||||||
|
interval: 5m
|
||||||
```
|
```
|
||||||
|
|
||||||
Semver range:
|
Pull the latest chart version that matches the sermver range every ten minutes:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: source.fluxcd.io/v1alpha1
|
apiVersion: source.fluxcd.io/v1alpha1
|
||||||
|
@ -97,22 +98,7 @@ spec:
|
||||||
version: ^10.0.0
|
version: ^10.0.0
|
||||||
helmRepositoryRef:
|
helmRepositoryRef:
|
||||||
name: stable
|
name: stable
|
||||||
```
|
interval: 10m
|
||||||
|
|
||||||
Interval:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: source.fluxcd.io/v1alpha1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: redis
|
|
||||||
namespace: default
|
|
||||||
spec:
|
|
||||||
name: redis
|
|
||||||
version: ^10.0.0
|
|
||||||
helmRepositoryRef:
|
|
||||||
name: stable
|
|
||||||
interval: 30m
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Status examples
|
## Status examples
|
||||||
|
@ -121,10 +107,10 @@ Successful chart pull:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
status:
|
status:
|
||||||
url: http://<host>/helmcharts/redis-default/redis-10.5.7.tgz
|
url: http://<host>/helmchart/default/redis/redis-10.5.7.tgz
|
||||||
conditions:
|
conditions:
|
||||||
- lastTransitionTime: "2020-04-10T09:34:45Z"
|
- lastTransitionTime: "2020-04-10T09:34:45Z"
|
||||||
message: Fetched artifact are available at /data/helmcharts/redis-default/redis-10.5.7.tgz
|
message: Helm chart is available at /data/helmchart/default/redis/redis-10.5.7.tgz
|
||||||
reason: ChartPullSucceeded
|
reason: ChartPullSucceeded
|
||||||
status: "True"
|
status: "True"
|
||||||
type: Ready
|
type: Ready
|
||||||
|
@ -136,8 +122,14 @@ Failed chart pull:
|
||||||
status:
|
status:
|
||||||
conditions:
|
conditions:
|
||||||
- lastTransitionTime: "2020-04-10T09:34:45Z"
|
- lastTransitionTime: "2020-04-10T09:34:45Z"
|
||||||
message: ''
|
message: 'invalid chart URL format'
|
||||||
reason: ChartPullFailed
|
reason: ChartPullFailed
|
||||||
status: "False"
|
status: "False"
|
||||||
type: Ready
|
type: Ready
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Wait for ready condition:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl wait helmchart/redis --for=condition=ready --timeout=1m
|
||||||
|
```
|
||||||
|
|
|
@ -64,7 +64,7 @@ const (
|
||||||
|
|
||||||
## Spec examples
|
## Spec examples
|
||||||
|
|
||||||
Public Helm repository:
|
Pull the index of a public Helm repository every ten minutes:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: source.fluxcd.io/v1alpha1
|
apiVersion: source.fluxcd.io/v1alpha1
|
||||||
|
@ -72,15 +72,12 @@ kind: HelmRepository
|
||||||
metadata:
|
metadata:
|
||||||
name: stable
|
name: stable
|
||||||
namespace: default
|
namespace: default
|
||||||
annotations:
|
|
||||||
# force sync trigger
|
|
||||||
source.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00"
|
|
||||||
spec:
|
spec:
|
||||||
url: https://kubernetes-charts.storage.googleapis.com/
|
url: https://kubernetes-charts.storage.googleapis.com/
|
||||||
interval: 1m
|
interval: 10m
|
||||||
```
|
```
|
||||||
|
|
||||||
Private Helm repository:
|
Pull the index of a private Helm repository every minute:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: source.fluxcd.io/v1alpha1
|
apiVersion: source.fluxcd.io/v1alpha1
|
||||||
|
@ -114,10 +111,10 @@ Successful indexation:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
status:
|
status:
|
||||||
url: http://<host>/helmrepository/podinfo-default/index.yaml
|
url: http://<host>/helmrepository/default/stable/index.yaml
|
||||||
conditions:
|
conditions:
|
||||||
- lastTransitionTime: "2020-04-10T09:34:45Z"
|
- lastTransitionTime: "2020-04-10T09:34:45Z"
|
||||||
message: Fetched artifact are available at /data/helmrepositories/podinfo-default/index-21c195d78e699e4b656e2885887d019627838993.yaml
|
message: Helm repository index is available at /data/helmrepository/default/stable/index-21c195d78e699e4b656e2885887d019627838993.yaml
|
||||||
reason: IndexationSucceeded
|
reason: IndexationSucceeded
|
||||||
status: "True"
|
status: "True"
|
||||||
type: Ready
|
type: Ready
|
||||||
|
@ -146,3 +143,9 @@ status:
|
||||||
status: "False"
|
status: "False"
|
||||||
type: Ready
|
type: Ready
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Wait for ready condition:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl wait helmrepository/stable --for=condition=ready --timeout=1m
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue