Skip to content

Commit 4e50d66

Browse files
authored
Merge pull request #201 from fidelity/Upgrade-helm-controller
Upgrade helm controller
2 parents 01e3650 + 2dffa64 commit 4e50d66

30 files changed

+575
-327
lines changed

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
<!--- Check all that apply -->
66

7-
- [ ] If any changes are made to the kraan-controller (\*.go, Dockerfile), bump VERSION file and `chart/Chart.yaml`'s `appVersion:`
8-
- [ ] If any changes are made to ./chart/templates, bump `chart/Chart.yaml`'s `version:`
7+
- [ ] If any changes are made, bump VERSION file `chart/Chart.yaml`'s `version:` and `chart/Chart.yaml`'s `appVersion:`, since chart version and appVersion are unified.

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/main.yaml

+16-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
kubectl apply -f ./testdata/addons/addons.yaml
9696
9797
echo "waiting 5m for test to pass..."
98-
kubectl wait al --for=condition=Deployed --all --timeout=5m || (kubectl get po -A && false)
98+
kubectl wait al --for=condition=Deployed --all --timeout=5m || (kubectl get po -A && kubectl describe al -A && false)
9999
- name: Orphan Integration Test
100100
run: |
101101
echo "setting up test..."
@@ -126,3 +126,18 @@ jobs:
126126
git config --global user.name "github-actions"
127127
git checkout go.mod go.sum
128128
make release
129+
tag-repo:
130+
needs: helm-publish
131+
runs-on: ubuntu-20.04
132+
steps:
133+
- uses: actions/checkout@v2
134+
with:
135+
fetch-depth: 0
136+
- name: tag repository
137+
if: github.event_name == 'push'
138+
run: |
139+
export VERSION=$(cat VERSION)
140+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
141+
git config --global user.name "github-actions"
142+
git tag -a $VERSION -m "tag version $VERSION"
143+
git push origin --tags

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN go mod download
1818
RUN mkdir bin
1919
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o bin/kraan-controller main/main.go
2020
RUN apt install -y curl
21-
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.12/bin/linux/amd64/kubectl
21+
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.19.3/bin/linux/amd64/kubectl
2222
RUN chmod +x ./kubectl
2323
RUN mv kubectl bin
2424
RUN curl -LO https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.8.5/kustomize_v3.8.5_linux_amd64.tar.gz

Dockerfile-check

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ COPY bin/ bin/
2020
RUN apt install -y curl
2121
RUN bin/setup.sh
2222
# Temporary fix see https://github.com/fidelity/kraan/issues/114
23-
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.12/bin/linux/amd64/kubectl
23+
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.19.3/bin/linux/amd64/kubectl
2424
RUN chmod +x ./kubectl
2525
RUN mv kubectl bin
2626
RUN cp bin/* /usr/local/bin

Dockerfile-dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN go mod download
1818
RUN mkdir bin
1919
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o bin/kraan-controller main/main.go
2020
RUN apt install -y curl
21-
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.12/bin/linux/amd64/kubectl
21+
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.19.3/bin/linux/amd64/kubectl
2222
RUN chmod +x ./kubectl
2323
RUN mv kubectl bin
2424
RUN curl -LO https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.8.5/kustomize_v3.8.5_linux_amd64.tar.gz

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.1.29
1+
v0.3.0

bin/setup.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kubebuilder_version=2.3.1
55
mockgen_version=v1.4.4
66
helm_version=v3.3.4
77
kind_version=v0.9.0
8-
kubectl_version=v1.17.12
8+
kubectl_version=v1.19.3
99
kustomize_version=v3.8.5
1010

1111
function usage()
@@ -130,7 +130,7 @@ flux --version >/dev/null 2>&1
130130
ret_code="${?}"
131131
if [[ "${ret_code}" != "0" ]] ; then
132132
echo "Installing latest version of flux cli"
133-
curl -s https://toolkit.fluxcd.io/install.sh | $sudo bash
133+
curl -s https://fluxcd.io/install.sh | $sudo bash
134134
flux --version >/dev/null 2>&1
135135
ret_code="${?}"
136136
if [ "${ret_code}" != "0" ] ; then

chart/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
description: A Helm chart for kraan controller
33
name: kraan-controller
44
type: application
5-
appVersion: v0.1.29
6-
version: v0.2.8
5+
appVersion: v0.3.0
6+
version: v0.3.0

chart/templates/gotk/helm-controller/crd.yaml

+400-83
Large diffs are not rendered by default.

chart/templates/gotk/source-controller/crds.yaml

+19-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.3.0
6+
controller-gen.kubebuilder.io/version: v0.4.1
77
creationTimestamp: null
88
labels:
99
app.kubernetes.io/instance: {{.Release.Namespace}}
@@ -190,7 +190,7 @@ apiVersion: apiextensions.k8s.io/v1
190190
kind: CustomResourceDefinition
191191
metadata:
192192
annotations:
193-
controller-gen.kubebuilder.io/version: v0.3.0
193+
controller-gen.kubebuilder.io/version: v0.4.1
194194
creationTimestamp: null
195195
labels:
196196
app.kubernetes.io/instance: {{.Release.Namespace}}
@@ -203,6 +203,8 @@ spec:
203203
listKind: GitRepositoryList
204204
plural: gitrepositories
205205
singular: gitrepository
206+
shortNames:
207+
- gitrepo
206208
scope: Namespaced
207209
versions:
208210
- additionalPrinterColumns:
@@ -247,6 +249,9 @@ spec:
247249
interval:
248250
description: The interval at which to check for repository updates.
249251
type: string
252+
recurseSubmodules:
253+
description: When enabled, after the clone is created, initializes all submodules within, using their default settings. This option is available only when using the 'go-git' GitImplementation.
254+
type: boolean
250255
ref:
251256
description: The Git reference to checkout and monitor for changes, defaults to master branch.
252257
properties:
@@ -405,7 +410,7 @@ apiVersion: apiextensions.k8s.io/v1
405410
kind: CustomResourceDefinition
406411
metadata:
407412
annotations:
408-
controller-gen.kubebuilder.io/version: v0.3.0
413+
controller-gen.kubebuilder.io/version: v0.4.1
409414
creationTimestamp: null
410415
labels:
411416
app.kubernetes.io/instance: {{.Release.Namespace}}
@@ -418,6 +423,8 @@ spec:
418423
listKind: HelmChartList
419424
plural: helmcharts
420425
singular: helmchart
426+
shortNames:
427+
- hc
421428
scope: Namespaced
422429
versions:
423430
- additionalPrinterColumns:
@@ -488,8 +495,13 @@ spec:
488495
description: This flag tells the controller to suspend the reconciliation of this source.
489496
type: boolean
490497
valuesFile:
491-
description: Alternative values file to use as the default chart values, expected to be a relative path in the SourceRef. Ignored when omitted.
498+
description: Alternative values file to use as the default chart values, expected to be a relative path in the SourceRef. Deprecated in favor of ValuesFiles, for backwards compatibility the file defined here is merged before the ValuesFiles items. Ignored when omitted.
492499
type: string
500+
valuesFiles:
501+
description: Alternative list of values files to use as the chart values (values.yaml is not included by default), expected to be a relative path in the SourceRef. Values files are merged in the order of this list with the last file overriding the first. Ignored when omitted.
502+
items:
503+
type: string
504+
type: array
493505
version:
494506
default: '*'
495507
description: The chart version semver expression, ignored for charts from GitRepository and Bucket sources. Defaults to latest when omitted.
@@ -596,7 +608,7 @@ apiVersion: apiextensions.k8s.io/v1
596608
kind: CustomResourceDefinition
597609
metadata:
598610
annotations:
599-
controller-gen.kubebuilder.io/version: v0.3.0
611+
controller-gen.kubebuilder.io/version: v0.4.1
600612
creationTimestamp: null
601613
labels:
602614
app.kubernetes.io/instance: {{.Release.Namespace}}
@@ -608,6 +620,8 @@ spec:
608620
kind: HelmRepository
609621
listKind: HelmRepositoryList
610622
plural: helmrepositories
623+
shortNames:
624+
- helmrepo
611625
singular: helmrepository
612626
scope: Namespaced
613627
versions:

chart/templates/gotk/source-controller/deployment.yaml

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ metadata:
1010
namespace: {{.Release.Namespace}}
1111
spec:
1212
replicas: 1
13+
strategy:
14+
type: Recreate
1315
selector:
1416
matchLabels:
1517
app: source-controller
@@ -37,6 +39,10 @@ spec:
3739
{{ toYaml .Values.global.prometheusAnnotations | indent 8 }}
3840
{{- end }}
3941
spec:
42+
# Required for AWS IAM Role bindings
43+
# https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html
44+
securityContext:
45+
fsGroup: 1337
4046
containers:
4147
- name: manager
4248
args:
@@ -62,13 +68,15 @@ spec:
6268
imagePullPolicy: {{ .Values.gotk.helmController.image.imagePullPolicy | default "IfNotPresent" }}
6369
livenessProbe:
6470
httpGet:
65-
path: /
66-
port: http
71+
path: /healthz
72+
port: healthz
6773
ports:
6874
- containerPort: 9090
6975
name: http
7076
- containerPort: 8080
7177
name: http-prom
78+
- containerPort: 9440
79+
name: healthz
7280
readinessProbe:
7381
httpGet:
7482
path: /

chart/values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ gotk:
9191
image:
9292
repository: ghcr.io/fluxcd
9393
name: source-controller
94-
tag: v0.7.1
94+
tag: v0.12.2
9595
imagePullPolicy:
9696

9797
imagePullSecrets:
@@ -143,7 +143,7 @@ gotk:
143143
image:
144144
repository: ghcr.io/fluxcd
145145
name: helm-controller
146-
tag: v0.6.1
146+
tag: v0.10.1
147147
imagePullPolicy:
148148

149149
proxy: true

controllers/addons_controller.go

+14-28
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,19 @@ func (r *AddonsLayerReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opt
9999
}
100100
err = ctl.Watch(
101101
&source.Kind{Type: &sourcev1.GitRepository{}},
102-
&handler.EnqueueRequestsFromMapFunc{
103-
ToRequests: handler.ToRequestsFunc(r.repoMapperFunc),
104-
},
102+
handler.EnqueueRequestsFromMapFunc(r.repoMapperFunc),
105103
predicate.Funcs{
106104
CreateFunc: func(e event.CreateEvent) bool {
107105
r.Log.V(1).Info("create event for GitRepository", append(logging.GetFunctionAndSource(logging.MyCaller), logging.GetObjKindNamespaceName(e.Object)...)...)
108106
return true
109107
},
110108
UpdateFunc: func(e event.UpdateEvent) bool {
111109
r.Log.V(1).Info("update event", append(logging.GetFunctionAndSource(logging.MyCaller), logging.GetObjKindNamespaceName(e.ObjectNew)...)...)
112-
if diff := cmp.Diff(e.MetaOld, e.MetaNew); len(diff) > 0 {
113-
r.Log.V(1).Info("update event meta change", append(logging.GetFunctionAndSource(logging.MyCaller), append(logging.GetObjKindNamespaceName(e.ObjectNew), "diff", diff)...)...)
114-
}
110+
115111
if diff := cmp.Diff(e.ObjectOld, e.ObjectNew); len(diff) > 0 {
116112
r.Log.V(1).Info("update event object change", append(logging.GetFunctionAndSource(logging.MyCaller), append(logging.GetObjKindNamespaceName(e.ObjectNew), "diff", diff)...)...)
117113
}
118-
if e.MetaOld == nil || e.MetaNew == nil {
114+
if e.ObjectOld == nil || e.ObjectNew == nil {
119115
r.Log.Error(fmt.Errorf("nill object passed to watcher"), "skipping processing",
120116
append(logging.GetFunctionAndSource(logging.MyCaller), "data", logging.LogJSON(e))...)
121117
return false
@@ -181,9 +177,7 @@ func (r *AddonsLayerReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opt
181177
}
182178
err = ctl.Watch(
183179
&source.Kind{Type: &kraanv1alpha1.AddonsLayer{}},
184-
&handler.EnqueueRequestsFromMapFunc{
185-
ToRequests: handler.ToRequestsFunc(r.layerMapperFunc),
186-
},
180+
handler.EnqueueRequestsFromMapFunc(r.layerMapperFunc),
187181
predicate.Funcs{
188182
CreateFunc: func(e event.CreateEvent) bool {
189183
r.Log.V(1).Info("create event for AddonsLayer, not processing will be processed by controller reconciler",
@@ -192,15 +186,11 @@ func (r *AddonsLayerReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opt
192186
},
193187
UpdateFunc: func(e event.UpdateEvent) bool {
194188
r.Log.V(1).Info("update event for AddonsLayer", append(logging.GetFunctionAndSource(logging.MyCaller), logging.GetObjKindNamespaceName(e.ObjectNew)...)...)
195-
if diff := cmp.Diff(e.MetaOld, e.MetaNew); len(diff) > 0 {
196-
r.Log.V(1).Info("update event meta change for AddonsLayer",
197-
append(logging.GetFunctionAndSource(logging.MyCaller), append(logging.GetObjKindNamespaceName(e.ObjectNew), "diff", diff)...)...)
198-
}
199189
if diff := cmp.Diff(e.ObjectOld, e.ObjectNew); len(diff) > 0 {
200190
r.Log.V(1).Info("update event object change for AddonsLayer",
201191
append(logging.GetFunctionAndSource(logging.MyCaller), append(logging.GetObjKindNamespaceName(e.ObjectNew), "diff", diff)...)...)
202192
}
203-
if e.MetaOld == nil || e.MetaNew == nil {
193+
if e.ObjectOld == nil || e.ObjectNew == nil {
204194
r.Log.Error(fmt.Errorf("nill object passed to watcher for AddonsLayer"), "skipping processing",
205195
append(logging.GetFunctionAndSource(logging.MyCaller), "data", logging.LogJSON(e))...)
206196
return false
@@ -266,9 +256,6 @@ func predicates(logger logr.Logger) predicate.Funcs {
266256
UpdateFunc: func(e event.UpdateEvent) bool {
267257
logger.V(1).Info("update event", append(logging.GetFunctionAndSource(logging.MyCaller),
268258
append(logging.GetObjKindNamespaceName(e.ObjectNew), "layer", logging.GetLayer(e.ObjectNew))...)...)
269-
if diff := cmp.Diff(e.MetaOld, e.MetaNew); len(diff) > 0 {
270-
logger.V(1).Info("update event meta change", append(logging.GetFunctionAndSource(logging.MyCaller), append(logging.GetObjKindNamespaceName(e.ObjectNew), "diff", diff)...)...)
271-
}
272259
if diff := cmp.Diff(e.ObjectOld, e.ObjectNew); len(diff) > 0 {
273260
logger.V(1).Info("update event object change", append(logging.GetFunctionAndSource(logging.MyCaller), append(logging.GetObjKindNamespaceName(e.ObjectNew), "diff", diff)...)...)
274261
}
@@ -719,11 +706,10 @@ func (r *AddonsLayerReconciler) updateRequeue(l layers.Layer) (res ctrl.Result,
719706
// Reconcile process AddonsLayers custom resources.
720707
// +kubebuilder:rbac:groups=kraan.io,resources=addons,verbs=get;list;watch;create;update;patch;delete
721708
// +kubebuilder:rbac:groups=kraan.io,resources=addons/status,verbs=get;update;patch
722-
func (r *AddonsLayerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { // nolint:funlen,gocyclo,gocognit // ok
709+
func (r *AddonsLayerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { // nolint:funlen,gocyclo,gocognit // ok
723710
logging.TraceCall(r.Log)
724711
defer logging.TraceExit(r.Log)
725712

726-
ctx := r.Context
727713
reconcileStart := time.Now()
728714

729715
var addonsLayer *kraanv1alpha1.AddonsLayer = &kraanv1alpha1.AddonsLayer{}
@@ -899,13 +885,13 @@ func (r *AddonsLayerReconciler) update(ctx context.Context, a *kraanv1alpha1.Add
899885
return nil
900886
}
901887

902-
func (r *AddonsLayerReconciler) repoMapperFunc(a handler.MapObject) []reconcile.Request { // nolint:gocyclo //ok
888+
func (r *AddonsLayerReconciler) repoMapperFunc(o client.Object) []reconcile.Request { // nolint:gocyclo //ok
903889
logging.TraceCall(r.Log)
904890
defer logging.TraceExit(r.Log)
905891

906-
srcRepo, ok := a.Object.(*sourcev1.GitRepository)
892+
srcRepo, ok := o.(*sourcev1.GitRepository)
907893
if !ok {
908-
r.Log.Error(fmt.Errorf("unable to cast object to GitRepository"), "skipping processing", logging.GetObjKindNamespaceName(a.Object))
894+
r.Log.Error(fmt.Errorf("unable to cast object to GitRepository"), "skipping processing", logging.GetObjKindNamespaceName(o))
909895
return []reconcile.Request{}
910896
}
911897

@@ -950,13 +936,13 @@ func (r *AddonsLayerReconciler) repoMapperFunc(a handler.MapObject) []reconcile.
950936
return addons
951937
}
952938

953-
func (r *AddonsLayerReconciler) layerMapperFunc(a handler.MapObject) []reconcile.Request {
939+
func (r *AddonsLayerReconciler) layerMapperFunc(o client.Object) []reconcile.Request {
954940
logging.TraceCall(r.Log)
955941
defer logging.TraceExit(r.Log)
956942

957-
src, ok := a.Object.(*kraanv1alpha1.AddonsLayer)
943+
src, ok := o.(*kraanv1alpha1.AddonsLayer)
958944
if !ok {
959-
r.Log.Error(fmt.Errorf("unable to cast object to AddonsLayer"), "skipping processing", logging.GetObjKindNamespaceName(a.Object))
945+
r.Log.Error(fmt.Errorf("unable to cast object to AddonsLayer"), "skipping processing", logging.GetObjKindNamespaceName(o))
960946
return []reconcile.Request{}
961947
}
962948

@@ -980,7 +966,7 @@ func (r *AddonsLayerReconciler) layerMapperFunc(a handler.MapObject) []reconcile
980966
return addons
981967
}
982968

983-
func (r *AddonsLayerReconciler) indexHelmReleaseByOwner(o runtime.Object) []string {
969+
func (r *AddonsLayerReconciler) indexHelmReleaseByOwner(o client.Object) []string {
984970
logging.TraceCall(r.Log)
985971
defer logging.TraceExit(r.Log)
986972

@@ -1008,7 +994,7 @@ func (r *AddonsLayerReconciler) indexHelmReleaseByOwner(o runtime.Object) []stri
1008994
return []string{owner.Name}
1009995
}
1010996

1011-
func (r *AddonsLayerReconciler) indexHelmRepoByOwner(o runtime.Object) []string {
997+
func (r *AddonsLayerReconciler) indexHelmRepoByOwner(o client.Object) []string {
1012998
logging.TraceCall(r.Log)
1013999
defer logging.TraceExit(r.Log)
10141000

0 commit comments

Comments
 (0)