Skip to content

Commit

Permalink
⚙️ Add flux providerConfig API (#23)
Browse files Browse the repository at this point in the history
Co-authored-by: Kai Kummerer <kai.kummerer@stackit.de>
Co-authored-by: Robin Schneider <45321827+robinschneider@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent 3bf38d4 commit 9b9dc56
Show file tree
Hide file tree
Showing 23 changed files with 1,296 additions and 38 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ jobs:
verify:
runs-on: ubuntu-latest

# update-codegen requires the workspace to be placed in GOPATH.
# Set up env var, working directory, and check out at the correct path in GOPATH.
env:
GOPATH: /home/runner/work/gardener-extension-shoot-flux/gardener-extension-shoot-flux/go
defaults:
run:
working-directory: go/src/github.com/stackitcloud/gardener-extension-shoot-flux

steps:
- uses: actions/checkout@v3
with:
path: go/src/github.com/stackitcloud/gardener-extension-shoot-flux
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
go-version-file: go/src/github.com/stackitcloud/gardener-extension-shoot-flux/go.mod
cache-dependency-path: go/src/github.com/stackitcloud/gardener-extension-shoot-flux/go.sum
- name: Configure git
run: |
git config --global user.email "ci@gardener.cloud"
Expand Down
6 changes: 6 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ issues:
- "\".*\" imported but not used"
# allow non-capitalized messages if they start with technical terms
- "structured logging message should be capitalized: \"garden(er-apiserver|er-controller-manager|er-admission-controller|er-operator|er-resource-manager|let)"
- "exported function SetDefaults_.* should have comment or be unexported"
exclude-rules:
- linters:
- staticcheck
Expand All @@ -47,6 +48,8 @@ linters-settings:
- name: exported
importas:
alias:
- pkg: github.com/stackitcloud/gardener-extension-shoot-flux/pkg/apis/(\w+)/(v[\w\d]+)
alias: $1$2
# External imported packages
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
alias: $1$2
Expand Down Expand Up @@ -100,3 +103,6 @@ linters-settings:
alias: $1$2$3
- pkg: github.com/gardener/gardener/pkg/chartrenderer
alias: chartrenderer
# Flux APIs
- pkg: github.com/fluxcd/(\w+)-controller/api/([\w\d]+)
alias: $1$2
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ check: $(GO_ADD_LICENSE) $(GOIMPORTS) $(GOLANGCI_LINT) $(HELM) $(YQ)
@bash $(HACK_DIRECTORY)/check-charts.sh ./charts

.PHONY: generate
generate:
generate: $(GEN_CRD_API_REFERENCE_DOCS)
@bash $(HACK_DIRECTORY)/generate-controller-registration.sh --pod-security-enforce=privileged shoot-flux charts/gardener-extension-shoot-flux latest deploy/extension/base/controller-registration.yaml Extension:shoot-flux
@bash $(HACK_DIRECTORY)/generate-sequential.sh ./cmd/... ./pkg/...
@hack/update-codegen.sh
@gen-crd-api-reference-docs -api-dir ./pkg/apis -config ./hack/api-reference/api.json -template-dir $(HACK_DIRECTORY)/api-reference/template -out-file ./hack/api-reference/api.md

.PHONY: format
format: $(GOIMPORTS) $(GOIMPORTSREVISER)
Expand Down
67 changes: 67 additions & 0 deletions example/shoot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: core.gardener.cloud/v1beta1
kind: Shoot
metadata:
name: flux
namespace: garden-local
annotations:
shoot.gardener.cloud/infrastructure-cleanup-wait-period-seconds: "0"
shoot.gardener.cloud/cloud-config-execution-max-delay-seconds: "0"
spec:
extensions:
- type: shoot-flux
providerConfig:
apiVersion: flux.extensions.gardener.cloud/v1alpha1
kind: FluxConfig
flux:
version: v2.1.2 # defaults to some current version, not latest!
registry: ghcr.io/fluxcd
namespace: flux-system
source:
template:
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
spec:
ref:
branch: main
# secretRef:
# name: flux-system
url: https://github.com/fluxcd/flux2-kustomize-helm-example
# secretResourceName: flux-ssh-secret
kustomization:
template:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
spec:
path: clusters/production/flux-system
# resources:
# - name: flux-ssh-secret
# resourceRef:
# apiVersion: v1
# kind: Secret
# name: my-project-secret

cloudProfileName: local
secretBindingName: local # dummy, doesn't contain any credentials
region: local
networking:
type: calico
provider:
type: local
workers:
- name: local
machine:
type: local
cri:
name: containerd
minimum: 1
maximum: 2
maxSurge: 1
maxUnavailable: 0
kubernetes:
kubelet:
seccompDefault: true
serializeImagePulls: false
registryPullQPS: 10
registryBurst: 20
protectKernelDefaults: true
streamingConnectionIdleTimeout: 5m
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.21
require (
github.com/ahmetb/gen-crd-api-reference-docs v0.3.0
github.com/fluxcd/flux2 v0.41.2
github.com/fluxcd/kustomize-controller/api v0.35.1
github.com/fluxcd/pkg/apis/meta v0.19.1
github.com/fluxcd/source-controller/api v0.36.1
github.com/fluxcd/kustomize-controller/api v1.1.1
github.com/fluxcd/pkg/apis/meta v1.1.2
github.com/fluxcd/source-controller/api v1.1.2
github.com/gardener/gardener v1.83.0
github.com/go-logr/logr v1.3.0
github.com/google/go-github/v44 v44.1.0
Expand All @@ -18,29 +18,31 @@ require (
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
k8s.io/code-generator v0.28.3
k8s.io/component-base v0.28.3
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bronze1man/yaml2json v0.0.0-20211227013850-8972abeaea25 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fluent/fluent-operator/v2 v2.2.0 // indirect
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
github.com/fluxcd/pkg/apis/kustomize v1.1.1 // indirect
github.com/fluxcd/pkg/ssh v0.7.3 // indirect
github.com/fluxcd/pkg/ssh v0.8.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gardener/etcd-druid v0.20.1 // indirect
github.com/gardener/hvpa-controller/api v0.10.0 // indirect
Expand Down Expand Up @@ -73,7 +75,7 @@ require (
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
Expand Down Expand Up @@ -114,7 +116,6 @@ require (
istio.io/client-go v1.17.1 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/autoscaler/vertical-pod-autoscaler v0.14.0 // indirect
k8s.io/code-generator v0.28.3 // indirect
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
k8s.io/helm v2.17.0+incompatible // indirect
k8s.io/klog v1.0.0 // indirect
Expand All @@ -123,7 +124,6 @@ require (
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/kubelet v0.28.3 // indirect
k8s.io/metrics v0.28.3 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20231015215740-bf15e44028f9 // indirect
sigs.k8s.io/controller-tools v0.13.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand Down Expand Up @@ -74,8 +74,8 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI=
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -100,18 +100,18 @@ github.com/fluent/fluent-operator/v2 v2.2.0 h1:97CiP6WKOHRM7zY/zCynX187Rg+T8hgx2
github.com/fluent/fluent-operator/v2 v2.2.0/go.mod h1:v/q0zLEOWP6MKHP7xvrhtASZTwlrk4LcCne/kgPQ7J0=
github.com/fluxcd/flux2 v0.41.2 h1:9KY616N4lm+60RGmQ5IbBAIuWT/b7T2ycP0gIAdBlYI=
github.com/fluxcd/flux2 v0.41.2/go.mod h1:b9eAdNwwSHtMU9ZyXLk0vjxKBN5QT01yhe9YiD+oYxY=
github.com/fluxcd/kustomize-controller/api v0.35.1 h1:l7AndDJXVLZcCHmEIRXU9ksWInlP6SjFtHQH1SC7++c=
github.com/fluxcd/kustomize-controller/api v0.35.1/go.mod h1:hrxVOUss0om4mg+ykMYtH4CgLuM2RReSPf0hG9e0b18=
github.com/fluxcd/kustomize-controller/api v1.1.1 h1:pQcAzvBC3cFGOCgk0zrcsO1Kjtal1tvd6rHXkyp2R78=
github.com/fluxcd/kustomize-controller/api v1.1.1/go.mod h1:FHJTX6c0+CznUNGMol5+Uc4lQsYRxWgpmIRK/xDCghA=
github.com/fluxcd/pkg/apis/acl v0.1.0 h1:EoAl377hDQYL3WqanWCdifauXqXbMyFuK82NnX6pH4Q=
github.com/fluxcd/pkg/apis/acl v0.1.0/go.mod h1:zfEZzz169Oap034EsDhmCAGgnWlcWmIObZjYMusoXS8=
github.com/fluxcd/pkg/apis/kustomize v1.1.1 h1:MSGn4z0R9PptmoPFHnx2nEZ8Jtl1sKfw0cuDQY2HYwM=
github.com/fluxcd/pkg/apis/kustomize v1.1.1/go.mod h1:0pCu0ecIY+ZM0iE/hOHYwCMZ3b0SpBrjJ1SH3FFyYdE=
github.com/fluxcd/pkg/apis/meta v0.19.1 h1:fCI5CnTXpAqr67UlaI9q0H+OztMKB5kDTr6xV6vlAo0=
github.com/fluxcd/pkg/apis/meta v0.19.1/go.mod h1:ZPPMYrPnWwPQYNEGM/Uc0N4SurUPS3xNI3IIpCQEfuM=
github.com/fluxcd/pkg/ssh v0.7.3 h1:Dhs+nXdp806lBriUJtPyRi0SVIVWbJafJGD/qQ71GiY=
github.com/fluxcd/pkg/ssh v0.7.3/go.mod h1:/z5ZNgQz+h9s/2nNFKAcZDHtZRMA1nj5YcriGDUOoLY=
github.com/fluxcd/source-controller/api v0.36.1 h1:/ul69kJNEwrFG1Cwk2P/GwgraIxOETCL+tP+zMtxTu8=
github.com/fluxcd/source-controller/api v0.36.1/go.mod h1:GktZmd5Dfxo84vPFBdLDl0bBtiJRODfd47uugK0romU=
github.com/fluxcd/pkg/apis/meta v1.1.2 h1:Unjo7hxadtB2dvGpeFqZZUdsjpRA08YYSBb7dF2WIAM=
github.com/fluxcd/pkg/apis/meta v1.1.2/go.mod h1:BHQyRHCskGMEDf6kDGbgQ+cyiNpUHbLsCOsaMYM2maI=
github.com/fluxcd/pkg/ssh v0.8.2 h1:WNfvTmnLnOUyXQDb8luSfmn1X0RIuhJBcKMFtKm6YsQ=
github.com/fluxcd/pkg/ssh v0.8.2/go.mod h1:ewbU9vakYYdGSX92qXhx6Kqi5tVQ3ppmGQakCX1R6Gw=
github.com/fluxcd/source-controller/api v1.1.2 h1:FfKDKVWnopo+Q2pOAxgHEjrtr4MP41L8aapR4mqBhBk=
github.com/fluxcd/source-controller/api v1.1.2/go.mod h1:ZLkaUd1KQIjtLPCvO63Ni5zpnSTVBAkeRgFBzMItbDQ=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
Expand Down Expand Up @@ -286,8 +286,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
Expand Down
26 changes: 26 additions & 0 deletions hack/api-reference/api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"hideMemberFields": [
"TypeMeta"
],
"hideTypePatterns": [
"ParseError$",
"List$"
],
"externalPackages": [
{
"typeMatchPrefix": "^k8s\\.io/(api|apimachinery/pkg/apis)/",
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}"
},
{
"typeMatchPrefix": "^github\\.com/fluxcd/(\\w+)-controller/api",
"docsURLTemplate": "{{ $component := arrIndex .PackageSegments -3 }}{{ if eq $component \"source-controller\" }}{{ $component = \"source\" }}{{ end }}{{ if eq $component \"kustomize-controller\" }}{{ $component = \"kustomize\" }}{{ end }}https://fluxcd.io/flux/components/{{$component}}/api/v1/#{{$component}}.toolkit.fluxcd.io/{{arrIndex .PackageSegments -1}}.{{.TypeIdentifier}}"
}
],
"typeDisplayNamePrefixOverrides": {
"k8s.io/api/": "Kubernetes ",
"k8s.io/apimachinery/pkg/apis/": "Kubernetes ",
"github.com/fluxcd/source-controller/api/": "source.toolkit.fluxcd.io/",
"github.com/fluxcd/kustomize-controller/api/": "kustomize.toolkit.fluxcd.io/"
},
"markdownDisabled": false
}
Loading

0 comments on commit 9b9dc56

Please sign in to comment.