Skip to content

Commit 242f828

Browse files
committed
Add Helm chart
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
1 parent a81feb3 commit 242f828

File tree

19 files changed

+1048
-2
lines changed

19 files changed

+1048
-2
lines changed

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ help: ## Display this help.
2121
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
2222

2323
.PHONY: manifests
24-
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
24+
manifests: controller-gen kustomize yq ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
25+
rm -rf charts/ofen/templates/generated/
26+
mkdir -p charts/ofen/templates/generated/crds/
2527
$(CONTROLLER_GEN) rbac:roleName=imageprefetch-controller-role crd paths="./..." output:crd:artifacts:config=config/crd/bases
28+
echo '{{- if .Values.crds.enabled }}' > charts/ofen/templates/generated/crds/ofen_crds.yaml
29+
$(KUSTOMIZE) build config/crd | $(YQ) e "." - >> charts/ofen/templates/generated/crds/ofen_crds.yaml
30+
echo '{{- end }}' >> charts/ofen/templates/generated/crds/ofen_crds.yaml
2631

2732
.PHONY: generate
2833
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -138,6 +143,7 @@ GINKGO = $(LOCALBIN)/ginkgo
138143
APPLYCONFIGURATION_GEN = $(LOCALBIN)/applyconfiguration-gen
139144
MODELS_SCHEMA = $(LOCALBIN)/models-schema
140145
KAPTEST ?= $(LOCALBIN)/kaptest
146+
YQ ?= $(LOCALBIN)/yq
141147

142148
## Tool Versions
143149
KUSTOMIZE_VERSION ?= v5.6.0
@@ -148,6 +154,7 @@ GINKGO_VERSION ?= v2.23.4
148154
CODE_GENERATOR_VERSION ?= v0.31.1
149155
MODELS_SCHEMA_VERSION ?= v1.31.1
150156
KAPTEST_VERSION ?= v0.1.2
157+
YQ_VERSION ?= v4.47.1
151158

152159
.PHONY: kustomize
153160
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -196,6 +203,15 @@ $(KAPTEST): $(LOCALBIN)
196203
tar -xzf kaptest_Linux_x86_64.tar.gz -C $(LOCALBIN) kaptest && \
197204
rm -f kaptest_Linux_x86_64.tar.gz
198205

206+
.PHONY: yq
207+
yq: $(YQ) ## Download yq locally if necessary.
208+
$(YQ): $(LOCALBIN)
209+
curl -sLO "https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_linux_amd64.tar.gz" && \
210+
tar -xzf yq_linux_amd64.tar.gz ./yq_linux_amd64 && \
211+
mv yq_linux_amd64 $(YQ) && \
212+
chmod +x $(YQ) && \
213+
rm -f yq_linux_amd64.tar.gz
214+
199215
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
200216
# $1 - target path with name of binary
201217
# $2 - package url which can be installed

charts/ofen/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/ofen/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: ofen
3+
description: Ofen is a kubernetes controller that prefetch(preheat) container images.
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.1.0"

charts/ofen/templates/NOTES.txt

Whitespace-only changes.

charts/ofen/templates/_helpers.tpl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "ofen.name" -}}
5+
{{- default .Chart.Name | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "ofen.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "ofen.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "ofen.labels" -}}
37+
helm.sh/chart: {{ include "ofen.chart" . }}
38+
{{- if .Chart.AppVersion }}
39+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
40+
{{- end }}
41+
app.kubernetes.io/managed-by: {{ .Release.Service }}
42+
{{- end }}

0 commit comments

Comments
 (0)