From 26500e9ea84183d704dcc9379c3d9ca3c1c4be0f Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 2 Oct 2018 00:23:04 +0300 Subject: [PATCH] Add podinfo chart for GitOps testing --- .../podinfo-steerer}/.helmignore | 0 charts/podinfo-steerer/Chart.yaml | 12 ++++ charts/podinfo-steerer/README.md | 56 +++++++++++++++++ charts/podinfo-steerer/templates/NOTES.txt | 1 + charts/podinfo-steerer/templates/_helpers.tpl | 36 +++++++++++ .../templates/canary-deployment.yaml | 63 +++++++++++++++++++ .../podinfo-steerer/templates/canary-hpa.yaml | 21 +++++++ .../templates/canary-service.yaml | 18 ++++++ .../templates/primary-deployment.yaml | 63 +++++++++++++++++++ .../templates/primary-hpa.yaml | 21 +++++++ .../templates/primary-service.yaml | 18 ++++++ .../templates/virtual-service.yaml | 30 +++++++++ charts/podinfo-steerer/values.yaml | 30 +++++++++ docs/index.yaml | 25 ++++++-- 14 files changed, 390 insertions(+), 4 deletions(-) rename {chart/steerer => charts/podinfo-steerer}/.helmignore (100%) create mode 100644 charts/podinfo-steerer/Chart.yaml create mode 100644 charts/podinfo-steerer/README.md create mode 100644 charts/podinfo-steerer/templates/NOTES.txt create mode 100644 charts/podinfo-steerer/templates/_helpers.tpl create mode 100644 charts/podinfo-steerer/templates/canary-deployment.yaml create mode 100644 charts/podinfo-steerer/templates/canary-hpa.yaml create mode 100644 charts/podinfo-steerer/templates/canary-service.yaml create mode 100644 charts/podinfo-steerer/templates/primary-deployment.yaml create mode 100644 charts/podinfo-steerer/templates/primary-hpa.yaml create mode 100644 charts/podinfo-steerer/templates/primary-service.yaml create mode 100644 charts/podinfo-steerer/templates/virtual-service.yaml create mode 100644 charts/podinfo-steerer/values.yaml diff --git a/chart/steerer/.helmignore b/charts/podinfo-steerer/.helmignore similarity index 100% rename from chart/steerer/.helmignore rename to charts/podinfo-steerer/.helmignore diff --git a/charts/podinfo-steerer/Chart.yaml b/charts/podinfo-steerer/Chart.yaml new file mode 100644 index 00000000..d62d0965 --- /dev/null +++ b/charts/podinfo-steerer/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +version: 1.2.1 +appVersion: 1.2.1 +engine: gotpl +name: podinfo-steerer +description: Podinfo Helm chart for Steerer progressive delivery +home: https://github.com/stefanprodan/k8s-podinfo +maintainers: +- email: stefanprodan@users.noreply.github.com + name: stefanprodan +sources: +- https://github.com/stefanprodan/steerer diff --git a/charts/podinfo-steerer/README.md b/charts/podinfo-steerer/README.md new file mode 100644 index 00000000..0a578fca --- /dev/null +++ b/charts/podinfo-steerer/README.md @@ -0,0 +1,56 @@ +# Podinfo Istio + +Podinfo is a tiny web application made with Go +that showcases best practices of running microservices in Kubernetes. + +## Installing the Chart + +Create an Istio enabled namespace: + +```console +kubectl create namespace test +kubectl label namespace test istio-injection=enabled +``` + +Create an Istio Gateway in the `istio-system` namespace named `public-gateway`: + +```yaml +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: public-gateway + namespace: istio-system +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - "*" + tls: + httpsRedirect: true + - port: + number: 443 + name: https + protocol: HTTPS + hosts: + - "*" + tls: + mode: SIMPLE + privateKey: /etc/istio/ingressgateway-certs/tls.key + serverCertificate: /etc/istio/ingressgateway-certs/tls.crt +``` + +Create the `frontend` release by specifying the external domain name: + +```console +helm upgrade frontend -i ./charts/podinfo-steerer \ + --namespace=test \ + --set gateway.enabled=true \ + --set gateway.host=podinfo.example.com +``` + + diff --git a/charts/podinfo-steerer/templates/NOTES.txt b/charts/podinfo-steerer/templates/NOTES.txt new file mode 100644 index 00000000..6ea87591 --- /dev/null +++ b/charts/podinfo-steerer/templates/NOTES.txt @@ -0,0 +1 @@ + {{ template "podinfo-steerer.fullname" . }} has been deployed successfully! diff --git a/charts/podinfo-steerer/templates/_helpers.tpl b/charts/podinfo-steerer/templates/_helpers.tpl new file mode 100644 index 00000000..b2667ff3 --- /dev/null +++ b/charts/podinfo-steerer/templates/_helpers.tpl @@ -0,0 +1,36 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "podinfo-steerer.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). +The release name is used as a full name. +*/}} +{{- define "podinfo-steerer.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} + +{{- define "podinfo-steerer.primary" -}} +{{- printf "%s-%s" .Release.Name "primary" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "podinfo-steerer.canary" -}} +{{- printf "%s-%s" .Release.Name "canary" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "podinfo-steerer.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + diff --git a/charts/podinfo-steerer/templates/canary-deployment.yaml b/charts/podinfo-steerer/templates/canary-deployment.yaml new file mode 100644 index 00000000..0188696b --- /dev/null +++ b/charts/podinfo-steerer/templates/canary-deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "podinfo-steerer.canary" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + selector: + matchLabels: + app: {{ template "podinfo-steerer.canary" . }} + template: + metadata: + labels: + app: {{ template "podinfo-steerer.canary" . }} + annotations: + prometheus.io/scrape: "true" + spec: + terminationGracePeriodSeconds: 30 + containers: + - name: podinfod + image: "{{ .Values.canary.repository }}:{{ .Values.canary.tag }}" + imagePullPolicy: {{ .Values.imagePullPolicy }} + command: + - ./podinfo + - --port={{ .Values.containerPort }} + - --level={{ .Values.logLevel }} + env: + - name: PODINFO_UI_COLOR + value: green + ports: + - name: http + containerPort: {{ .Values.containerPort }} + protocol: TCP + livenessProbe: + exec: + command: + - podcli + - check + - http + - localhost:{{ .Values.containerPort }}/healthz + readinessProbe: + exec: + command: + - podcli + - check + - http + - localhost:{{ .Values.containerPort }}/readyz + periodSeconds: 3 + volumeMounts: + - name: data + mountPath: /data + resources: +{{ toYaml .Values.resources | indent 12 }} + volumes: + - name: data + emptyDir: {} diff --git a/charts/podinfo-steerer/templates/canary-hpa.yaml b/charts/podinfo-steerer/templates/canary-hpa.yaml new file mode 100644 index 00000000..8a07a280 --- /dev/null +++ b/charts/podinfo-steerer/templates/canary-hpa.yaml @@ -0,0 +1,21 @@ +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "podinfo-steerer.canary" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "podinfo-steerer.canary" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.targetAverageUtilization }} diff --git a/charts/podinfo-steerer/templates/canary-service.yaml b/charts/podinfo-steerer/templates/canary-service.yaml new file mode 100644 index 00000000..efa21cfb --- /dev/null +++ b/charts/podinfo-steerer/templates/canary-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "podinfo-steerer.canary" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.containerPort }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "podinfo-steerer.canary" . }} diff --git a/charts/podinfo-steerer/templates/primary-deployment.yaml b/charts/podinfo-steerer/templates/primary-deployment.yaml new file mode 100644 index 00000000..398321ff --- /dev/null +++ b/charts/podinfo-steerer/templates/primary-deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "podinfo-steerer.primary" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + selector: + matchLabels: + app: {{ template "podinfo-steerer.primary" . }} + template: + metadata: + labels: + app: {{ template "podinfo-steerer.primary" . }} + annotations: + prometheus.io/scrape: "true" + spec: + terminationGracePeriodSeconds: 30 + containers: + - name: podinfod + image: "quay.io/stefanprodan/podinfo:1.1.1" + imagePullPolicy: {{ .Values.imagePullPolicy }} + command: + - ./podinfo + - --port={{ .Values.containerPort }} + - --level={{ .Values.logLevel }} + env: + - name: PODINFO_UI_COLOR + value: blue + ports: + - name: http + containerPort: {{ .Values.containerPort }} + protocol: TCP + livenessProbe: + exec: + command: + - podcli + - check + - http + - localhost:{{ .Values.containerPort }}/healthz + readinessProbe: + exec: + command: + - podcli + - check + - http + - localhost:{{ .Values.containerPort }}/readyz + periodSeconds: 3 + volumeMounts: + - name: data + mountPath: /data + resources: +{{ toYaml .Values.resources | indent 12 }} + volumes: + - name: data + emptyDir: {} diff --git a/charts/podinfo-steerer/templates/primary-hpa.yaml b/charts/podinfo-steerer/templates/primary-hpa.yaml new file mode 100644 index 00000000..4ca3ad55 --- /dev/null +++ b/charts/podinfo-steerer/templates/primary-hpa.yaml @@ -0,0 +1,21 @@ +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "podinfo-steerer.primary" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "podinfo-steerer.primary" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.targetAverageUtilization }} diff --git a/charts/podinfo-steerer/templates/primary-service.yaml b/charts/podinfo-steerer/templates/primary-service.yaml new file mode 100644 index 00000000..5632bcb7 --- /dev/null +++ b/charts/podinfo-steerer/templates/primary-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "podinfo-steerer.primary" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.containerPort }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "podinfo-steerer.primary" . }} diff --git a/charts/podinfo-steerer/templates/virtual-service.yaml b/charts/podinfo-steerer/templates/virtual-service.yaml new file mode 100644 index 00000000..30b14632 --- /dev/null +++ b/charts/podinfo-steerer/templates/virtual-service.yaml @@ -0,0 +1,30 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "podinfo-steerer.fullname" . }} + labels: + app: {{ template "podinfo-steerer.fullname" . }} + chart: {{ template "podinfo-steerer.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + hosts: + - {{ template "podinfo-steerer.fullname" . }} +{{- if .Values.gateway.enabled }} + - {{ .Values.gateway.host }} + gateways: + - {{ .Values.gateway.name }} +{{- end }} + http: + - route: + - destination: + host: {{ template "podinfo-steerer.primary" . }} + port: + number: {{ .Values.containerPort }} + weight: 100 + - destination: + host: {{ template "podinfo-steerer.canary" . }} + port: + number: {{ .Values.containerPort }} + weight: 0 + timeout: {{ .Values.timeout }} diff --git a/charts/podinfo-steerer/values.yaml b/charts/podinfo-steerer/values.yaml new file mode 100644 index 00000000..ceab3563 --- /dev/null +++ b/charts/podinfo-steerer/values.yaml @@ -0,0 +1,30 @@ +# Default values for podinfo-steerer. + +canary: + repository: quay.io/stefanprodan/podinfo + tag: "1.2.0" + +# enable the gateway when exposing the service outside the cluster +gateway: + enabled: false + name: public-gateway.istio-system.svc.cluster.local + # external domain name + host: + +hpa: + minReplicas: 2 + maxReplicas: 4 + targetAverageUtilization: 99 + +timeout: 30s +logLevel: info +containerPort: 9898 +imagePullPolicy: IfNotPresent + +resources: + limits: + cpu: 2000m + memory: 512Mi + requests: + cpu: 100m + memory: 64Mi diff --git a/docs/index.yaml b/docs/index.yaml index 5a584f88..76b3287c 100755 --- a/docs/index.yaml +++ b/docs/index.yaml @@ -1,15 +1,32 @@ apiVersion: v1 entries: + podinfo-steerer: + - apiVersion: v1 + appVersion: 1.2.1 + created: 2018-10-02T00:17:11.434625+03:00 + description: Podinfo Helm chart for Steerer progressive delivery + digest: 6a3cd952095487550b019f6b861c59f243ca62294c01fe58e8f87f7af16d7d25 + engine: gotpl + home: https://github.com/stefanprodan/k8s-podinfo + maintainers: + - email: stefanprodan@users.noreply.github.com + name: stefanprodan + name: podinfo-steerer + sources: + - https://github.com/stefanprodan/steerer + urls: + - https://stefanprodan.github.io/steerer/podinfo-steerer-1.2.1.tgz + version: 1.2.1 steerer: - apiVersion: v1 - appVersion: 0.0.1-rc.6 - created: 2018-09-30T09:47:15.355564357+03:00 + appVersion: 0.0.1-rc.16 + created: 2018-10-02T00:17:11.435078+03:00 description: Steerer is a Kubernetes operator that automates the promotion of canary deployments using Istio routing for traffic shifting and Prometheus metrics for canary analysis. - digest: 02c30ba24d2fc0e00238fe12c5cf8525a4dbf5192af555a104f64e7bd2dbb35a + digest: 44e8f383aabc9c27cf456ba1ca99ccbca4bc201400f109e6914bad2610253d3e name: steerer urls: - https://stefanprodan.github.io/steerer/steerer-0.0.1.tgz version: 0.0.1 -generated: 2018-09-30T09:47:15.354615937+03:00 +generated: 2018-10-02T00:17:11.433476+03:00