Draft HelmRepository and HelmRelease specs

This commit is contained in:
Hidde Beydals 2020-04-10 11:44:46 +02:00 committed by stefanprodan
parent 134633266a
commit 52a2ae80d1
3 changed files with 344 additions and 7 deletions

View File

@ -2,9 +2,12 @@
The is the v1alpha1 API specification for defining the desired state sources of Kubernetes clusters.
Source kinds:
* [GitRepository](gitrepositories.md)
* [HelmRepository](helmrepositories.md)
* [Common](common.md)
* Source kinds:
+ [GitRepository](gitrepositories.md)
+ [HelmRepository](helmrepositories.md)
- [HelmChart](helmrepositories.md)
Implementations:
* source-controller [v0.0.1-alpha.1](https://github.com/fluxcd/source-controller/releases)

View File

@ -0,0 +1,62 @@
# Common
Common defines resources used across types.
## Specification
### Source condition
> **Note:** to be replaced with <https://github.com/kubernetes/enhancements/pull/1624>
> once made available.
```go
// SourceCondition contains condition information for a source.
type SourceCondition struct {
// Type of the condition, currently ('Ready').
// +required
Type string `json:"type"`
// Status of the condition, one of ('True', 'False', 'Unknown').
// +required
Status corev1.ConditionStatus `json:"status"`
// LastTransitionTime is the timestamp corresponding to the last status
// change of this condition.
// +required
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// Reason is a brief machine readable explanation for the condition's last
// transition.
// +required
Reason string `json:"reason,omitempty"`
// Message is a human readable description of the details of the last
// transition, complementing reason.
// +optional
Message string `json:"message,omitempty"`
}
```
#### Types
```go
const (
// ReadyCondition represents the fact that a given source is in ready state.
ReadyCondition string = "Ready"
)
```
#### Reasons
```go
const (
// InitializingReason represents the fact that a given source is being initialized.
InitializingReason string = "Initializing"
// URLInvalidReason represents the fact that a given source has an invalid URL.
URLInvalidReason string = "URLInvalid"
)
```
## Examples
See the [Git repository](gitrepositories.md) and [Helm chart](helmrepositories.md) APIs.

View File

@ -1,15 +1,287 @@
# Helm Repositories
The `HelmReposiory` and `HelmChart` API defines a source for artifacts coming from Helm repositories.
The Helm source API defines two sources for artifact coming from Helm:
`HelmRepository` and `HelmChart`.
## Specification
TODO
### Helm repository
```go
// HelmRepository defines the reference to a Helm repository.
type HelmRepositorySpec struct {
// The Helm repository URL, a valid URL contains at least a
// protocol and host.
// +required
URL string `json:"url"`
// The name of the secret containing authentication credentials
// for the Helm repository.
// +optional
SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
// The interval at which to check the upstream for updates.
// +required
Interval metav1.Duration `json:"interval"`
}
```
#### Helm repository status
```go
// HelmRepositoryStatus defines the observed state of the HelmRepository.
type HelmRepositoryStatus struct {
// +optional
Conditions []SourceCondition `json:"conditions,omitempty"`
// LastUpdateTime is the timestamp corresponding to the last status
// change of this Helm repository.
// +optional
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
// URI for the artifact of the last successful repository index.
// +optional
Artifact string `json:"artifact,omitempty"`
}
```
#### Helm repository condition reasons
```go
const (
// IndexationFailedReason represents the fact that the indexation
// of the given Helm repository failed.
IndexationFailedReason string = "IndexationFailed"
// IndexationSucceededReason represents the fact that the indexation
// of the given Helm repository succeeded.
IndexationSucceedReason string = "IndexationSucceed"
)
```
### Helm chart
```go
// HelmChart defines the desired state of a Helm chart.
type HelmChartSpec struct {
// The name of the Helm chart, as made available by the referenced
// Helm repository.
// +required
Name string `json:"name"`
// The chart version semver expression, defaults to latest when
// omitted.
// +optional
Version string `json:"version,omitempty"`
// The name of the HelmRepository the chart is available at.
// +required
HelmRepositoryRef v1.LocalObjectReference `json:"helmRepositoryRef"`
// The interval at which to check the Helm repository for updates.
// Defaults to the interval of the Helm repository.
// +optional
Interval metav1.Duration `json:"interval,omitempty"`
}
```
#### Helm chart status
```go
// HelmChartStatus defines the observed state of the HelmChart.
type HelmChartStatus struct {
// +optional
Conditions []SourceCondition `json:"conditions,omitempty"`
// LastUpdateTime is the timestamp corresponding to the last status
// change of this Helm chart.
// +optional
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
// URI for the artifact of the latest successful Helm chart pull.
// +optional
Artifact string `json:"artifact,omitempty"`
}
```
#### Helm chart condition reasons
```go
const (
// ChartPullFailedReason represents the fact that the pull of the
// given Helm chart failed.
ChartPullFailedReason string = "ChartPullFailed"
// ChartPullSucceededReason represents the fact that the pull of
// the given Helm chart succeeded.
ChartPullSucceedReason string = "ChartPullSucceeded"
)
```
## Spec examples
TODO
### Helm repository
Public Helm repository:
```yaml
apiVersion: source.fluxcd.io/v1alpha1
kind: HelmRepository
metadata:
name: stable
namespace: default
annotations:
# force sync trigger
source.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00"
spec:
url: https://kubernetes-charts.storage.googleapis.com/
interval: 1m
```
Private Helm repository:
```yaml
apiVersion: source.fluxcd.io/v1alpha1
kind: HelmRepository
metadata:
name: private
namespace: default
spec:
url: https://charts.example.com
secretRef:
name: https-credentials
interval: 1m
---
apiVersion: v1
kind: Secret
metadata:
name: https-credentials
namespace: default
type: Opaque
data:
username: <BASE64>
password: <BASE64>
certFile: <BASE64>
keyFile: <BASE64>
caFile: <BASE64>
insecureSkipTLSVerify: <base64>
```
### Helm chart
Pinned version:
```yaml
apiVersion: source.fluxcd.io/v1alpha1
kind: HelmChart
metadata:
name: redis
namespace: default
annotations:
# force sync trigger
source.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00"
spec:
name: redis
version: 10.5.7
helmRepositoryRef:
name: stable
```
Semver range:
```yaml
apiVersion: source.fluxcd.io/v1alpha1
kind: HelmChart
metadata:
name: redis
namespace: default
spec:
name: redis
version: ^10.0.0
helmRepositoryRef:
name: stable
```
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
TODO
### Helm repository
Successful indexation:
```yaml
status:
artifact: http://<host>/helmrepositories/podinfo-default/index-21c195d78e699e4b656e2885887d019627838993.yaml
conditions:
- lastTransitionTime: "2020-04-10T09:34:45Z"
message: Fetched artifact are available at /data/helmrepositories/podinfo-default/index-21c195d78e699e4b656e2885887d019627838993.yaml
reason: IndexationSucceeded
status: "True"
type: Ready
lastUpdateTime: "2020-04-10T09:34:45Z"
```
Failed indexation:
```yaml
status:
conditions:
- lastTransitionTime: "2020-04-10T09:27:21Z"
message: 'failed to fetch https://invalid.example.com/index.yaml : 404 Not Found'
reason: IndexationFailed
status: "False"
type: Ready
```
Invalid repository URL:
```yaml
status:
conditions:
- lastTransitionTime: "2020-04-10T09:27:21Z"
message: scheme "invalid" not supported
reason: URLInvalid
status: "False"
type: Ready
```
### Helm chart
Successful chart pull:
```yaml
status:
artifact: http://<host>/helmcharts/redis-default/redis-10.5.7.tgz
conditions:
- lastTransitionTime: "2020-04-10T09:34:45Z"
message: Fetched artifact are available at /data/helmcharts/redis-default/redis-10.5.7.tgz
reason: ChartPullSucceeded
status: "True"
type: Ready
lastUpdateTime: "2020-04-10T09:34:45Z"
```
Failed chart pull:
```yaml
status:
conditions:
- lastTransitionTime: "2020-04-10T09:34:45Z"
message: ''
reason: ChartPullFailed
status: "False"
type: Ready
```