-
Notifications
You must be signed in to change notification settings - Fork 20
K8s object helm charts #57
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
Draft
ameijer
wants to merge
1
commit into
master
Choose a base branch
from
cursor/k8s-object-helm-charts-a60c
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.
Draft
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
| apiVersion: v2 | ||
| appVersion: "v1.0.0" | ||
| home: https://github.com/ameijer/k8s-as-helm | ||
| description: Helm Chart representing a single LimitRange Kubernetes API object | ||
| name: limitrange | ||
| version: 1.0.0 | ||
| icon: https://ameijer.github.io/k8s-as-helm/icon.png | ||
| maintainers: | ||
| - name: ameijer | ||
| url: https://github.com/ameijer | ||
| keywords: | ||
| - limitrange | ||
| - limits | ||
| - limit | ||
| - api | ||
| - primitives |
This file contains hidden or 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,2 @@ | ||
|
|
||
| The LimitRange Chart {{ .Release.Name }} has been installed into your cluster! |
This file contains hidden or 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,40 @@ | ||
| # LimitRange Chart | ||
| [](https://artifacthub.io/packages/search?repo=k8s-as-helm) | ||
|
|
||
| ## TL;DR; | ||
|
|
||
| ```console | ||
| $ helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/ | ||
| $ helm install my-release k8s-as-helm/limitrange | ||
| ``` | ||
|
|
||
| ## Introduction | ||
|
|
||
| Helm charts are great! They are really configurable and let you build complicated software stacks in seconds. Tools like [Helmfile](https://github.com/roboll/helmfile) combine helm charts together to allow you to set up an environment consisting entirely of helm releases. | ||
|
|
||
| Let's say, though, you want to add additional code to a third party helm chart. You could make a new chart with your K8s API resource and the third party chart as a dependency, but that requires maintenance which might not be worth it if you only needed a single additional resource created. That's where k8s-as-helm charts come in. These charts wrap a single Kubernetes resource in a helm chart with all the key parameters exposed. | ||
|
|
||
| The limitrange chart deploys a single Kubernetes LimitRange object. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```console | ||
| $ helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/ | ||
| $ helm install my-release k8s-as-helm/limitrange | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| The following table lists the configurable parameters of the limitrange chart and their default values. | ||
|
|
||
| Parameter | Description | Default | ||
| --- | --- | --- | ||
| `nameOverride` | override name of the chart component | .Release.Name | ||
| `apiVersion` | api version of k8s object | `"v1"` | ||
| `annotations` | annotations in yaml map format to be added to the object | `null` | ||
| `labels` | labels to add to LimitRange object | `null` | ||
| `limits` | (REQUIRED) spec.limits list | `[]` | ||
|
|
||
| ## Example Configuration | ||
|
|
||
| For some examples of values used to configure this chart, see [the ci/example values for this chart](./ci/ci-values.yaml) |
This file contains hidden or 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 @@ | ||
| annotations: | ||
| example.com/annotation: "true" | ||
| labels: | ||
| test: "true" | ||
| ci: "true" | ||
|
|
||
| limits: | ||
| - type: Container | ||
| default: | ||
| cpu: 500m | ||
| memory: 512Mi | ||
| defaultRequest: | ||
| cpu: 200m | ||
| memory: 256Mi | ||
| max: | ||
| cpu: "1" | ||
| memory: 1Gi | ||
| min: | ||
| cpu: 100m | ||
| memory: 128Mi | ||
| maxLimitRequestRatio: | ||
| cpu: "10" | ||
| - type: Pod | ||
| max: | ||
| cpu: "2" | ||
| memory: 2Gi |
This file contains hidden or 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,14 @@ | ||
| {{/* vim: set filetype=mustache: */}} | ||
| {{/* | ||
| Setup a chart name | ||
| */}} | ||
| {{- define "limitrange.name" -}} | ||
| {{- default .Release.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Return the appropriate apiVersion for the object | ||
| */}} | ||
| {{- define "apiVersion" -}} | ||
| {{- default "v1" .Values.apiVersion -}} | ||
| {{- end -}} |
This file contains hidden or 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,21 @@ | ||
| apiVersion: {{ template "apiVersion" . }} | ||
| kind: LimitRange | ||
| metadata: | ||
| {{- if .Values.annotations }} | ||
| annotations: | ||
| {{ toYaml .Values.annotations | indent 4}} | ||
| {{- end }} | ||
| labels: | ||
| app: {{ template "limitrange.name" . }} | ||
| chart: {{ .Chart.Name }} | ||
| release: {{ .Release.Name }} | ||
| heritage: {{ .Release.Service }} | ||
| {{- if .Values.labels }} | ||
| {{ toYaml .Values.labels | indent 4 }} | ||
| {{- end }} | ||
| name: {{ template "limitrange.name" . }} | ||
| spec: | ||
| {{- if .Values.limits }} | ||
| limits: | ||
| {{ toYaml .Values.limits | indent 4 }} | ||
| {{- end }} |
This file contains hidden or 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,45 @@ | ||
| suite: limitrange | ||
| templates: | ||
| - templates/limitrange.yaml | ||
| tests: | ||
| - it: should render a LimitRange with limits | ||
| values: | ||
| - values/basic.yaml | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 1 | ||
| - isKind: | ||
| of: LimitRange | ||
| - equal: | ||
| path: apiVersion | ||
| value: v1 | ||
| - equal: | ||
| path: metadata.name | ||
| value: RELEASE-NAME | ||
| - equal: | ||
| path: spec.limits | ||
| value: | ||
| - type: Container | ||
| default: | ||
| cpu: 500m | ||
| memory: 512Mi | ||
|
|
||
| - it: should omit annotations when unset | ||
| set: | ||
| limits[0].type: Container | ||
| asserts: | ||
| - notExists: | ||
| path: metadata.annotations | ||
|
|
||
| - it: should include annotations and labels when set | ||
| set: | ||
| annotations.test: "true" | ||
| labels.extra: "label" | ||
| limits[0].type: Container | ||
| asserts: | ||
| - equal: | ||
| path: metadata.annotations.test | ||
| value: "true" | ||
| - equal: | ||
| path: metadata.labels.extra | ||
| value: label |
This file contains hidden or 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,5 @@ | ||
| limits: | ||
| - type: Container | ||
| default: | ||
| cpu: 500m | ||
| memory: 512Mi |
This file contains hidden or 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,9 @@ | ||
| apiVersion: "v1" | ||
|
|
||
| nameOverride: null | ||
|
|
||
| annotations: null | ||
| labels: null | ||
|
|
||
| # (REQUIRED) LimitRange spec.limits list. See Kubernetes LimitRange documentation. | ||
| limits: [] |
This file contains hidden or 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,16 @@ | ||
| apiVersion: v2 | ||
| appVersion: "v1.0.0" | ||
| home: https://github.com/ameijer/k8s-as-helm | ||
| description: Helm Chart representing a single ResourceQuota Kubernetes API object | ||
| name: resourcequota | ||
| version: 1.0.0 | ||
| icon: https://ameijer.github.io/k8s-as-helm/icon.png | ||
| maintainers: | ||
| - name: ameijer | ||
| url: https://github.com/ameijer | ||
| keywords: | ||
| - resourcequota | ||
| - quota | ||
| - resource | ||
| - api | ||
| - primitives |
This file contains hidden or 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,2 @@ | ||
|
|
||
| The ResourceQuota Chart {{ .Release.Name }} has been installed into your cluster! |
This file contains hidden or 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,42 @@ | ||
| # ResourceQuota Chart | ||
| [](https://artifacthub.io/packages/search?repo=k8s-as-helm) | ||
|
|
||
| ## TL;DR; | ||
|
|
||
| ```console | ||
| $ helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/ | ||
| $ helm install my-release k8s-as-helm/resourcequota | ||
| ``` | ||
|
|
||
| ## Introduction | ||
|
|
||
| Helm charts are great! They are really configurable and let you build complicated software stacks in seconds. Tools like [Helmfile](https://github.com/roboll/helmfile) combine helm charts together to allow you to set up an environment consisting entirely of helm releases. | ||
|
|
||
| Let's say, though, you want to add additional code to a third party helm chart. You could make a new chart with your K8s API resource and the third party chart as a dependency, but that requires maintenance which might not be worth it if you only needed a single additional resource created. That's where k8s-as-helm charts come in. These charts wrap a single Kubernetes resource in a helm chart with all the key parameters exposed. | ||
|
|
||
| The resourcequota chart deploys a single Kubernetes ResourceQuota object. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```console | ||
| $ helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/ | ||
| $ helm install my-release k8s-as-helm/resourcequota | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| The following table lists the configurable parameters of the resourcequota chart and their default values. | ||
|
|
||
| Parameter | Description | Default | ||
| --- | --- | --- | ||
| `nameOverride` | override name of the chart component | .Release.Name | ||
| `apiVersion` | api version of k8s object | `"v1"` | ||
| `annotations` | annotations in yaml map format to be added to the object | `null` | ||
| `labels` | labels to add to ResourceQuota object | `null` | ||
| `hard` | (REQUIRED) map of resource quota hard limits | `null` | ||
| `scopes` | optional list of scopes | `[]` | ||
| `scopeSelector` | optional scope selector for priority class, etc. | `null` | ||
|
|
||
| ## Example Configuration | ||
|
|
||
| For some examples of values used to configure this chart, see [the ci/example values for this chart](./ci/ci-values.yaml) |
This file contains hidden or 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,22 @@ | ||
| annotations: | ||
| example.com/annotation: "true" | ||
| labels: | ||
| test: "true" | ||
| ci: "true" | ||
|
|
||
| hard: | ||
| pods: "10" | ||
| requests.cpu: "4" | ||
| requests.memory: 8Gi | ||
| limits.cpu: "8" | ||
| limits.memory: 16Gi | ||
|
|
||
| scopes: | ||
| - NotTerminating | ||
|
|
||
| scopeSelector: | ||
| matchExpressions: | ||
| - scopeName: PriorityClass | ||
| operator: In | ||
| values: | ||
| - high |
This file contains hidden or 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,14 @@ | ||
| {{/* vim: set filetype=mustache: */}} | ||
| {{/* | ||
| Setup a chart name | ||
| */}} | ||
| {{- define "resourcequota.name" -}} | ||
| {{- default .Release.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Return the appropriate apiVersion for the object | ||
| */}} | ||
| {{- define "apiVersion" -}} | ||
| {{- default "v1" .Values.apiVersion -}} | ||
| {{- end -}} |
This file contains hidden or 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,32 @@ | ||
| apiVersion: {{ template "apiVersion" . }} | ||
| kind: ResourceQuota | ||
| metadata: | ||
| {{- if .Values.annotations }} | ||
| annotations: | ||
| {{ toYaml .Values.annotations | indent 4}} | ||
| {{- end }} | ||
| labels: | ||
| app: {{ template "resourcequota.name" . }} | ||
| chart: {{ .Chart.Name }} | ||
| release: {{ .Release.Name }} | ||
| heritage: {{ .Release.Service }} | ||
| {{- if .Values.labels }} | ||
| {{ toYaml .Values.labels | indent 4 }} | ||
| {{- end }} | ||
| name: {{ template "resourcequota.name" . }} | ||
| spec: | ||
| {{- if .Values.hard }} | ||
| hard: | ||
| {{ toYaml .Values.hard | indent 4 }} | ||
| {{- end }} | ||
| {{- if .Values.scopes }} | ||
| scopes: | ||
| {{ toYaml .Values.scopes | indent 4 }} | ||
| {{- end }} | ||
| {{- if .Values.scopeSelector }} | ||
| scopeSelector: | ||
| {{- if .Values.scopeSelector.matchExpressions }} | ||
| matchExpressions: | ||
| {{ toYaml .Values.scopeSelector.matchExpressions | indent 6 }} | ||
| {{- end }} | ||
| {{- 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.
CI script doubles chart path causing tests to never run
The
ct list-changedcommand returns paths likecharts/resourcequota, but the script prependscharts/again in thecompgencheck andhelm unittestcommand, creating invalid paths likecharts/charts/resourcequota. This causes the unit test step to either always skip tests (if no matching path found) or fail (if attempting to run). The library chart exclusion check on line 43 also compareschart(which containscharts/lib-k8s-as-helm) against justlib-k8s-as-helm, so it will never match.Additional Locations (1)
.github/workflows/ci.yaml#L42-L43