Skip to content

Commit

Permalink
Add several new resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Getz committed Jan 5, 2024
1 parent de40b19 commit 281bb38
Show file tree
Hide file tree
Showing 17 changed files with 481 additions and 22 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
go-version: ^1.20
- name: Checkout
uses: actions/checkout@v2

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down Expand Up @@ -43,3 +44,12 @@ jobs:
with:
name: build
path: iits-chart-creator

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: 'v3.7.1' # setup Helm version explicitly if necessary

- name: Validate Helm Chart
run: |
helm template blueprints --set deployment.image.repository=myrepo --set deployment.image.tag=mytag
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,55 @@

`iits-chart-creator` is a powerful cli helm tool designed to streamline and automate the process of creating and managing Helm charts for iits projects.

Current features:
- ingress
- _helpers.tpl

```shell
Available Commands:
deployment Creates a deployment deployment file
helpers.tpl Creates a helpers.tpl deployment file
ingress Creates a Ingress YAML deployment file
service Creates a service deployment file
service-monitor Creates a service-monitor deployment file
serviceaccount Creates a serviceaccount deployment file
```


## Install

## Usage

```shell
helm plugin install https://github.com/iits-consulting/iits-chart-creator
#We would recommend to put this also into your .bash_aliases
alias updateChartCreator="helm plugin update helm-chart-creator && helm iits-chart-creator -v"
alias updateCharter="helm plugin update iits-chart-creator && helm iits-chart-creator -v"
alias charter='helm iits-chart-creator infrastructure-charts'
```

### Local development
If you want to test it out locally execute the following

```shell
go build . && mv iits-chart-creator binaries/iits-chart-creator_linux_amd64_v1/ && helm plugin rm iits-chart-creator && helm plugin install .
```

## Usage

```shell
charter

Creates Infrastructure Charts

Usage:
iits-chart-creator infrastructure-charts [command]

Available Commands:
deployment Creates a deployment deployment file
helpers.tpl Creates a helpers.tpl deployment file
ingress Creates a Ingress YAML deployment file
service Creates a service deployment file
service-monitor Creates a service-monitor deployment file
serviceaccount Creates a serviceaccount deployment file

Flags:
-h, --help help for infrastructure-charts

Use "iits-chart-creator infrastructure-charts [command] --help" for more information about a command.
```
4 changes: 4 additions & 0 deletions blueprints/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: blueprints
type: application
version: 1.4.2
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ Selector labels
{{- define "myService.selectorLabels" -}}
app: {{ include "myService.name" . }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "myService.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "myService.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
58 changes: 58 additions & 0 deletions blueprints/templates/infrastructure-charts/deployment-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
deployment:
replicaCount: "2"

image:
repository: #REPLACE_ME
pullPolicy: IfNotPresent
tag: #REPLACE_ME

imagePullSecrets: [ ]
nameOverride: ""
fullnameOverride: ""

podAnnotations: { }

podSecurityContext:
# fsGroup: 2000

securityContext:
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

volumes: { }
volumeMounts: { }

affinity: { }

ports:
http:

health:
startupProbe:
path: "/"
# initialDelaySeconds: # defaults to 20
# periodSeconds: # defaults to 20
# failureThreshold: # defaults to 3
# port: # defaults to 80
liveness:
path: "/"
# initialDelaySeconds: # defaults to 20
# periodSeconds: # defaults to 20
# failureThreshold: # defaults to 3
# port: # defaults to 80
readiness:
path: "/"
# initialDelaySeconds: # defaults to 20
# periodSeconds: # defaults to 20
# failureThreshold: # defaults to 3
# port: # defaults to 80

env:
MUH: "KUH"

#set the secret where to take env from
envFromSecret:
106 changes: 106 additions & 0 deletions blueprints/templates/infrastructure-charts/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "myService.fullname" . }}
labels:
{{- include "myService.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.deployment.replicaCount }}
revisionHistoryLimit: 3
selector:
matchLabels:
{{- include "myService.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.deployment.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "myService.selectorLabels" . | nindent 8 }}
spec:
{{- if .Values.deployment.onePodForEachNode}}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- {{ include "myService.fullname" . }}
topologyKey: "kubernetes.io/hostname"
{{- end}}
{{- with .Values.deployment.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "myService.serviceAccountName" . }}
{{- if .Values.deployment.podSecurityContext }}
securityContext:
{{- toYaml .Values.deployment.podSecurityContext | nindent 8 }}
{{- end }}
containers:
- name: {{ .Release.Name }}
{{- if .Values.deployment.securityContext }}
securityContext:
{{- toYaml .Values.deployment.securityContext | nindent 12 }}
{{- end }}
image: "{{ tpl .Values.deployment.image.repository . }}:{{ .Values.deployment.image.tag }}"
imagePullPolicy: {{ .Values.deployment.image.pullPolicy }}
env:
{{- range $key, $value := .Values.deployment.env }}
- name: {{ printf "%s" $key | replace "." "_" | upper | quote }}
value: {{ tpl ($value | toString) $ | quote }}
{{- end }}
{{- if .Values.deployment.envSecretName}}
envFrom:
- secretRef:
name: {{.Values.deployment.envSecretName}}
{{- end }}
ports:
{{- range $name,$values := .Values.deployment.ports }}
- name: {{$name }}
protocol: {{ ($values).protocol | default "TCP"}}
containerPort: {{($values).port | default 80 }}
{{- end }}
{{- with ((.Values.deployment).health).liveness }}
livenessProbe:
httpGet:
path: {{ tpl .path $ | default "/" }}
port: {{ .port | default 80 }}
initialDelaySeconds: {{ .initialDelaySeconds | default 20 }}
periodSeconds: 5
failureThreshold: {{ .failureThreshold | default 5 }}
{{- end }}
{{- with ((.Values.deployment).health).readiness }}
readinessProbe:
httpGet:
path: {{ tpl .path $ | default "/" }}
port: {{ .port | default 80 }}
initialDelaySeconds: {{ .initialDelaySeconds | default 20 }}
periodSeconds: 5
failureThreshold: {{ .failureThreshold | default 5 }}
{{- end }}
resources:
{{- toYaml .Values.deployment.resources | nindent 12 }}
{{- with .Values.deployment.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
serviceMonitor:
enabled: true
# Default values, override them if necessary
#labels: {}
#annotations: {}
#portName: "http"
#interval: "10s"
#path: "/metrics"
22 changes: 22 additions & 0 deletions blueprints/templates/infrastructure-charts/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "myService.fullname" $ }}
{{- with .Values.serviceMonitor.labels }}
labels:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "myService.selectorLabels" . | nindent 6 }}
endpoints:
- port: {{ default "http" .Values.serviceMonitor.portName }}
interval: {{ default "10s" .Values.serviceMonitor.interval }}
path: {{ default "/metrics" .Values.serviceMonitor.path }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
service:
ports:
http:
#These values are the default values, override them if necessary
#targetPort: 80
## port name from above
#name: "http"
#protocol: TCP
#port: 80
17 changes: 17 additions & 0 deletions blueprints/templates/infrastructure-charts/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "myService.fullname" . }}
labels:
{{- include "myService.labels" . | nindent 4 }}
spec:
type: {{ (.Values.service).serviceType | default "ClusterIP"}}
ports:
{{- range $name,$values := .Values.service.ports }}
- targetPort: {{ ($values).targetPort | default 80 }}
name: {{ ($values).name | default $name }}
protocol: {{ ($values).protocol | default "TCP"}}
port: {{($values).port | default 80 }}
{{- end }}
selector:
{{- include "myService.selectorLabels" . | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
12 changes: 12 additions & 0 deletions blueprints/templates/infrastructure-charts/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "myService.serviceAccountName" . }}
labels:
{{- include "myService.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit 281bb38

Please sign in to comment.