Skip to content

Commit

Permalink
Merge pull request #85 from startechnica/st-common
Browse files Browse the repository at this point in the history
[st common] Bump version to 0.1.9
  • Loading branch information
firmansyahn authored Jan 18, 2025
2 parents 574aa1c + 6f9691d commit 0b7698c
Show file tree
Hide file tree
Showing 30 changed files with 2,129 additions and 146 deletions.
5 changes: 4 additions & 1 deletion charts/common/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
.project
.idea/
*.tmproj
.vscode/
.vscode/

# Artifact 2.29.0
# https://github.com/bitnami/charts/blob/main/bitnami/common/Chart.yaml
12 changes: 4 additions & 8 deletions charts/common/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
annotations:
category: Infrastructure
artifacthub.io/changes: |
- kind: changed
description: Fix Istio API resources
- kind: changed
description: Fix Kubernetes Gateway API resources
- kind: changed
description: Fix Prometheus API resources
- kind: added
description: Add more popular common helper
apiVersion: v2
appVersion: 0.1.8
appVersion: 0.1.9
description: A Library Helm Chart for grouping common logic between Startechnica charts.
This chart is not deployable by itself.
home: https://github.com/startechnica/apps/tree/main/charts/common
Expand All @@ -27,4 +23,4 @@ name: st-common
sources:
- https://startechnica.github.io/apps
type: library
version: 0.1.8
version: 0.1.9
14 changes: 7 additions & 7 deletions charts/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ This chart provides a common template helpers which can be used to develop new c

The following table lists the helpers available in the library which are scoped in different sections.

### istio
### Istio

| Helper identifier | Description | Expected Input |
|---------------------------------------------------|--------------------------------------------------------------------------|-------------------|
| `common.capabilities.istioExtensions.apiVersion` | Return the appropriate apiVersion for Istio Extension. | `.` Chart context |
| `common.capabilities.istioInstall.apiVersion` | Return the appropriate apiVersion for Istio Install. | `.` Chart context |
| `common.capabilities.istioNetworking.apiVersion` | Return the appropriate apiVersion for Istio Networking. | `.` Chart context |
| `common.capabilities.istioSecurity.apiVersion` | Return the appropriate apiVersion for Istio Security. | `.` Chart context |
| `common.capabilities.istioTelemetry.apiVersion` | Return the appropriate apiVersion for Istio Telemetry. | `.` Chart context |
| `st-common.capabilities.istiolWasmPugin.apiVersion` | Return the appropriate apiVersion for Istio WasmPlugin. | `.` Chart context |
| `st-common.capabilities.istioIstioOperator.apiVersion` | Return the appropriate apiVersion for Istio IstioOperator. | `.` Chart context |
| `st-common.capabilities.istioAuthorizationPolicy.apiVersion` | Return the appropriate apiVersion for Istio AuthorizationPolicy. | `.` Chart context |
| `st-common.capabilities.istioDestinationRule.apiVersion` | Return the appropriate apiVersion for Istio DestinationRule. | `.` Chart context |
| `st-common.capabilities.istioTelemetry.apiVersion` | Return the appropriate apiVersion for Istio Telemetry. | `.` Chart context |

### cert-manager

Expand Down Expand Up @@ -71,7 +71,7 @@ metadata:

## License

Copyright © 2022 Startechnica
Copyright © 2025 Startechnica

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
155 changes: 155 additions & 0 deletions charts/common/templates/_affinities.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{{/*
Copyright (c) 2025 Firmansyah Nainggolan. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{/* vim: set filetype=mustache: */}}

{{/*
Return a soft nodeAffinity definition
{{ include "st-common.affinities.nodes.soft" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "st-common.affinities.nodes.soft" -}}
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: {{ .key }}
operator: In
values:
{{- range .values }}
- {{ . | quote }}
{{- end }}
weight: 1
{{- end -}}

{{/*
Return a hard nodeAffinity definition
{{ include "st-common.affinities.nodes.hard" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "st-common.affinities.nodes.hard" -}}
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: {{ .key }}
operator: In
values:
{{- range .values }}
- {{ . | quote }}
{{- end }}
{{- end -}}

{{/*
Return a nodeAffinity definition
{{ include "st-common.affinities.nodes" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "st-common.affinities.nodes" -}}
{{- if eq .type "soft" }}
{{- include "st-common.affinities.nodes.soft" . -}}
{{- else if eq .type "hard" }}
{{- include "st-common.affinities.nodes.hard" . -}}
{{- end -}}
{{- end -}}

{{/*
Return a topologyKey definition
{{ include "st-common.affinities.topologyKey" (dict "topologyKey" "BAR") -}}
*/}}
{{- define "st-common.affinities.topologyKey" -}}
{{ .topologyKey | default "kubernetes.io/hostname" -}}
{{- end -}}

{{/*
Return a soft podAffinity/podAntiAffinity definition
{{ include "st-common.affinities.pods.soft" (dict "component" "FOO" "customLabels" .Values.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "extraPodAffinityTerms" .Values.extraPodAffinityTerms "extraNamespaces" (list "namespace1" "namespace2") "context" $) -}}
*/}}
{{- define "st-common.affinities.pods.soft" -}}
{{- $component := default "" .component -}}
{{- $customLabels := default (dict) .customLabels -}}
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
{{- $extraPodAffinityTerms := default (list) .extraPodAffinityTerms -}}
{{- $extraNamespaces := default (list) .extraNamespaces -}}
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels: {{- (include "st-common.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 10 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := $extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if $extraNamespaces }}
namespaces:
- {{ .context.Release.Namespace }}
{{- with $extraNamespaces }}
{{ include "st-common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
{{- end }}
topologyKey: {{ include "st-common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
weight: 1
{{- range $extraPodAffinityTerms }}
- podAffinityTerm:
labelSelector:
matchLabels: {{- (include "st-common.labels.matchLabels" ( dict "customLabels" $customLabels "context" $.context )) | nindent 10 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := .extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topologyKey: {{ include "st-common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
weight: {{ .weight | default 1 -}}
{{- end -}}
{{- end -}}

{{/*
Return a hard podAffinity/podAntiAffinity definition
{{ include "st-common.affinities.pods.hard" (dict "component" "FOO" "customLabels" .Values.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "extraPodAffinityTerms" .Values.extraPodAffinityTerms "extraNamespaces" (list "namespace1" "namespace2") "context" $) -}}
*/}}
{{- define "st-common.affinities.pods.hard" -}}
{{- $component := default "" .component -}}
{{- $customLabels := default (dict) .customLabels -}}
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
{{- $extraPodAffinityTerms := default (list) .extraPodAffinityTerms -}}
{{- $extraNamespaces := default (list) .extraNamespaces -}}
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels: {{- (include "st-common.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 8 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := $extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if $extraNamespaces }}
namespaces:
- {{ .context.Release.Namespace }}
{{- with $extraNamespaces }}
{{ include "st-common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
{{- end }}
topologyKey: {{ include "st-common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
{{- range $extraPodAffinityTerms }}
- labelSelector:
matchLabels: {{- (include "st-common.labels.matchLabels" ( dict "customLabels" $customLabels "context" $.context )) | nindent 8 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := .extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topologyKey: {{ include "st-common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
{{- end -}}
{{- end -}}

{{/*
Return a podAffinity/podAntiAffinity definition
{{ include "st-common.affinities.pods" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "st-common.affinities.pods" -}}
{{- if eq .type "soft" }}
{{- include "st-common.affinities.pods.soft" . -}}
{{- else if eq .type "hard" }}
{{- include "st-common.affinities.pods.hard" . -}}
{{- end -}}
{{- end -}}
33 changes: 33 additions & 0 deletions charts/common/templates/_argoproj.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- /*
Copyright (c) 2025 Firmansyah Nainggolan. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{/* vim: set filetype=mustache: */}}

{{/* Return the appropriate apiVersion for Argo Application */}}
{{- define "st-common.capabilities.argoprojApplication.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "argoproj.io/v1alpha1" -}}
{{- print "argoproj.io/v1alpha1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Argo ApplicationSet */}}
{{- define "st-common.capabilities.argoprojApplicationSet.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "argoproj.io/v1alpha1" -}}
{{- print "argoproj.io/v1alpha1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Argo AppProject */}}
{{- define "st-common.capabilities.argoprojAppProject.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "argoproj.io/v1alpha1" -}}
{{- print "argoproj.io/v1alpha1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}
32 changes: 31 additions & 1 deletion charts/common/templates/_calico.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- /*
Copyright (c) 2024 Firmansyah Nainggolan. All Rights Reserved.
Copyright (c) 2025 Firmansyah Nainggolan. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{/* vim: set filetype=mustache: */}}

{{/* Return the appropriate apiVersion for Project Calico */}}
{{- define "common.capabilities.calico.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "projectcalico.org/v3" -}}
Expand All @@ -29,4 +31,32 @@ SPDX-License-Identifier: APACHE-2.0
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Project Calico */}}
{{- define "st-common.capabilities.calico.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "projectcalico.org/v3" -}}
{{- print "projectcalico.org/v3" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{- define "st-common.capabilities.calicoCrd.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "crd.projectcalico.org/v1" -}}
{{- print "crd.projectcalico.org/v1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Calico BGPConfiguration */}}
{{- define "st-common.capabilities.calicoBGPConfiguration.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "projectcalico.org/v3/BGPConfiguration" -}}
{{- print "projectcalico.org/v3" -}}
{{- else if .Capabilities.APIVersions.Has "crd.projectcalico.org/v1/BGPConfiguration" -}}
{{- print "crd.projectcalico.org/v1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}
Loading

0 comments on commit 0b7698c

Please sign in to comment.