Skip to content

Commit

Permalink
Merge pull request #63 from spring-financial-group/amend/deploy-node-…
Browse files Browse the repository at this point in the history
…affinities

feat: amend node affinities to bring in default values
  • Loading branch information
msvticket authored Jul 28, 2023
2 parents fc2ad8f + a6ea09a commit 1c63604
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 287 deletions.
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME := tekton-pipeline
CHART_DIR := charts/${NAME}
CHART_VERSION ?= latest
RELEASE_VERSION := $(shell jx-release-version -previous-version=from-file:charts/tekton-pipeline/Chart.yaml)
RELEASE_VERSION := $(shell jx release version -previous-version=from-file:charts/tekton-pipeline/Chart.yaml)

CHART_REPO := gs://jenkinsxio/charts

Expand All @@ -21,6 +21,9 @@ endif
find $(CHART_DIR)/templates -type f \( -name "*-crb.yaml" -o -name "*-rb.yaml" \) -exec yq -i '(.subjects[] | select(has("namespace"))).namespace = "{{ .Release.Namespace }}"' "{}" \;
# Remove namespace from metadata to force with helm install
find $(CHART_DIR)/templates -type f -name "*.yaml" -exec yq -i eval 'del(.metadata.namespace)' "{}" \;
# Move content of containers.resources from tekton-pipelines-remote-resolvers-deploy.yaml to remoteresolver.resources
yq -i '.remoteresolver.resources = load("$(CHART_DIR)/templates/tekton-pipelines-remote-resolvers-deploy.yaml").spec.template.spec.containers[].resources' $(CHART_DIR)/values.yaml
yq e -i 'del(.spec.template.spec.containers[].resources)' $(CHART_DIR)/templates/tekton-pipelines-remote-resolvers-deploy.yaml
# Move content of data: from feature-slags-cm.yaml to featureFlags: in values.yaml
yq -i '.featureFlags = load("$(CHART_DIR)/templates/feature-flags-cm.yaml").data' $(CHART_DIR)/values.yaml
yq -i '.data = null' $(CHART_DIR)/templates/feature-flags-cm.yaml
Expand All @@ -30,12 +33,13 @@ endif
# Move content of data: from git-resolver-config-cm.yaml to gitResolverConfig: in values.yaml
yq -i '.gitResolverConfig = load("$(CHART_DIR)/templates/git-resolver-config-cm.yaml").data' $(CHART_DIR)/values.yaml
yq -i '.data = null' $(CHART_DIR)/templates/git-resolver-config-cm.yaml
# Retrieve the image value from the template
yq -i '.controller.deployment.image = load("$(CHART_DIR)/templates/tekton-pipelines-controller-deploy.yaml").spec.template.spec.containers[].image' $(CHART_DIR)/values.yaml
# Remove the image value, so that end users can customize the image
yq -i '.spec.template.spec.containers[].image = null' $(CHART_DIR)/templates/tekton-pipelines-controller-deploy.yaml
# Remove duplicated node affinity
find $(CHART_DIR)/templates -type f -name "*deploy.yaml" -exec yq -i eval 'del(.spec.template.spec.affinity.nodeAffinity)' "{}" \;
# Remove image: from tekton-pipelines-controller-deploy
yq -i 'del(.spec.template.spec.containers[].image)' $(CHART_DIR)/templates/tekton-pipelines-controller-deploy.yaml
# Make node affinity configurable
yq -i '.webhook.affinity.nodeAffinity = load("$(CHART_DIR)/templates/tekton-pipelines-webhook-deploy.yaml").spec.template.spec.affinity.nodeAffinity' $(CHART_DIR)/values.yaml
yq -i 'del(.spec.template.spec.affinity.nodeAffinity)' $(CHART_DIR)/templates/tekton-pipelines-webhook-deploy.yaml
yq -i '.controller.affinity.nodeAffinity = load("$(CHART_DIR)/templates/tekton-pipelines-controller-deploy.yaml").spec.template.spec.affinity.nodeAffinity' $(CHART_DIR)/values.yaml
yq -i 'del(.spec.template.spec.affinity.nodeAffinity)' $(CHART_DIR)/templates/tekton-pipelines-controller-deploy.yaml
# kustomize the resources to include some helm template blocs
kustomize build ${CHART_DIR} | sed '/helmTemplateRemoveMe/d' > ${CHART_DIR}/templates/resource.yaml
jx gitops split -d ${CHART_DIR}/templates
Expand All @@ -45,6 +49,9 @@ ifneq ($(CHART_VERSION),latest)
sed -i.bak "s/^appVersion:.*/appVersion: ${CHART_VERSION}/" ${CHART_DIR}/Chart.yaml
endif

version:
# Increment Chart.yaml version for minor changes to helm chart
yq eval '.version = "$(RELEASE_VERSION)"' -i charts/tekton-pipeline/Chart.yaml
build:
rm -rf Chart.lock
#helm dependency build
Expand All @@ -62,8 +69,6 @@ delete:
clean:

release: clean
# Increment Chart.yaml version for minor changes to helm chart
yq eval '.version = "$(RELEASE_VERSION)"' -i charts/tekton-pipeline/Chart.yaml
helm dependency build
helm lint
helm package .
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ CDF official helm chart for [Tekton Pipelines](https://github.com/tektoncd/pipel

## Prerequisites

The following tools need to be installed locally:
The following tools need to be installed locally (apart from jx):

- [kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/)
- [yq](https://github.com/mikefarah/yq/#install)
- [jx-release-version](https://github.com/jenkins-x-plugins/jx-release-version)

### Jenkins X

Expand All @@ -23,19 +22,21 @@ make fetch
```

This will fetch the latest version.
To fetch a specific version (say 0.32.0), use CHART_VERSION

```bash
make CHART_VERSION=0.32.0 fetch
```
To fetch a specific version (say 0.32.0), use CHART_VERSION
```bash
make version
```
This will increment the chart version by 1. Please use this command when making changes to the charts to maintain version control.

```bash
make release
```
This will check the current version in Chart.yaml and increment the minor version by 0.0.1.
Please use this command when making changes to the charts to maintain version control.
This will also check the current version in Chart.yaml and increment the patch version by 1.

Also, remember to change the `version` in `charts/tekton-pipeline/Chart.yaml`.
The `app_version` will be set to the `CHART_VERSION` automatically by the makefile if a `CHART_VERSION` is specified.
For latest set `app_version` to the latest tekton version from the [tekton release page](https://github.com/tektoncd/pipeline/releases) and not `latest`.

Expand Down
2 changes: 1 addition & 1 deletion charts/tekton-pipeline/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: A Helm chart for Tekton Pipelines
name: tekton-pipeline
version: 1.0.1
version: 1.0.2
appVersion: 0.42.0
icon: https://avatars2.githubusercontent.com/u/47602533
home: https://github.com/cdfoundation/tekton-helm-chart
2 changes: 2 additions & 0 deletions charts/tekton-pipeline/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ resources:
- templates/config-defaults-cm.yaml
- templates/feature-flags-cm.yaml
- templates/git-resolver-config-cm.yaml
- templates/tekton-pipelines-remote-resolvers-deploy.yaml

patchesStrategicMerge:
- patches/tekton-pipelines-controller-deploy.yaml
- patches/tekton-pipelines-webhook-deploy.yaml
- patches/config-defaults-cm.yaml
- patches/feature-flags-cm.yaml
- patches/git-resolver-config-cm.yaml
- patches/tekton-pipelines-remote-resolvers-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ spec:
{{- end}}
spec:
affinity:
nodeAffinity:
helmTemplateRemoveMe: |
{{- with .Values.controllerDeploymentTolerations.nodeAffinity }}
{{- toYaml . | nindent 10 }}
{{- end }}
helmTemplateRemoveMe: |
{{- with .Values.controller.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: tekton-pipelines-controller
envFrom:
Expand All @@ -38,11 +37,11 @@ spec:
image: {{ .Values.controller.deployment.image }}
nodeSelector:
helmTemplateRemoveMe: |
{{- with .Values.controllerDeploymentTolerations.nodeSelector }}
{{- with .Values.controller.nodeSelector }}
{{- toYaml . | nindent 8 }}
{{- end}}
tolerations:
- helmTemplateRemoveMe: |
{{- with .Values.controllerDeploymentTolerations.tolerations }}
{{- with .Values.controller.tolerations }}
{{- toYaml . | nindent 6 }}
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-remote-resolvers
spec:
template:
spec:
affinity:
helmTemplateRemoveMe: |
{{- with .Values.remoteresolver.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
nodeSelector:
helmTemplateRemoveMe: |
{{- with .Values.remoteresolver.nodeSelector }}
{{- toYaml . | nindent 8 }}
{{- end}}
tolerations:
- helmTemplateRemoveMe: |
{{- with .Values.remoteresolver.tolerations }}
{{- toYaml . | nindent 6 }}
{{- end}}
containers:
- name: controller
resources:
helmTemplateRemoveMe: |
{{- with .Values.remoteresolver.resources }}
{{- toYaml . | trim | nindent 10 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ spec:
{{- end}}
spec:
affinity:
nodeAffinity:
helmTemplateRemoveMe: |
{{- with .Values.webhookDeploymentTolerations.nodeAffinity }}
{{- toYaml . | nindent 10 }}
{{- end }}
helmTemplateRemoveMe: |
{{- with .Values.webhook.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: webhook
envFrom:
Expand All @@ -30,11 +29,11 @@ spec:
optional: true
nodeSelector:
helmTemplateRemoveMe: |
{{- with .Values.webhookDeploymentTolerations.nodeSelector }}
{{- with .Values.webhook.nodeSelector }}
{{- toYaml . | nindent 8 }}
{{- end}}
tolerations:
- helmTemplateRemoveMe: |
{{- with .Values.webhookDeploymentTolerations.tolerations }}
{{- with .Values.webhook.tolerations }}
{{- toYaml . | nindent 6 }}
{{- end}}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ spec:
version: v0.42.0
spec:
affinity:
nodeAffinity:
{{- with .Values.controllerDeploymentTolerations.nodeAffinity }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.controller.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- args:
- -kubeconfig-writer-image
Expand Down Expand Up @@ -99,7 +98,6 @@ spec:
- secretRef:
name: '{{ .Values.controller.envFromSecret }}'
optional: true
image: null
livenessProbe:
httpGet:
path: /health
Expand Down Expand Up @@ -144,12 +142,12 @@ spec:
readOnly: true
image: {{ .Values.controller.deployment.image }}
nodeSelector:
{{- with .Values.controllerDeploymentTolerations.nodeSelector }}
{{- with .Values.controller.nodeSelector }}
{{- toYaml . | nindent 8 }}
{{- end}}
serviceAccountName: tekton-pipelines-controller
tolerations:
{{- with .Values.controllerDeploymentTolerations.tolerations }}
{{- with .Values.controller.tolerations }}
{{- toYaml . | nindent 6 }}
{{- end}}
volumes:
Expand Down
Loading

0 comments on commit 1c63604

Please sign in to comment.