Skip to content

Commit

Permalink
chore: add helm chart to repo
Browse files Browse the repository at this point in the history
Signed-off-by: r3drun3 <simone.ragonesi@sighup.io>
  • Loading branch information
R3DRUN3 committed Feb 16, 2024
1 parent 16edf36 commit ef32a13
Show file tree
Hide file tree
Showing 26 changed files with 1,686 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Set the shell to bash always
SHELL := /bin/bash

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
Expand Down Expand Up @@ -151,6 +153,19 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -


######################### Helmify #########################
HELMIFY=$(shell which helmify)

.PHONY: helmify
helmify: $(HELMIFY) ## Download helmify locally if necessary.
$(HELMIFY): $(LOCALBIN)
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@v0.4.5

.PHONY: helm
helm: manifests kustomize helmify ## Produce operator helm charts
$(KUSTOMIZE) build config/default | $(HELMIFY) ./charts

##@ Build Dependencies

## Location to install dependencies to
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Deployment
uninstall Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
deploy Deploy controller to the K8s cluster specified in ~/.kube/config.
undeploy Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
helmify Download helmify locally if necessary.
helm Produce operator helm charts

Build Dependencies
kustomize Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
Expand Down Expand Up @@ -234,7 +236,7 @@ spec:
matchLabels:
app: nginx
status:
numPodsDestroyed: 9
numPodsDestroyed: 7
```
The `status` spec tells you how many pods have been successfully destroyed.
Expand Down Expand Up @@ -854,6 +856,14 @@ khaos-controller-manager-8887957bf-5b8g9 2/2 Running 0
> [!NOTE]
> If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin.

The *Makefile* also contains a target to build the operator's *Helm chart* with [*helmify*](https://github.com/arttor/helmify).
You can build the helm chart with the following command (once you are inside the project's root):
```console
make helm
```
As of right now, the charts are put inside the `charts` folder and not published to a registry or a repo.



## Operator Image Signature Verification
The `realease` pipeline sign the operator's *OCI image* with [cosign](https://docs.sigstore.dev/signing/quickstart/).
Expand Down
23 changes: 23 additions & 0 deletions charts/.helmignore
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/
21 changes: 21 additions & 0 deletions charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: charts
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: 0.1.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: "0.1.0"
62 changes: 62 additions & 0 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "charts.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 "charts.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 "charts.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "charts.labels" -}}
helm.sh/chart: {{ include "charts.chart" . }}
{{ include "charts.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "charts.selectorLabels" -}}
app.kubernetes.io/name: {{ include "charts.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "charts.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "charts.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
54 changes: 54 additions & 0 deletions charts/templates/apiserveroverload-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: apiserveroverloads.khaos.stackzoo.io
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
labels:
{{- include "charts.labels" . | nindent 4 }}
spec:
group: khaos.stackzoo.io
names:
kind: ApiServerOverload
listKind: ApiServerOverloadList
plural: apiserveroverloads
singular: apiserveroverload
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ApiServerOverload is the Schema for the apiserveroverloads API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ApiServerOverloadSpec defines the desired state of ApiServerOverload
type: object
status:
description: ApiServerOverloadStatus defines the observed state of ApiServerOverload
properties:
executedTimestamp:
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
62 changes: 62 additions & 0 deletions charts/templates/commandinjection-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: commandinjections.khaos.stackzoo.io
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
labels:
{{- include "charts.labels" . | nindent 4 }}
spec:
group: khaos.stackzoo.io
names:
kind: CommandInjection
listKind: CommandInjectionList
plural: commandinjections
singular: commandinjection
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: CommandInjection is the Schema for the commandinjections API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CommandInjectionSpec defines the desired state of CommandInjection
properties:
command:
type: string
deployment:
type: string
namespace:
type: string
type: object
status:
description: CommandInjectionStatus defines the observed state of CommandInjection
properties:
numPodsInjected:
format: int32
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
62 changes: 62 additions & 0 deletions charts/templates/configmapdestroyer-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: configmapdestroyers.khaos.stackzoo.io
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
labels:
{{- include "charts.labels" . | nindent 4 }}
spec:
group: khaos.stackzoo.io
names:
kind: ConfigMapDestroyer
listKind: ConfigMapDestroyerList
plural: configmapdestroyers
singular: configmapdestroyer
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ConfigMapDestroyer is the Schema for the configmapdestroyers API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ConfigMapDestroyerSpec defines the desired state of ConfigMapDestroyer
properties:
configMapNames:
items:
type: string
type: array
namespace:
type: string
type: object
status:
description: ConfigMapDestroyerStatus defines the observed state of ConfigMapDestroyer
properties:
numConfigMapsDestroyed:
format: int32
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit ef32a13

Please sign in to comment.