Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe3e0efcf1 | ||
|
|
ed7a880287 | ||
|
|
e94853f023 | ||
|
|
cbecd8ab56 | ||
|
|
feaab54f70 | ||
|
|
02e12cf871 | ||
|
|
7aeec0a0c4 | ||
|
|
abeea06e72 | ||
|
|
4a55b828b1 | ||
|
|
6b9c0a5e48 | ||
|
|
e060873246 | ||
|
|
143609b9fb | ||
|
|
a22438b7fa | ||
|
|
34321983e7 | ||
|
|
44762933b3 | ||
|
|
2912d1d437 | ||
|
|
4885278691 | ||
|
|
8a7c94180b | ||
|
|
183b9a7ee0 | ||
|
|
0fc582d6fd | ||
|
|
c7a6ed53ca | ||
|
|
547e39d24c | ||
|
|
115b58fe49 | ||
|
|
613e270d00 | ||
|
|
c24e738973 | ||
|
|
e2fb6089c9 | ||
|
|
95eb7aede0 |
11
.github/aur/flux-bin/.SRCINFO.template
vendored
11
.github/aur/flux-bin/.SRCINFO.template
vendored
@@ -1,4 +1,5 @@
|
||||
pkgbase = flux-bin
|
||||
pkgname = flux-bin
|
||||
pkgdesc = Open and extensible continuous delivery solution for Kubernetes
|
||||
pkgver = ${PKGVER}
|
||||
pkgrel = ${PKGREL}
|
||||
@@ -8,9 +9,7 @@ pkgbase = flux-bin
|
||||
arch = armv7h
|
||||
arch = aarch64
|
||||
license = APACHE
|
||||
source_x86_64 = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_amd64.tar.gz
|
||||
source_armv6h = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm.tar.gz
|
||||
source_armv7h = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm.tar.gz
|
||||
source_aarch64 = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm64.tar.gz
|
||||
|
||||
pkgname = flux-bin
|
||||
source_x86_64 = ${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_amd64.tar.gz
|
||||
source_armv6h = ${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_arm.tar.gz
|
||||
source_armv7h = ${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_arm.tar.gz
|
||||
source_aarch64 = ${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_arm64.tar.gz
|
||||
|
||||
@@ -117,6 +117,7 @@ For private Git repositories, the basic authentication credentials are stored in
|
||||
# Create a source for a Git repository using basic authentication
|
||||
flux create source git podinfo \
|
||||
--url=https://github.com/stefanprodan/podinfo \
|
||||
--branch=master \
|
||||
--username=username \
|
||||
--password=password`,
|
||||
RunE: createSourceGitCmdRun,
|
||||
|
||||
@@ -204,12 +204,10 @@ func parallelPodLogs(ctx context.Context, requests []rest.ResponseWrapper) error
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(len(requests))
|
||||
|
||||
var mutex = &sync.Mutex{}
|
||||
|
||||
for _, request := range requests {
|
||||
go func(req rest.ResponseWrapper) {
|
||||
defer wg.Done()
|
||||
if err := logRequest(mutex, ctx, req, os.Stdout); err != nil {
|
||||
if err := logRequest(ctx, req, writer); err != nil {
|
||||
writer.CloseWithError(err)
|
||||
return
|
||||
}
|
||||
@@ -226,9 +224,8 @@ func parallelPodLogs(ctx context.Context, requests []rest.ResponseWrapper) error
|
||||
}
|
||||
|
||||
func podLogs(ctx context.Context, requests []rest.ResponseWrapper) error {
|
||||
mutex := &sync.Mutex{}
|
||||
for _, req := range requests {
|
||||
if err := logRequest(mutex, ctx, req, os.Stdout); err != nil {
|
||||
if err := logRequest(ctx, req, os.Stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -246,7 +243,7 @@ func createLabelStringFromMap(m map[string]string) string {
|
||||
return strings.Join(strArr, ",")
|
||||
}
|
||||
|
||||
func logRequest(mu *sync.Mutex, ctx context.Context, request rest.ResponseWrapper, w io.Writer) error {
|
||||
func logRequest(ctx context.Context, request rest.ResponseWrapper, w io.Writer) error {
|
||||
stream, err := request.Stream(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -261,6 +258,7 @@ func logRequest(mu *sync.Mutex, ctx context.Context, request rest.ResponseWrappe
|
||||
return fmt.Errorf("unable to create template, err: %s", err)
|
||||
}
|
||||
|
||||
bw := bufio.NewWriter(w)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if !strings.HasPrefix(line, "{") {
|
||||
@@ -271,24 +269,21 @@ func logRequest(mu *sync.Mutex, ctx context.Context, request rest.ResponseWrappe
|
||||
logger.Failuref("parse error: %s", err)
|
||||
break
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
filterPrintLog(t, &l)
|
||||
mu.Unlock()
|
||||
filterPrintLog(t, &l, bw)
|
||||
bw.Flush()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func filterPrintLog(t *template.Template, l *ControllerLogEntry) {
|
||||
func filterPrintLog(t *template.Template, l *ControllerLogEntry, w io.Writer) {
|
||||
if logsArgs.logLevel != "" && logsArgs.logLevel != l.Level ||
|
||||
logsArgs.kind != "" && strings.ToLower(logsArgs.kind) != strings.ToLower(l.Kind) ||
|
||||
logsArgs.name != "" && strings.ToLower(logsArgs.name) != strings.ToLower(l.Name) ||
|
||||
!logsArgs.allNamespaces && strings.ToLower(*kubeconfigArgs.Namespace) != strings.ToLower(l.Namespace) {
|
||||
logsArgs.kind != "" && strings.EqualFold(logsArgs.kind, l.Kind) ||
|
||||
logsArgs.name != "" && strings.EqualFold(logsArgs.name, l.Name) ||
|
||||
!logsArgs.allNamespaces && strings.EqualFold(*kubeconfigArgs.Namespace, l.Namespace) {
|
||||
return
|
||||
}
|
||||
|
||||
err := t.Execute(os.Stdout, l)
|
||||
err := t.Execute(w, l)
|
||||
if err != nil {
|
||||
logger.Failuref("log template error: %s", err)
|
||||
}
|
||||
|
||||
12
go.mod
12
go.mod
@@ -7,11 +7,11 @@ require (
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20220517143526-88bb52951d5b
|
||||
github.com/cyphar/filepath-securejoin v0.2.3
|
||||
github.com/fluxcd/go-git-providers v0.6.0
|
||||
github.com/fluxcd/helm-controller/api v0.22.1
|
||||
github.com/fluxcd/image-automation-controller/api v0.23.4
|
||||
github.com/fluxcd/image-reflector-controller/api v0.19.2
|
||||
github.com/fluxcd/kustomize-controller/api v0.26.1
|
||||
github.com/fluxcd/notification-controller/api v0.24.0
|
||||
github.com/fluxcd/helm-controller/api v0.22.2
|
||||
github.com/fluxcd/image-automation-controller/api v0.23.5
|
||||
github.com/fluxcd/image-reflector-controller/api v0.19.4
|
||||
github.com/fluxcd/kustomize-controller/api v0.26.3
|
||||
github.com/fluxcd/notification-controller/api v0.24.1
|
||||
github.com/fluxcd/pkg/apis/meta v0.14.2
|
||||
github.com/fluxcd/pkg/kustomize v0.5.2
|
||||
github.com/fluxcd/pkg/runtime v0.16.2
|
||||
@@ -19,7 +19,7 @@ require (
|
||||
github.com/fluxcd/pkg/ssh v0.5.0
|
||||
github.com/fluxcd/pkg/untar v0.1.0
|
||||
github.com/fluxcd/pkg/version v0.1.0
|
||||
github.com/fluxcd/source-controller/api v0.25.8
|
||||
github.com/fluxcd/source-controller/api v0.25.11
|
||||
github.com/go-git/go-git/v5 v5.4.2
|
||||
github.com/gonvenience/bunt v1.3.4
|
||||
github.com/gonvenience/ytbx v1.4.4
|
||||
|
||||
24
go.sum
24
go.sum
@@ -191,16 +191,16 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fluxcd/go-git-providers v0.6.0 h1:XJc3MTYFpuahBSoKTVxmH9OBPCeIyvYoQkTjTqa3fH4=
|
||||
github.com/fluxcd/go-git-providers v0.6.0/go.mod h1:UMFHnMCIO9CBpEln7ZsArEWyXSNxTpm76fyQxUmClrc=
|
||||
github.com/fluxcd/helm-controller/api v0.22.1 h1:J+i6AZMj0SCuQxcpHmyf1qmPdgDKP0nTkyS4/oLHx0M=
|
||||
github.com/fluxcd/helm-controller/api v0.22.1/go.mod h1:2xuHOYjbRv86ekTYkF7VzTwu5hEHYawrdi7FZrvpr4g=
|
||||
github.com/fluxcd/image-automation-controller/api v0.23.4 h1:MR7TKGxTaFBObyul7ww7YW3DVgtm3eVAcyBGrcvOXIA=
|
||||
github.com/fluxcd/image-automation-controller/api v0.23.4/go.mod h1:wTxI65xywGEULsKR+eCw0H9uNHqSlISYYeozYIRPPx8=
|
||||
github.com/fluxcd/image-reflector-controller/api v0.19.2 h1:ZWM+v05M/f01Q/MHuasQWYY2EtD9B/q4CsewK01ROrU=
|
||||
github.com/fluxcd/image-reflector-controller/api v0.19.2/go.mod h1:WvPujFOXzWttkETUxkCgP9BesCTAfVYzgCeZXu43nY4=
|
||||
github.com/fluxcd/kustomize-controller/api v0.26.1 h1:hX8vPe49/ytKzSAO8Qewb/Cmswt8oit/JNIQ9h5l+xQ=
|
||||
github.com/fluxcd/kustomize-controller/api v0.26.1/go.mod h1:f16v3IErWGQJ0WXtpOW3ATjFukz/KhbkanqS9ZTM8ks=
|
||||
github.com/fluxcd/notification-controller/api v0.24.0 h1:pvLcCD1HT+x0Hup8VLfDrVGFDK33oJKNC7WX6mtEEh0=
|
||||
github.com/fluxcd/notification-controller/api v0.24.0/go.mod h1:pld1fyodxqdWPBr+Ez+kTixmtmO2o3o0I5Zf5wQDHGM=
|
||||
github.com/fluxcd/helm-controller/api v0.22.2 h1:nh0GZBsUE0gNzm4PmPa4aOoqYlbZbpGt2pcIL9S2184=
|
||||
github.com/fluxcd/helm-controller/api v0.22.2/go.mod h1:GfD9TFgLyn81VgwZN1yM47/aUdz0SwTSyRAGmC8xZ+c=
|
||||
github.com/fluxcd/image-automation-controller/api v0.23.5 h1:haMWilXLHXQGn4YXwm70kYvU+7QU5iNoS+0Ybm+4Gac=
|
||||
github.com/fluxcd/image-automation-controller/api v0.23.5/go.mod h1:v/sRqXwo0jNyXK0f4oUY7GZt8NgcNy5twP3OVEsoAt0=
|
||||
github.com/fluxcd/image-reflector-controller/api v0.19.4 h1:SnqJS7vhm+jWHsArjMluCdVydu6jY+m3M2mi+oSHh94=
|
||||
github.com/fluxcd/image-reflector-controller/api v0.19.4/go.mod h1:QFRYeJTfUQY9l3r+PqGGAlr7KzJRCKN7Lsvg9nXaWHk=
|
||||
github.com/fluxcd/kustomize-controller/api v0.26.3 h1:RTrRM9N+YWIX8M690x/rDq/ryiEkhnOaq9Sj1AeWcNQ=
|
||||
github.com/fluxcd/kustomize-controller/api v0.26.3/go.mod h1:Zwvl6iBKbR6SKl5W8APK5hvHfH55S50zAqFLJ/188LQ=
|
||||
github.com/fluxcd/notification-controller/api v0.24.1 h1:aGe4AEPmCW/8gIRCRhOosppXb2mqZYgfftt16Q05/30=
|
||||
github.com/fluxcd/notification-controller/api v0.24.1/go.mod h1:hqn/1JsYiv8Gg3xjBYkLJQhez3hbYj2v57ATfSo637M=
|
||||
github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6k1lc=
|
||||
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
|
||||
github.com/fluxcd/pkg/apis/kustomize v0.4.2 h1:5mC/t+OndouK7poFaG4soWLqvHqOxJ3HCsbxu8qyt30=
|
||||
@@ -219,8 +219,8 @@ github.com/fluxcd/pkg/untar v0.1.0 h1:k97V/xV5hFrAkIkVPuv5AVhyxh1ZzzAKba/lbDfGo6
|
||||
github.com/fluxcd/pkg/untar v0.1.0/go.mod h1:aGswNyzB1mlz/T/kpOS58mITBMxMKc9tlJBH037A2HY=
|
||||
github.com/fluxcd/pkg/version v0.1.0 h1:v+SmCanmCB5Tj2Cx9TXlj+kNRfPGbAvirkeqsp7ZEAQ=
|
||||
github.com/fluxcd/pkg/version v0.1.0/go.mod h1:V7Z/w8dxLQzv0FHqa5ox5TeyOd2zOd49EeuWFgnwyj4=
|
||||
github.com/fluxcd/source-controller/api v0.25.8 h1:5/zxan8aWP03Pfk4Mj1YvFE55s6+TmohVDs1UQFdd9c=
|
||||
github.com/fluxcd/source-controller/api v0.25.8/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs=
|
||||
github.com/fluxcd/source-controller/api v0.25.11 h1:1YbH5vlQ1k96tbRKTdQHCBsBVMgpp/QaRpKG/r29koQ=
|
||||
github.com/fluxcd/source-controller/api v0.25.11/go.mod h1:5kihSWjg+gIXLPTTXbe6AnY+g+iDmP+CY4g6nFqublc=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c=
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/helm-controller/releases/download/v0.22.1/helm-controller.crds.yaml
|
||||
- https://github.com/fluxcd/helm-controller/releases/download/v0.22.1/helm-controller.deployment.yaml
|
||||
- https://github.com/fluxcd/helm-controller/releases/download/v0.22.2/helm-controller.crds.yaml
|
||||
- https://github.com/fluxcd/helm-controller/releases/download/v0.22.2/helm-controller.deployment.yaml
|
||||
- account.yaml
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/image-automation-controller/releases/download/v0.23.4/image-automation-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-automation-controller/releases/download/v0.23.4/image-automation-controller.deployment.yaml
|
||||
- https://github.com/fluxcd/image-automation-controller/releases/download/v0.23.5/image-automation-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-automation-controller/releases/download/v0.23.5/image-automation-controller.deployment.yaml
|
||||
- account.yaml
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/image-reflector-controller/releases/download/v0.19.2/image-reflector-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-reflector-controller/releases/download/v0.19.2/image-reflector-controller.deployment.yaml
|
||||
- https://github.com/fluxcd/image-reflector-controller/releases/download/v0.19.4/image-reflector-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-reflector-controller/releases/download/v0.19.4/image-reflector-controller.deployment.yaml
|
||||
- account.yaml
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/kustomize-controller/releases/download/v0.26.1/kustomize-controller.crds.yaml
|
||||
- https://github.com/fluxcd/kustomize-controller/releases/download/v0.26.1/kustomize-controller.deployment.yaml
|
||||
- https://github.com/fluxcd/kustomize-controller/releases/download/v0.26.3/kustomize-controller.crds.yaml
|
||||
- https://github.com/fluxcd/kustomize-controller/releases/download/v0.26.3/kustomize-controller.deployment.yaml
|
||||
- account.yaml
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/notification-controller/releases/download/v0.24.0/notification-controller.crds.yaml
|
||||
- https://github.com/fluxcd/notification-controller/releases/download/v0.24.0/notification-controller.deployment.yaml
|
||||
- https://github.com/fluxcd/notification-controller/releases/download/v0.24.1/notification-controller.crds.yaml
|
||||
- https://github.com/fluxcd/notification-controller/releases/download/v0.24.1/notification-controller.deployment.yaml
|
||||
- account.yaml
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/source-controller/releases/download/v0.25.8/source-controller.crds.yaml
|
||||
- https://github.com/fluxcd/source-controller/releases/download/v0.25.8/source-controller.deployment.yaml
|
||||
- https://github.com/fluxcd/source-controller/releases/download/v0.25.11/source-controller.crds.yaml
|
||||
- https://github.com/fluxcd/source-controller/releases/download/v0.25.11/source-controller.deployment.yaml
|
||||
- account.yaml
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- https://github.com/fluxcd/source-controller/releases/download/v0.25.8/source-controller.crds.yaml
|
||||
- https://github.com/fluxcd/kustomize-controller/releases/download/v0.26.1/kustomize-controller.crds.yaml
|
||||
- https://github.com/fluxcd/helm-controller/releases/download/v0.22.1/helm-controller.crds.yaml
|
||||
- https://github.com/fluxcd/notification-controller/releases/download/v0.24.0/notification-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-reflector-controller/releases/download/v0.19.2/image-reflector-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-automation-controller/releases/download/v0.23.4/image-automation-controller.crds.yaml
|
||||
- https://github.com/fluxcd/source-controller/releases/download/v0.25.11/source-controller.crds.yaml
|
||||
- https://github.com/fluxcd/kustomize-controller/releases/download/v0.26.3/kustomize-controller.crds.yaml
|
||||
- https://github.com/fluxcd/helm-controller/releases/download/v0.22.2/helm-controller.crds.yaml
|
||||
- https://github.com/fluxcd/notification-controller/releases/download/v0.24.1/notification-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-reflector-controller/releases/download/v0.19.4/image-reflector-controller.crds.yaml
|
||||
- https://github.com/fluxcd/image-automation-controller/releases/download/v0.23.5/image-automation-controller.crds.yaml
|
||||
|
||||
425
rfcs/0003-kubernetes-oci/README.md
Normal file
425
rfcs/0003-kubernetes-oci/README.md
Normal file
@@ -0,0 +1,425 @@
|
||||
# RFC-0003 Flux OCI support for Kubernetes manifests
|
||||
|
||||
**Status:** implementable
|
||||
|
||||
**Creation date:** 2022-03-31
|
||||
|
||||
**Last update:** 2022-07-06
|
||||
|
||||
## Summary
|
||||
|
||||
Flux should be able to distribute and reconcile Kubernetes configuration packaged as OCI artifacts.
|
||||
|
||||
On the client-side, the Flux CLI should offer a command for packaging Kubernetes configs into
|
||||
an OCI artifact and pushing the artifact to a container registry using the Docker config file
|
||||
and the Docker credential helpers for authentication.
|
||||
|
||||
On the server-side, the Flux source-controller should offer a dedicated API Kind for defining
|
||||
how OCI artifacts are pulled from container registries and how the artifact's authenticity can be verified.
|
||||
Flux should be able to work with any type of artifact even if it's not created with the Flux CLI.
|
||||
|
||||
## Motivation
|
||||
|
||||
Given that OCI registries are evolving into a generic artifact storage solution,
|
||||
we should extend Flux to allow fetching Kubernetes manifests and related configs
|
||||
from container registries similar to how Flux works with Git and Bucket storage.
|
||||
|
||||
With OCI support, Flux users can automate artifact updates to Git in the same way
|
||||
they do today for container images.
|
||||
|
||||
### Goals
|
||||
|
||||
- Add support to the Flux CLI for packaging Kubernetes manifests and related configs into OCI artifacts.
|
||||
- Add support to Flux source-controller for fetching configs stored as OCI artifacts.
|
||||
- Make it easy for users to switch from Git repositories and Buckets to OCI repositories.
|
||||
|
||||
### Non-Goals
|
||||
|
||||
- Introduce a new OCI media type for artifacts containing Kubernetes manifests.
|
||||
|
||||
## Proposal
|
||||
|
||||
### Push artifacts
|
||||
|
||||
Flux users should be able to package a local directory containing Kubernetes configs into a tarball
|
||||
and push the archive to a container registry as an OCI artifact.
|
||||
|
||||
```sh
|
||||
flux push artifact oci://docker.io/org/app-config:v1.0.0 \
|
||||
--source="$(git config --get remote.origin.url)" \
|
||||
--revision="$(git branch --show-current)/$(git rev-parse HEAD)" \
|
||||
--path="./deploy"
|
||||
```
|
||||
|
||||
The Flux CLI will produce artifacts of type `application/vnd.docker.distribution.manifest.v2+json`
|
||||
which ensures compatibility with container registries that don't support custom OCI media types.
|
||||
|
||||
The directory pointed to by `--path` is archived and compressed in the `tar+gzip` format
|
||||
and the layer media type is set to `application/vnd.docker.image.rootfs.diff.tar.gzip`.
|
||||
|
||||
The source URL and revision are added to the OCI artifact as annotations in the format:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"annotations": {
|
||||
"source.toolkit.fluxcd.io/url": "https://github.com/org/app.git",
|
||||
"source.toolkit.fluxcd.io/revision": "main/450796ddb2ab6724ee1cc32a4be56da032d1cca0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To ease the promotion workflow of a specific version from one environment to another, the CLI
|
||||
should offer a tagging command.
|
||||
|
||||
```sh
|
||||
flux tag artifact oci://docker.io/org/app-config:v1.0.0 --tag=latest --tag=production
|
||||
```
|
||||
|
||||
To view all the available artifacts in a repository and their metadata, the CLI should
|
||||
offer a list command.
|
||||
|
||||
```sh
|
||||
flux list artifacts oci://docker.io/org/app-config
|
||||
```
|
||||
|
||||
To help inspect artifacts, the Flux CLI will offer a `build` and a `pull` command for generating
|
||||
tarballs locally and for downloading the tarballs from remote container registries.
|
||||
|
||||
```sh
|
||||
flux build artifact --path ./deploy --output tmp/artifact.tgz
|
||||
flux pull artifact oci://docker.io/org/app-config:v1.0.0 --output ./manifests
|
||||
```
|
||||
|
||||
### Pull artifacts
|
||||
|
||||
Flux users should be able to define a source for pulling manifests inside the cluster from an OCI repository.
|
||||
|
||||
```yaml
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
kind: OCIRepository
|
||||
metadata:
|
||||
name: app-config
|
||||
namespace: flux-system
|
||||
spec:
|
||||
interval: 10m
|
||||
url: oci://docker.io/org/app-config
|
||||
ref:
|
||||
tag: v1.0.0
|
||||
```
|
||||
|
||||
The `spec.url` field points to the container image repository in the format `oci://<host>:<port>/<org-name>/<repo-name>`.
|
||||
Note that specifying a tag or digest is not in accepted for this field. The `spec.url` value is used by the controller
|
||||
to fetch the list of tags from the remote OCI repository.
|
||||
|
||||
An `OCIRepository` can refer to an artifact by tag, digest or semver range:
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
ref:
|
||||
# one of
|
||||
tag: "latest"
|
||||
digest: "sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2"
|
||||
semver: "6.0.x"
|
||||
```
|
||||
|
||||
To verify the authenticity of an artifact, the Sigstore cosign public key can be supplied with:
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
verify:
|
||||
provider: cosign
|
||||
secretRef:
|
||||
name: cosign-key
|
||||
```
|
||||
|
||||
### Pull artifacts from private repositories
|
||||
|
||||
For authentication purposes, Flux users can choose between supplying static credentials with Kubernetes secrets
|
||||
and cloud-based OIDC using an IAM role binding to the source-controller Kubernetes service account.
|
||||
|
||||
#### Basic auth
|
||||
|
||||
For private repositories hosted on DockerHub, GitHub, Quay, self-hosted Docker Registry and others,
|
||||
the credentials can be supplied with:
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
secretRef:
|
||||
name: regcred
|
||||
```
|
||||
|
||||
The `secretRef` points to a Kubernetes secret in the same namespace as the `OCIRepository`,
|
||||
the secret type must be `kubernetes.io/dockerconfigjson`:
|
||||
|
||||
```shell
|
||||
kubectl create secret docker-registry regcred \
|
||||
--docker-server=<your-registry-server> \
|
||||
--docker-username=<your-name> \
|
||||
--docker-password=<your-pword>
|
||||
```
|
||||
|
||||
For image pull secrets attached to a service account, the account name can be specified with:
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
serviceAccountName: regsa
|
||||
```
|
||||
|
||||
#### Client cert auth
|
||||
|
||||
For private repositories which require a certificate to authenticate,
|
||||
the client certificate, private key and the CA certificate (if self-signed), can be provided with:
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
certSecretRef:
|
||||
name: regcert
|
||||
```
|
||||
|
||||
The `certSecretRef` points to a Kubernetes secret in the same namespace as the `OCIRepository`:
|
||||
|
||||
```shell
|
||||
kubectl create secret generic regcert \
|
||||
--from-file=certFile=client.crt \
|
||||
--from-file=keyFile=client.key \
|
||||
--from-file=caFile=ca.crt
|
||||
```
|
||||
|
||||
#### OIDC auth
|
||||
|
||||
When Flux runs on AKS, EKS or GKE, an IAM role (that grants read-only access to ACR, ECR or GCR)
|
||||
can be used to bind the `source-controller` to the IAM role.
|
||||
|
||||
Similar to image-reflector-controller
|
||||
[auto-login feature](https://fluxcd.io/docs/guides/image-update/#imagerepository-cloud-providers-authentication),
|
||||
source-controller will expose dedicated flags for each cloud provider:
|
||||
|
||||
```sh
|
||||
--aws-autologin-for-ecr
|
||||
--azure-autologin-for-acr
|
||||
--gcp-autologin-for-gcr
|
||||
```
|
||||
|
||||
### Reconcile artifacts
|
||||
|
||||
The `OCIRepository` can be used as a drop-in replacement for `GitRepository` and `Bucket` sources.
|
||||
For example, a Flux Kustomization can refer to an `OCIRepository` and reconcile the manifests found in the OCI artifact:
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
|
||||
kind: Kustomization
|
||||
metadata:
|
||||
name: app
|
||||
namespace: flux-system
|
||||
spec:
|
||||
interval: 10m
|
||||
sourceRef:
|
||||
kind: OCIRepository
|
||||
name: app-config
|
||||
path: ./
|
||||
```
|
||||
|
||||
### User Stories
|
||||
|
||||
#### Story 1
|
||||
|
||||
> As a developer I want to publish my app Kubernetes manifests to the same GHCR registry
|
||||
> where I publish my app containers.
|
||||
|
||||
First login to GHCR with Docker:
|
||||
|
||||
```sh
|
||||
docker login ghcr.io -u ${GITHUB_USER} -p ${GITHUB_TOKEN}
|
||||
```
|
||||
|
||||
Build your app container image and push it to GHCR:
|
||||
|
||||
```sh
|
||||
docker build -t ghcr.io/org/my-app:v1.0.0 .
|
||||
docker push ghcr.io/org/my-app:v1.0.0
|
||||
```
|
||||
|
||||
Edit the app deployment manifest and set the new image tag.
|
||||
Then push the Kubernetes manifests to GHCR:
|
||||
|
||||
```sh
|
||||
flux push artifact oci://ghcr.io/org/my-app-config:v1.0.0 \
|
||||
--source="$(git config --get remote.origin.url)" \
|
||||
--revision="$(git tag --points-at HEAD)/$(git rev-parse HEAD)"\
|
||||
--path="./deploy"
|
||||
```
|
||||
|
||||
Sign the config image with cosign:
|
||||
|
||||
```sh
|
||||
cosign sign --key cosign.key ghcr.io/org/my-app-config:v1.0.0
|
||||
```
|
||||
|
||||
Mark `v1.0.0` as latest:
|
||||
|
||||
```sh
|
||||
flux tag artifact oci://ghcr.io/org/my-app-config:v1.0.0 --tag latest
|
||||
```
|
||||
|
||||
List the artifacts and their metadata with:
|
||||
|
||||
```console
|
||||
$ flux list artifacts oci://ghcr.io/org/my-app-config
|
||||
ARTIFACT DIGEST SOURCE REVISION
|
||||
ghcr.io/org/my-app-config:latest sha256:45b95019d30af335137977a369ad56e9ea9e9c75bb01afb081a629ba789b890c https://github.com/org/my-app-config.git v1.0.0/20b3a674391df53f05e59a33554973d1cbd4d549
|
||||
ghcr.io/org/my-app-config:v1.0.0 sha256:45b95019d30af335137977a369ad56e9ea9e9c75bb01afb081a629ba789b890c https://github.com/org/my-app-config.git v1.0.0/3f45e72f0d3457e91e3c530c346d86969f9f4034
|
||||
```
|
||||
|
||||
#### Story 2
|
||||
|
||||
> As a developer I want to deploy my app using Kubernetes manifests published as OCI artifacts to GHCR.
|
||||
|
||||
First create a secret using a GitHub token that allows access to GHCR:
|
||||
|
||||
```sh
|
||||
kubectl create secret docker-registry my-app-regcred \
|
||||
--docker-server=ghcr.io \
|
||||
--docker-username=$GITHUB_USER \
|
||||
--docker-password=$GITHUB_TOKEN
|
||||
```
|
||||
|
||||
Then create a secret with your cosgin public key:
|
||||
|
||||
```sh
|
||||
kubectl create secret generic my-app-cosgin-key \
|
||||
--from-file=cosign.pub=cosign/my-key.pub
|
||||
```
|
||||
|
||||
Then define an `OCIRepository` to fetch and verify the latest app config version:
|
||||
|
||||
```yaml
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
kind: OCIRepository
|
||||
metadata:
|
||||
name: app-config
|
||||
namespace: default
|
||||
spec:
|
||||
interval: 10m
|
||||
url: oci://ghcr.io/org/my-app-config
|
||||
ref:
|
||||
semver: "1.x"
|
||||
secretRef:
|
||||
name: my-app-regcred
|
||||
verify:
|
||||
provider: cosign
|
||||
secretRef:
|
||||
name: my-app-cosgin-key
|
||||
```
|
||||
|
||||
And finally, create a Flux Kustomization to reconcile the app on the cluster:
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
|
||||
kind: Kustomization
|
||||
metadata:
|
||||
name: app
|
||||
namespace: default
|
||||
spec:
|
||||
interval: 10m
|
||||
sourceRef:
|
||||
kind: OCIRepository
|
||||
name: app-config
|
||||
path: ./deploy
|
||||
prune: true
|
||||
wait: true
|
||||
timeout: 2m
|
||||
```
|
||||
|
||||
### Alternatives
|
||||
|
||||
An alternative solution is to introduce an OCI artifact type especially made for Kubernetes configuration.
|
||||
That is considered unpractical, as introducing an OCI type has to go through the
|
||||
IANA process and Flux is not the owner of those type as Helm is for Helm artifact for example.
|
||||
|
||||
## Design Details
|
||||
|
||||
Both the Flux CLI and source-controller will use the [go-containerregistry](https://github.com/google/go-containerregistry)
|
||||
library for OCI operations such as push, pull, tag, list tags, etc.
|
||||
|
||||
For authentication purposes, the `flux <verb> artifact` commands will use the `~/.docker/config.json`
|
||||
config file and the Docker credential helpers.
|
||||
|
||||
The source-controller will reuse the authentication library from
|
||||
[image-reflector-controller](https://github.com/fluxcd/image-reflector-controller).
|
||||
|
||||
The Flux CLI will produce OCI artifacts with the following format:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {
|
||||
"mediaType": "application/vnd.docker.container.image.v1+json",
|
||||
"size": 233,
|
||||
"digest": "sha256:e7c52109f8e375176a888fd571dc0e0b40ed8a80d9301208474a2a906b0a2dcc"
|
||||
},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||
"size": 1091,
|
||||
"digest": "sha256:ad804afeae14a8a5c9a45b29f4931104a887844691d040c8737ee3cce6fd6735"
|
||||
}
|
||||
],
|
||||
"annotations": {
|
||||
"source.toolkit.fluxcd.io/revision": "6.1.6/450796ddb2ab6724ee1cc32a4be56da032d1cca0",
|
||||
"source.toolkit.fluxcd.io/url": "https://github.com/stefanprodan/podinfo.git"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The source-controller will extract the first layer from the OCI artifact, and will repackage it
|
||||
as an internal `sourcev1.Artifact`. The internal artifact revision will be set to the OCI SHA256 digest:
|
||||
|
||||
```yaml
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
kind: OCIRepository
|
||||
metadata:
|
||||
creationTimestamp: "2022-06-22T09:14:19Z"
|
||||
finalizers:
|
||||
- finalizers.fluxcd.io
|
||||
generation: 1
|
||||
name: podinfo
|
||||
namespace: oci
|
||||
resourceVersion: "6603"
|
||||
uid: 42e0b9f0-021c-476d-86c7-2cd20747bfff
|
||||
spec:
|
||||
interval: 10m
|
||||
ref:
|
||||
tag: 6.1.6
|
||||
timeout: 60s
|
||||
url: oci://ghcr.io/stefanprodan/manifests/podinfo
|
||||
status:
|
||||
artifact:
|
||||
checksum: d7e924b4882e55b97627355c7b3d2e711e9b54303afa2f50c25377f4df66a83b
|
||||
lastUpdateTime: "2022-06-22T09:14:21Z"
|
||||
path: ocirepository/oci/podinfo/3b6cdcc7adcc9a84d3214ee1c029543789d90b5ae69debe9efa3f66e982875de.tar.gz
|
||||
revision: 3b6cdcc7adcc9a84d3214ee1c029543789d90b5ae69debe9efa3f66e982875de
|
||||
size: 1105
|
||||
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/oci/podinfo/3b6cdcc7adcc9a84d3214ee1c029543789d90b5ae69debe9efa3f66e982875de.tar.gz
|
||||
conditions:
|
||||
- lastTransitionTime: "2022-06-22T09:14:21Z"
|
||||
message: stored artifact for revision '3b6cdcc7adcc9a84d3214ee1c029543789d90b5ae69debe9efa3f66e982875de'
|
||||
observedGeneration: 1
|
||||
reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2022-06-22T09:14:21Z"
|
||||
message: stored artifact for revision '3b6cdcc7adcc9a84d3214ee1c029543789d90b5ae69debe9efa3f66e982875de'
|
||||
observedGeneration: 1
|
||||
reason: Succeeded
|
||||
status: "True"
|
||||
type: ArtifactInStorage
|
||||
observedGeneration: 1
|
||||
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/oci/podinfo/latest.tar.gz
|
||||
```
|
||||
|
||||
### Enabling the feature
|
||||
|
||||
The feature is enabled by default.
|
||||
Reference in New Issue
Block a user