-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker plain helm chart #1035
Open
segfault16
wants to merge
40
commits into
master
Choose a base branch
from
docker-plain-helm-chart
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,239
−22
Open
Docker plain helm chart #1035
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
429158a
feat: add initial draft for helm chart (docker-plain)
segfault16 a8df74d
test: docker-plain chart test use AWS ECR busybox
gerardcl 55df77c
test: update docker-plain golden tests with helm integration
gerardcl abcd6c1
feat: docker-plain remove provisioning resources creation
gerardcl 8be1e7a
drop: comment on docker-plain chart name
gerardcl 5fb6f7e
feat: prepare Chart.yaml for templating the componend_id
segfault16 3dc157b
fix: remove custom app label, prefer the labels suggested by kubernetes
segfault16 ed3b160
fix: remove componentId since this should be covered by the helm char…
segfault16 f83dba3
feat: update image section
segfault16 1d7229d
update devnotes
segfault16 543e5e2
fix TODO note regarding image Values values.yaml
gerardcl e48a729
feat: docker-plain ingress with default tls templating, fix imagetag …
gerardcl 3c9e765
fix: align tabs on ingress.yaml and update devnotes todo
gerardcl 0658683
feat: docker-plain render Helm chart Chart.yaml file
gerardcl 0b541a8
update devnotes, remove dependencies in Chart.yml for now
segfault16 d6d7121
Merge branch 'master' into docker-plain-helm-chart
segfault16 b97f813
update changelog
segfault16 8b87c2c
enable chart testing and enable deploymentStrategy to be set via valu…
gerardcl b2452c0
avoid dependency on Jenkins lib only provided image values - enable c…
gerardcl 6148c67
fix: add missing tpl for serviceAccount
segfault16 2b4a064
fix no property error
BraisVQ 9b6e866
fix
BraisVQ 37271df
skip SA creation on default, use chart fullname
segfault16 b64fd82
Change to nginxinc image
BraisVQ 4b74140
Merge branch 'master' into docker-plain-helm-chart
BraisVQ 6cd786f
Specify selector for Release manager pipeline
BraisVQ 1d9ff9c
Remove value
segfault16 865c738
use nginx image from redhat
segfault16 be71448
move image name logic to _image.tpl, make registry optional
segfault16 f445e25
Update readme, switch to ImagePullStrategy: IfNotPresent
segfault16 00ceccd
Provide initial values files for environments
segfault16 4485450
more strict schema
segfault16 818e13f
update image
segfault16 6bf18ed
docker-plain add helm lint and helm template processing howto info in…
gerardcl 11871d4
Update OS package by default
BraisVQ a4c338a
docker-plain: add HorizontalPodAutoscaler
faust2199 e3e6552
docker-plain: use nginx/nginx-unprivileged
faust2199 167397b
docker-plain: add simpleHost to chart/values.yaml
faust2199 fe5fa7f
docker-plain: allow additionalProperties; make use of .Values.service…
faust2199 6c58ed7
Revert "docker-plain: add simpleHost to chart/values.yaml"
faust2199 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: @component_id@ | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 1.0.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,66 @@ | ||
# Plain Docker image (docker-plain) | ||
|
||
## Purpose | ||
|
||
This Quickstarter serves as a minimal starting point for building your own components that don't fit any of the other Quickstarters. | ||
For demonstration purposes, a nginx webserver provides a simple 'Hello World' message. | ||
|
||
## Folder structure and important files | ||
|
||
- docker: All files inside this folder are available for use in building the docker container | ||
- [docker/Dockerfile](docker/Dockerfile): Defines the container to be built. | ||
- chart: The Helm chart used for deploying the component. | ||
- [chart/Chart.yaml](chart/Chart.yaml): Metadata for your Helm chart. | ||
- [chart/values.yaml](chart/values.yaml): Default values used when templating the Helm chart. | ||
- [chart/values.dev.yaml](chart/values.dev.yaml): Values used for deployment in the 'dev' environment. Values specified in this file are overriding default values from [chart/values.yaml](chart/values.yaml). | ||
- chart/templates: | ||
- [chart/templates/deployment.yaml](chart/templates/deployment.yaml): Template for the [deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) resource. This is where you add additional configuration like environment variables. | ||
- [chart/templates/service.yaml](chart/templates/service.yaml): Template for the [service](https://kubernetes.io/docs/concepts/services-networking/service/) resource. | ||
- [chart/templates/ingress.yaml](chart/templates/ingress.yaml): Template for the [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) resource. | ||
|
||
## Testing locally | ||
|
||
If you want to run this component locally for testing, this might get you started. | ||
It also mimicks what's happening in the [Jenkinsfile](Jenkinsfile). | ||
|
||
### Building the container | ||
|
||
Using a local container runtime you can build the container and tag it with the current git revision: | ||
|
||
```bash | ||
docker build -t testing/my-component:$(git rev-parse --short=8 HEAD) docker/ | ||
``` | ||
|
||
### Helm chart linting | ||
|
||
This quickstarter comes with a fine-tunned [values.schema.json](chart/values.schema.json) Helm chart linting file. | ||
Validate your chart template by running, under the `chart` folder, the following command: | ||
|
||
```bash | ||
helm lint | ||
``` | ||
|
||
### Helm chart template processing test | ||
|
||
One can test the chart template processing; run, under the `chart` folder, the following command: | ||
|
||
```bash | ||
helm --debug template . --set image.path=testing --set image.name=my-component --set image.tag=$(git rev-parse --short=8 HEAD) | ||
``` | ||
|
||
### Deploying the helm chart using a local k8s | ||
|
||
Using a local kubernetes cluster (i.e.: [kind](https://kind.sigs.k8s.io/)) you can deploy the component: | ||
|
||
```bash | ||
kubectl create ns docker-plain | ||
kind load docker-image testing/my-component:$(git rev-parse --short=8 HEAD) | ||
helm upgrade --install --wait --atomic --namespace docker-plain --set image.path=testing --set image.name=my-component --set image.tag=$(git rev-parse --short=8 HEAD) docker-plain chart | ||
``` | ||
|
||
## How to create a custom jenkins-agent out of this docker-plain component | ||
- Remove `odsComponentStageRolloutOpenShiftDeployment(context)` from your `Jenkinsfile`. We only want to build a docker image, not run it outside the pipeline. | ||
- In your `Dockerfile`, replace `FROM alpine:latest` with the ods-jenkins-agent-base image that is available in the OpenDevStack namespace of your cluster, e.g. `FROM docker-registry.default.svc:5000/ods/jenkins-agent-base:latest`. | ||
- Add everything you need in the jenkins-agent to your `Dockerfile`, for examples see the existing agents at [github](https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-agents). | ||
- Commit and push your code to git, this will trigger the pipeline and result in a docker image of your custom jenkins-agent in your cd-namespace. | ||
- Now you can use your custom jenkins-agent by changing the imageStreamTag to `imageStreamTag: '<your_cd_namespace>/<your_custom_jenkins_agent_image_name>:latest'` in the `Jenkinsfile` of the actual application you want to build with your custom new jenkins-agent. | ||
- Now you can use your custom jenkins-agent by changing the imageStreamTag to `imageStreamTag: '<your_cd_namespace>/<your_custom_jenkins_agent_image_name>:latest'` in the `Jenkinsfile` of the actual application you want to build with your custom new jenkins-agent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# IMPORTANT: Content will be recreated from the Chart.yaml.template file by the Jenkins shared library provision job | ||
# NOTE: The content is provided for testing purposes | ||
apiVersion: v2 | ||
name: Your helm chart | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 1.0.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# TODO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just in case we forget, this file should be removed before the PR is merged |
||
Can we adapt NOTES.txt to display some deployed resources and other important information for release documentation? Do we need it? | ||
|
||
- helm linting preps, hence to add values schema validation in the chart together with the values.yaml | ||
- add a test for helm lint | ||
- future add as a Jenkins shared lib stage | ||
- now either we do it as an added manually in the jenkinsfiles or documented and test locally | ||
- make use of it on the github actions when PRs on quickstarters (reuse max as possible) | ||
- we will move to values.yaml | ||
- [X] the probes | ||
- [x] the affinity (missing labels now and some additions required) | ||
- [x] the route (with timeout values and example for ACME usage) | ||
- [x] rolling update strategy? | ||
- [X] remove provisioning resources creation -> get rid odsQuickstarterStageCreateOpenShiftResources | ||
- jenkinsfile with values.env.yaml ready, so we will provide all the env values too: Different replicaCount + ingress hosts | ||
segfault16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- [X] update test-conection.yaml with better image (to not suffer dockerhub rate limiting) | ||
- [X] golden tests do not check anymore imagetags nor deploymentconfigs | ||
- [X] Test ingress on Openshift without hostname -> is there a generated one? NO -> host value is required but tls can be left empty now with default OpenShift TLS (See ingress.yaml and values.yaml). host value is required as ingress approach is a rules based system. | ||
- [X] Make ingress more standard helm (e.g. list of hosts) -> Sebastian | ||
- start defining howtos/FAQS we detect on the way (goal to keep simple the chart but to show how to improve it and have good practises) bitnami examples (more elaborated affinity, ...) | ||
|
||
|
||
- example of chart dependency | ||
- example of configmap and secret | ||
- example of secret resource management in code | ||
- add support for extra secret operator | ||
|
||
Later | ||
- with the common folder with tpl files we provide a more clean and fitting approach for us | ||
- create a new pipeline step provisioning that copies over .tpl files required from common | ||
- creation of template files folder in common, so we try to centralise the chart creation and maintenance from one place (as it is done already with openshift templates/tailor) | ||
|
||
Decisions: | ||
- To stay close to default helm templates: Remove the Values.componentId and use chart.fullname instead -> Otherwise breaks DEV + PREVIEW. Chart.Name should be the source for componentId. If we want to automate -> template the Chart.yaml on provisioning <- DONE | ||
|
||
Shared library ToDo's: | ||
- Match required labels (app) | ||
- Review helm install command | ||
- Release manager image checks | ||
- Agree if helm install requires overwritting values on image (see helm notes and deployment, and values.yaml) | ||
segfault16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- provide docs on how to test chart updates, by running `helm --debug template . ` under the chart folder to be tested | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also helm lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Component '{{ include "chart.fullname" . }}' on version '{{ .Values.imageTag }}' released with Helm! | ||
{{- if .Values.ingress.enabled }} | ||
The component is exposed via the following routes: | ||
{{- $appUrl := .Values.appUrl -}} | ||
{{- range .Values.ingress.hosts }} | ||
{{ printf "https://%s" .host }} | ||
{{- end }} | ||
{{- else }} | ||
The component is not exposed. | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{{/* | ||
Part of the ODS helm tpl library | ||
|
||
Version: 1.0 | ||
*/}} | ||
|
||
|
||
{{/* | ||
Pod affinity/anti-affinity (soft) | ||
|
||
Usage: Include where needed, e.g. | ||
```` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
spec: | ||
template: | ||
spec: | ||
affinity: | ||
podAntiAffinity: {{- include "common.affinities.pods.soft" . | nindent 10}} | ||
gerardcl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```` | ||
*/}} | ||
{{- define "common.affinities.pods.soft" -}} | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 1 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: {{- include "common.matchLabels" . | nindent 10 }} | ||
topologyKey: "kubernetes.io/hostname" | ||
{{- end -}} | ||
|
||
{{/* | ||
Pod affinity/anti-affinity (hard) | ||
|
||
Usage: Include where needed, e.g. | ||
```` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
spec: | ||
template: | ||
spec: | ||
affinity: | ||
podAntiAffinity: {{- include "common.affinities.pods.hard" . | nindent 10}} | ||
```` | ||
*/}} | ||
{{- define "common.affinities.pods.hard" -}} | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- podAffinityTerm: | ||
labelSelector: | ||
matchLabels: {{- include "common.matchLabels" . | nindent 10 }} | ||
topologyKey: "kubernetes.io/hostname" | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "chart.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "chart.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "chart.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "chart.labels" -}} | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
{{ include "chart.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "chart.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "chart.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "chart.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
{{/* | ||
Part of the ODS helm tpl library | ||
|
||
Version: 1.0 | ||
*/}} | ||
|
||
{{/* | ||
Create an image name from the registry, image path, name and tag. | ||
.Values.registry, .Values.imageNamespace, .Values.componentId and .Values.imageTag are injected by the ODS pipeline on deployment. | ||
If not set, values from .Values.image.registry, .Values.image.path, .Values.image.name and .Values.image.tag are used. | ||
*/}} | ||
{{- define "image.fullname" -}} | ||
{{- if (or .Values.registry .Values.image.registry) }} | ||
{{- printf "%s/%s/%s:%s" (or .Values.registry .Values.image.registry) (or .Values.imageNamespace .Values.image.path) (or .Values.componentId .Values.image.name) (or .Values.imageTag .Values.image.tag ) -}} | ||
{{- else }} | ||
{{- printf "%s/%s:%s" (or .Values.imageNamespace .Values.image.path) (or .Values.componentId .Values.image.name) (or .Values.imageTag .Values.image.tag ) -}} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{/* | ||
Part of the ODS helm tpl library | ||
|
||
Version: 1.0 | ||
*/}} | ||
|
||
|
||
{{- define "common.matchLabels" -}} | ||
app.kubernetes.io/name: {{ include "chart.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still needed?