Skip to content

Commit

Permalink
envoy: Change installation method to Helm directory (cnti-testcatalog…
Browse files Browse the repository at this point in the history
…#2122)

- add helm chart and values file for configurable
  parameters
- add templates for K8s resources
- update PodDisruptionBudget apiVersion
  to policy/v1 to work with newer version of K8s

Signed-off-by: barmull <[email protected]>
  • Loading branch information
barmull authored Aug 3, 2024
1 parent 73b1d44 commit c84cbef
Show file tree
Hide file tree
Showing 12 changed files with 647 additions and 6 deletions.
6 changes: 1 addition & 5 deletions example-cnfs/envoy/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
---
release_name: envoy
service_name: envoy
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
helm_chart: stable/envoy
helm_install_namespace: cnfspace
helm_directory: envoy
21 changes: 21 additions & 0 deletions example-cnfs/envoy/envoy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
10 changes: 10 additions & 0 deletions example-cnfs/envoy/envoy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
description: Envoy is an open source edge and service proxy, designed for cloud-native applications.
name: envoy
version: 1.9.4
appVersion: 1.11.2
keywords:
- envoy
- proxy
sources:
- https://github.com/envoyproxy/envoy
32 changes: 32 additions & 0 deletions example-cnfs/envoy/envoy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "envoy.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 "envoy.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 "envoy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
19 changes: 19 additions & 0 deletions example-cnfs/envoy/envoy/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "envoy.fullname" . }}
labels:
app: {{ template "envoy.name" . }}
chart: {{ template "envoy.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: |-
{{ $value | default "" | indent 4 }}
{{- end -}}
{{- range $key, $value := .Values.templates }}
{{ $key }}: |-
{{ $valueWithDefault := default "" $value -}}
{{ tpl $valueWithDefault $ | indent 4 }}
{{- end -}}
121 changes: 121 additions & 0 deletions example-cnfs/envoy/envoy/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "envoy.fullname" . }}
labels:
app: {{ template "envoy.name" . }}
chart: {{ template "envoy.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "envoy.name" . }}
release: {{ .Release.Name }}
strategy:
{{ .Values.strategy | nindent 4 }}
template:
metadata:
labels:
app: {{ template "envoy.name" . }}
release: {{ .Release.Name }}
component: controller
{{- if .Values.podLabels }}
## Custom pod labels
{{- range $key, $value := .Values.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
annotations:
checksum/config: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- if .Values.podAnnotations }}
## Custom pod annotations
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
securityContext:
{{ toYaml .Values.securityContext | nindent 8 }}
{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- if .Values.initContainersTemplate }}
initContainers:
{{ tpl .Values.initContainersTemplate $ | nindent 8 }}
{{- end }}
containers:
- name: envoy
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
{{ toYaml .Values.command | nindent 12 }}
args:
{{- if $.Values.argsTemplate }}
{{ tpl $.Values.argsTemplate $ | nindent 12}}
{{- else }}
{{ toYaml .Values.args | nindent 12 }}
{{- end }}
ports:
{{- with .Values.ports }}
{{- range $key, $port := . }}
- name: {{ $key }}
{{ toYaml $port | nindent 14 }}
{{- end }}
{{- end }}

livenessProbe:
{{ toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{ toYaml .Values.readinessProbe | nindent 12 }}
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key | upper | replace "." "_" }}
value: {{ $value | quote }}
{{- end }}
resources:
{{ toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /config
{{- if .Values.volumeMounts }}
{{ toYaml .Values.volumeMounts | nindent 12 }}
{{- end }}
{{- range $key, $value := .Values.secretMounts }}
- name: {{ $key }}
mountPath: {{ $value.mountPath }}
{{- end }}
lifecycle:
{{ toYaml .Values.lifecycle | nindent 12 }}

{{- if .Values.sidecarContainersTemplate }}
{{ tpl .Values.sidecarContainersTemplate $ | nindent 8 }}
{{- end }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "envoy.fullname" . }}
{{- if .Values.volumes }}
{{ toYaml .Values.volumes | nindent 8 }}
{{- end }}
{{- range $key, $value := .Values.secretMounts }}
- name: {{ $key }}
secret:
secretName: {{ $value.secretName }}
defaultMode: {{ $value.defaultMode }}
{{- end }}
15 changes: 15 additions & 0 deletions example-cnfs/envoy/envoy/templates/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ template "envoy.fullname" . }}
labels:
app: {{ template "envoy.name" . }}
chart: {{ template "envoy.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
matchLabels:
app: {{ template "envoy.name" . }}
release: {{ .Release.Name }}
{{ .Values.podDisruptionBudget | indent 2 }}
32 changes: 32 additions & 0 deletions example-cnfs/envoy/envoy/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.service.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.service.name }}
labels:
app: {{ template "envoy.name" . }}
chart: {{ template "envoy.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- with .Values.service.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if ne .Values.service.loadBalancerIP "" }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
ports:
{{- range $key, $value := .Values.service.ports }}
- name: {{ $key }}
{{ toYaml $value | indent 6 }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 6 }}
{{- end }}
selector:
app: {{ template "envoy.name" . }}
release: {{ .Release.Name }}
{{- end }}
38 changes: 38 additions & 0 deletions example-cnfs/envoy/envoy/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: {{ template "envoy.name" . }}
chart: {{ template "envoy.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{ toYaml .Values.serviceMonitor.additionalLabels | indent 4}}
{{- end }}
name: {{ template "envoy.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- targetPort: {{ .Values.ports.admin.containerPort }}
interval: {{ .Values.serviceMonitor.interval }}
path: "/stats/prometheus"
jobLabel: {{ template "envoy.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "envoy.name" . }}
release: {{ .Release.Name }}
{{- with .Values.serviceMonitor.targetLabels }}
targetLabels:
{{ toYaml . | trim | indent 4 -}}
{{- end }}
{{- with .Values.serviceMonitor.podTargetLabels }}
podTargetLabels:
{{ toYaml . | trim | indent 4 -}}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions example-cnfs/envoy/envoy/templates/xds.configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "envoy.fullname" . }}-xds
labels:
app: {{ template "envoy.name" . }}
chart: {{ template "envoy.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{- range $filename, $content := .Values.xds }}
{{ tpl $filename $ }}: |-
{{ $valueWithDefault := default "" $content -}}
{{ tpl $valueWithDefault $ | indent 4 }}
{{- end -}}
Loading

0 comments on commit c84cbef

Please sign in to comment.