Skip to content

Commit

Permalink
feat(rollouts-demo): added chart
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamar committed Aug 22, 2023
1 parent 231e7fa commit 737731a
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# helm-charts
Some simple Helm Charts

* whoami - simple Chart for https://github.com/traefik/whoami application
* rollouts-demo - Chart with Argo CD rollout. Based on https://github.com/argoproj/rollouts-demo
23 changes: 23 additions & 0 deletions charts/rollouts-demo/.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/
6 changes: 6 additions & 0 deletions charts/rollouts-demo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: rollouts-demo
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: 0.1.0
5 changes: 5 additions & 0 deletions charts/rollouts-demo/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


https://{{ .Values.gateway.host }}

kubectl argo rollouts get rollout {{ include "rollouts-demo.fullname" . }}
51 changes: 51 additions & 0 deletions charts/rollouts-demo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "rollouts-demo.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 "rollouts-demo.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 "rollouts-demo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "rollouts-demo.selectorLabels" -}}
app.kubernetes.io/name: {{ include "rollouts-demo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/rollouts-demo/templates/dns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: {{ include "rollouts-demo.fullname" . }}
spec:
endpoints:
- dnsName: {{ .Values.gateway.host }}
recordTTL: 300
recordType: CNAME
targets:
- {{ .Values.gateway.target }}
26 changes: 26 additions & 0 deletions charts/rollouts-demo/templates/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if .Values.gateway.enabled -}}
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
name: {{ include "rollouts-demo.fullname" . }}
labels:
{{- include "rollouts-demo.labels" . | nindent 4 }}
{{- with .Values.gateway.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
gatewayClassName: {{ .Values.gateway.className }}
listeners:
- name: http
hostname: {{ .Values.gateway.host }}
protocol: HTTP
port: {{ .Values.gateway.port.web }}
- name: https
hostname: {{ .Values.gateway.host }}
protocol: HTTPS
port: {{ .Values.gateway.port.websecure }}
tls:
certificateRefs:
- name: {{ include "rollouts-demo.fullname" . }}-tls
{{- end }}
23 changes: 23 additions & 0 deletions charts/rollouts-demo/templates/httproute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.gateway.enabled -}}
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
name: {{ include "rollouts-demo.fullname" . }}
annotations:
config.kubernetes.io/depends-on: /namespaces/{{ .Release.Namespace }}/Service/{{ include "rollouts-demo.fullname" . }},/namespaces/{{ .Release.Namespace }}/Service/{{ include "rollouts-demo.fullname" . }}-stable,/namespaces/{{ .Release.Namespace }}/Service/{{ include "rollouts-demo.fullname" . }}-canary
spec:
hostnames:
- {{ .Values.gateway.host }}
parentRefs:
- name: {{ include "rollouts-demo.fullname" . }}
rules:
- backendRefs:
- name: {{ include "rollouts-demo.fullname" . }}-canary
port: {{ .Values.service.port }}
matches:
- headers:
{{- toYaml .Values.gateway.matches.canary | nindent 10 }}
- backendRefs:
- name: {{ include "rollouts-demo.fullname" . }}
port: {{ .Values.service.port }}
{{- end }}
63 changes: 63 additions & 0 deletions charts/rollouts-demo/templates/rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: {{ include "rollouts-demo.fullname" . }}
labels:
{{- include "rollouts-demo.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "rollouts-demo.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "rollouts-demo.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
strategy:
canary:
canaryService: {{ include "rollouts-demo.fullname" . }}-canary
stableService: {{ include "rollouts-demo.fullname" . }}-stable
trafficRouting:
traefik:
weightedTraefikServiceName: {{ include "rollouts-demo.fullname" . }}
steps:
- setWeight: 20
- pause: {}
- setWeight: 40
- pause: {duration: 10}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}
revisionHistoryLimit: 2
42 changes: 42 additions & 0 deletions charts/rollouts-demo/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "rollouts-demo.fullname" . }}
labels:
{{- include "rollouts-demo.labels" . | nindent 4 }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "rollouts-demo.selectorLabels" . | nindent 4 }}

---
apiVersion: v1
kind: Service
metadata:
name: {{ include "rollouts-demo.fullname" . }}-canary
labels:
{{- include "rollouts-demo.labels" . | nindent 4 }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http

---
apiVersion: v1
kind: Service
metadata:
name: {{ include "rollouts-demo.fullname" . }}-stable
labels:
{{- include "rollouts-demo.labels" . | nindent 4 }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
11 changes: 11 additions & 0 deletions charts/rollouts-demo/templates/traefik-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
name: {{ include "rollouts-demo.fullname" . }}
spec:
weighted:
services:
- name: {{ include "rollouts-demo.fullname" . }}-stable
port: {{ .Values.service.port }}
- name: {{ include "rollouts-demo.fullname" . }}-canary
port: {{ .Values.service.port }}
54 changes: 54 additions & 0 deletions charts/rollouts-demo/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Default values for rollouts-demo.

replicaCount: 5

image:
repository: argoproj/rollouts-demo
pullPolicy: IfNotPresent
tag: blue

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

podAnnotations: {}

podSecurityContext:
fsGroup: 2000

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

service:
type: ClusterIP
port: 80


# gateway.networking.k8s.io/v1alpha2 Gateway configuration
# defaults for Traefik controller
gateway:
enabled: true
className: traefik
annotations: {}
port:
web: 8000
websecure: 8443
host: ""
target: ""
matches:
canary: []
# - name: version
# value: 2

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 5m
memory: 32Mi

0 comments on commit 737731a

Please sign in to comment.