diff --git a/Makefile b/Makefile index c59207a..ccd4801 100644 --- a/Makefile +++ b/Makefile @@ -105,9 +105,9 @@ dep: .PHONY: charts charts: cd charts/ && helm package podinfo/ + cd charts/ && helm package podinfo-istio/ cd charts/ && helm package ambassador/ cd charts/ && helm package grafana/ cd charts/ && helm package ngrok/ - cd charts/ && helm package weave-flux/ mv charts/*.tgz docs/ helm repo index docs --url https://stefanprodan.github.io/k8s-podinfo --merge ./docs/index.yaml diff --git a/charts/weave-cloud/.helmignore b/charts/podinfo-istio/.helmignore similarity index 100% rename from charts/weave-cloud/.helmignore rename to charts/podinfo-istio/.helmignore diff --git a/charts/podinfo-istio/Chart.yaml b/charts/podinfo-istio/Chart.yaml new file mode 100644 index 0000000..cb3aaf3 --- /dev/null +++ b/charts/podinfo-istio/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +appVersion: "0.6.0" +description: Podinfo Helm chart for Istio +name: podinfo-istio +version: 0.1.0 +home: https://github.com/stefanprodan/k8s-podinfo +sources: +- https://github.com/stefanprodan/k8s-podinfo +maintainers: + - name: stefanprodan + email: stefanprodan@users.noreply.github.com +engine: gotpl diff --git a/charts/podinfo-istio/README.md b/charts/podinfo-istio/README.md new file mode 100644 index 0000000..13cb345 --- /dev/null +++ b/charts/podinfo-istio/README.md @@ -0,0 +1,81 @@ +# Podinfo Istio + +Podinfo is a tiny web application made with Go +that showcases best practices of running microservices in Kubernetes. + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +kubectl create namespace demo +kubectl label namespace demo istio-injection=enabled +``` + +```console +$ helm install podinfo-istio --name my-release -namespace demo +``` + +The command deploys podinfo-istio on the Kubernetes cluster in the default namespace. +The [configuration](#configuration) section lists the parameters that can be configured during installation. + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete --purge my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the podinfo-istio.chart and their default values. + +Parameter | Description | Default +--- | --- | --- +`affinity` | node/pod affinities | None +`hpa.enabled` | Enables HPA | `false` +`hpa.cpu` | Target CPU usage per pod | None +`hpa.memory` | Target memory usage per pod | None +`hpa.requests` | Target requests per second per pod | None +`hpa.maxReplicas` | Maximum pod replicas | `10` +`ingress.hosts` | Ingress accepted hostnames | None +`ingress.tls` | Ingress TLS configuration | None: +`image.pullPolicy` | Image pull policy | `IfNotPresent` +`image.repository` | Image repository | `stefanprodan/podinfo-istio. +`image.tag` | Image tag | `0.0.1` +`ingress.enabled` | Enables Ingress | `false` +`ingress.annotations` | Ingress annotations | None +`ingress.hosts` | Ingress accepted hostnames | None +`ingress.tls` | Ingress TLS configuration | None +`nodeSelector` | node labels for pod assignment | `{}` +`podAnnotations` | annotations to add to each pod | `{}` +`replicaCount` | desired number of pods | `1` +`resources.requests/cpu` | pod CPU request | `1m` +`resources.requests/memory` | pod memory request | `16Mi` +`resources.limits/cpu` | pod CPU limit | None +`resources.limits/memory` | pod memory limit | None +`service.externalPort` | external port for the service | `9898` +`service.internalPort` | internal port for the service | `9898` +`service.nodePort` | node port for the service | `31198` +`service.type` | type of service | `ClusterIP` +`tolerations` | List of node taints to tolerate | `[]` + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install stable/podinfo-istio.--name my-release \ + --set=image.tag=0.0.2,service.type=NodePort +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install podinfo-istio --name my-release -f values.yaml +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) +``` + diff --git a/charts/podinfo-istio/templates/NOTES.txt b/charts/podinfo-istio/templates/NOTES.txt new file mode 100644 index 0000000..680a26e --- /dev/null +++ b/charts/podinfo-istio/templates/NOTES.txt @@ -0,0 +1 @@ + {{ template "podinfo-istio.fullname" . }} has been deployed successfully! diff --git a/charts/weave-cloud/templates/_helpers.tpl b/charts/podinfo-istio/templates/_helpers.tpl similarity index 69% rename from charts/weave-cloud/templates/_helpers.tpl rename to charts/podinfo-istio/templates/_helpers.tpl index 2de28c4..6639581 100644 --- a/charts/weave-cloud/templates/_helpers.tpl +++ b/charts/podinfo-istio/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{- define "weave-cloud.name" -}} +{{- define "podinfo-istio.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -11,22 +11,25 @@ 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 "weave-cloud.fullname" -}} +{{- define "podinfo-istio.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 -}} + +{{- define "podinfo-istio.blue" -}} +{{- printf "%s-%s" .Release.Name "blue" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "podinfo-istio.green" -}} +{{- printf "%s-%s" .Release.Name "green" | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Create chart name and version as used by the chart label. */}} -{{- define "weave-cloud.chart" -}} +{{- define "podinfo-istio.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} diff --git a/charts/podinfo-istio/templates/blue-deployment.yaml b/charts/podinfo-istio/templates/blue-deployment.yaml new file mode 100644 index 0000000..d3a4403 --- /dev/null +++ b/charts/podinfo-istio/templates/blue-deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "podinfo-istio.blue" . }} + labels: + app: {{ template "podinfo-istio.fullname" . }} + chart: {{ template "podinfo-istio.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + color: blue + version: {{ .Values.blue.tag }} +spec: + replicas: {{ .Values.blue.replicas }} + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + selector: + matchLabels: + app: {{ template "podinfo-istio.fullname" . }} + color: blue + version: {{ .Values.blue.tag }} + template: + metadata: + labels: + app: {{ template "podinfo-istio.fullname" . }} + color: blue + version: {{ .Values.blue.tag }} + annotations: + prometheus.io/scrape: 'true' + spec: + terminationGracePeriodSeconds: 30 + containers: + - name: podinfod + image: "{{ .Values.blue.repository }}:{{ .Values.blue.tag }}" + imagePullPolicy: {{ .Values.imagePullPolicy }} + command: + - ./podinfo + - -port={{ .Values.containerPort }} + - -logLevel={{ .Values.logLevel }} + env: + - name: color + value: blue + {{- if .Values.backend }} + - name: backendURL + value: {{ .Values.backend }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.containerPort }} + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: 9898 + initialDelaySeconds: 1 + periodSeconds: 2 + failureThreshold: 1 + livenessProbe: + httpGet: + path: /healthz + port: 9898 + initialDelaySeconds: 1 + periodSeconds: 10 + failureThreshold: 2 + volumeMounts: + - name: data + mountPath: /data + resources: +{{ toYaml .Values.resources | indent 12 }} + volumes: + - name: data + emptyDir: {} diff --git a/charts/podinfo-istio/templates/destionation-rule.yaml b/charts/podinfo-istio/templates/destionation-rule.yaml new file mode 100644 index 0000000..9e1f183 --- /dev/null +++ b/charts/podinfo-istio/templates/destionation-rule.yaml @@ -0,0 +1,18 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: DestinationRule +metadata: + name: {{ template "podinfo-istio.fullname" . }} + labels: + app: {{ template "podinfo-istio.fullname" . }} + chart: {{ template "podinfo-istio.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + host: {{ template "podinfo-istio.fullname" . }} + subsets: + - name: blue + labels: + color: blue + - name: green + labels: + color: green \ No newline at end of file diff --git a/charts/podinfo-istio/templates/gateway.yaml b/charts/podinfo-istio/templates/gateway.yaml new file mode 100644 index 0000000..e1b1977 --- /dev/null +++ b/charts/podinfo-istio/templates/gateway.yaml @@ -0,0 +1,31 @@ +{{- if .Values.gateway.create -}} +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ .Values.gateway.name }} + namespace: istio-system +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - "*" + tls: + httpsRedirect: {{ .Values.gateway.httpsRedirect }} + {{- if .Values.gateway.tls }} + - 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 + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/podinfo-istio/templates/green-deployment.yaml b/charts/podinfo-istio/templates/green-deployment.yaml new file mode 100644 index 0000000..a9721e1 --- /dev/null +++ b/charts/podinfo-istio/templates/green-deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "podinfo-istio.green" . }} + labels: + app: {{ template "podinfo-istio.fullname" . }} + chart: {{ template "podinfo-istio.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + color: green + version: {{ .Values.green.tag }} +spec: + replicas: {{ .Values.green.replicas }} + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + selector: + matchLabels: + app: {{ template "podinfo-istio.fullname" . }} + color: green + version: {{ .Values.green.tag }} + template: + metadata: + labels: + app: {{ template "podinfo-istio.fullname" . }} + color: green + version: {{ .Values.green.tag }} + annotations: + prometheus.io/scrape: 'true' + spec: + terminationGracePeriodSeconds: 30 + containers: + - name: podinfod + image: "{{ .Values.green.repository }}:{{ .Values.green.tag }}" + imagePullPolicy: {{ .Values.imagePullPolicy }} + command: + - ./podinfo + - -port={{ .Values.containerPort }} + - -logLevel={{ .Values.logLevel }} + env: + - name: color + value: green + {{- if .Values.backend }} + - name: backendURL + value: {{ .Values.backend }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.containerPort }} + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: 9898 + initialDelaySeconds: 1 + periodSeconds: 2 + failureThreshold: 1 + livenessProbe: + httpGet: + path: /healthz + port: 9898 + initialDelaySeconds: 1 + periodSeconds: 10 + failureThreshold: 2 + volumeMounts: + - name: data + mountPath: /data + resources: +{{ toYaml .Values.resources | indent 12 }} + volumes: + - name: data + emptyDir: {} diff --git a/charts/podinfo-istio/templates/service.yaml b/charts/podinfo-istio/templates/service.yaml new file mode 100644 index 0000000..66e0594 --- /dev/null +++ b/charts/podinfo-istio/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "podinfo-istio.fullname" . }} + labels: + app: {{ template "podinfo-istio.fullname" . }} + chart: {{ template "podinfo-istio.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.containerPort }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "podinfo-istio.fullname" . }} diff --git a/charts/podinfo-istio/templates/virtual-service.yaml b/charts/podinfo-istio/templates/virtual-service.yaml new file mode 100644 index 0000000..a87d694 --- /dev/null +++ b/charts/podinfo-istio/templates/virtual-service.yaml @@ -0,0 +1,36 @@ +{{- $host := .Release.Name -}} +{{- $timeout := .Values.timeout -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "podinfo-istio.fullname" . }} + labels: + app: {{ template "podinfo-istio.fullname" . }} + chart: {{ template "podinfo-istio.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + hosts: + - {{ .Values.host }} +{{- if .Values.exposeHost }} + gateways: + - {{ .Values.gateway.name }}.istio-system.svc.cluster.local +{{- end }} + http: + {{- if gt .Values.green.replicas 0.0 }} + {{- range .Values.green.routing }} + - match: +{{ toYaml .match | indent 6 }} + route: + - destination: + host: {{ $host }} + subset: green + timeout: {{ $timeout }} + {{- end }} + {{- end }} + # default route + - route: + - destination: + host: {{ template "podinfo-istio.fullname" . }} + subset: blue + timeout: {{ .Values.timeout }} \ No newline at end of file diff --git a/charts/podinfo-istio/values.yaml b/charts/podinfo-istio/values.yaml new file mode 100644 index 0000000..f845b54 --- /dev/null +++ b/charts/podinfo-istio/values.yaml @@ -0,0 +1,55 @@ +# Default values for podinfo-istio. + + +# host can be an extarnal domain or a local one as in podinfo.test.svc.cluster.local +host: canary.istio.weavedx.com +# if the host is an external domain must be exposed via the Gateway +exposeHost: true +timeout: 30s + +# no more than one Gateway can be created on a cluster +# if TLS is enabled the istio-ingressgateway-certs secret must exist in istio-system ns +# if you have a Gateway running you can set the name to your own gateway and turn off create +gateway: + name: public-gateway + # creates public-gateway.istio-system.svc.cluster.local + create: false + tls: true + httpsRedirect: true + +# stable release +# by default all traffic goes to blue +blue: + replicas: 2 + repository: quay.io/stefanprodan/podinfo + tag: 0.6.0 + backend: + +# canary release +# can be disabled by setting replicas to 0 +green: + replicas: 2 + repository: quay.io/stefanprodan/podinfo + tag: 0.6.1 + routing: + # target Safari + - match: + - headers: + user-agent: + regex: "^(?!.*Chrome).*Safari.*" + # target API clients by version + - match: + - headers: + x-api-version: + regex: "^(v{0,1})0\\.6\\.([1-9]).*" + backend: + +# blue/green common settings +logLevel: info +containerPort: 9898 +imagePullPolicy: IfNotPresent +resources: + limits: + requests: + cpu: 1m + memory: 16Mi \ No newline at end of file diff --git a/docs/index.yaml b/docs/index.yaml index e35e742..2bb52fb 100755 --- a/docs/index.yaml +++ b/docs/index.yaml @@ -3,7 +3,7 @@ entries: ambassador: - apiVersion: v1 appVersion: 0.29.0 - created: 2018-08-16T00:03:51.210499364+03:00 + created: 2018-08-16T15:14:32.45299943+03:00 description: A Helm chart for Datawire Ambassador digest: a30c8cb38e696b09fda8269ad8465ce6fec6100cfc108ca85ecbc85913ca5c7f engine: gotpl @@ -19,7 +19,7 @@ entries: grafana: - apiVersion: v1 appVersion: "1.0" - created: 2018-08-16T00:03:51.211170354+03:00 + created: 2018-08-16T15:14:32.45369699+03:00 description: A Helm chart for Kubernetes digest: abdcadc5cddcb7c015aa5bb64e59bfa246774ad9243b3eb3c2a814abb38f2776 name: grafana @@ -29,7 +29,7 @@ entries: ngrok: - apiVersion: v1 appVersion: "1.0" - created: 2018-08-16T00:03:51.211452823+03:00 + created: 2018-08-16T15:14:32.453994154+03:00 description: A Ngrok Helm chart for Kubernetes digest: 7bf5ed2ef63ccd5efb76bcd9a086b04816a162c51d6ab592bccf58c283acd2ea name: ngrok @@ -39,9 +39,9 @@ entries: podinfo: - apiVersion: v1 appVersion: 0.6.0 - created: 2018-08-16T00:03:51.214668506+03:00 + created: 2018-08-16T15:14:32.45935387+03:00 description: Podinfo Helm chart for Kubernetes - digest: 27ba84d7fe19f72e15a7f0b61492268c1a1f5ed8bc5467f87ed04b4409073173 + digest: dab20fb79c55badd3fb923c6a204a7a7915490cb37a9eadf7ee7d91c5977fec2 engine: gotpl home: https://github.com/stefanprodan/k8s-podinfo maintainers: @@ -55,7 +55,7 @@ entries: version: 0.2.2 - apiVersion: v1 appVersion: 0.5.1 - created: 2018-08-16T00:03:51.214206947+03:00 + created: 2018-08-16T15:14:32.458873487+03:00 description: Podinfo Helm chart for Kubernetes digest: 631ca3e2db5553541a50b625f538e6a1f2a103c13aa8148fdd38baf2519e5235 engine: gotpl @@ -71,7 +71,7 @@ entries: version: 0.2.1 - apiVersion: v1 appVersion: 0.5.0 - created: 2018-08-16T00:03:51.213413197+03:00 + created: 2018-08-16T15:14:32.457991323+03:00 description: Podinfo Helm chart for Kubernetes digest: dfe7cf44aef0d170549918b00966422a07e7611f9d0081fb34f5b5beb0641c00 engine: gotpl @@ -87,7 +87,7 @@ entries: version: 0.2.0 - apiVersion: v1 appVersion: 0.3.0 - created: 2018-08-16T00:03:51.212459375+03:00 + created: 2018-08-16T15:14:32.456942217+03:00 description: Podinfo Helm chart for Kubernetes digest: 4865a2d8b269cf453935cda9661c2efb82c16411471f8c11221a6d03d9bb58b1 engine: gotpl @@ -101,41 +101,21 @@ entries: urls: - https://stefanprodan.github.io/k8s-podinfo/podinfo-0.1.0.tgz version: 0.1.0 - weave-flux: + podinfo-istio: - apiVersion: v1 - appVersion: 1.3.0 - created: 2018-08-16T00:03:51.216272023+03:00 - description: Flux is a tool that automatically ensures that the state of a cluster - matches what is specified in version control - digest: 1f52e427bb1d728641405f5ad9c514e8861905c110c14db95516629d24443b7d + appVersion: 0.6.0 + created: 2018-08-16T15:14:32.459743584+03:00 + description: Podinfo Helm chart for Istio + digest: fca748e8655beee0e67a32c496bec5ae4bae2f2d8c6eb3f5132c03aa530b3221 engine: gotpl - home: https://weave.works - icon: https://landscape.cncf.io/logos/weave-flux.svg + home: https://github.com/stefanprodan/k8s-podinfo maintainers: - - email: stefan@weave.works + - email: stefanprodan@users.noreply.github.com name: stefanprodan - name: weave-flux + name: podinfo-istio sources: - - https://github.com/weaveworks/flux + - https://github.com/stefanprodan/k8s-podinfo urls: - - https://stefanprodan.github.io/k8s-podinfo/weave-flux-0.2.0.tgz - version: 0.2.0 - - apiVersion: v1 - appVersion: 1.2.5 - created: 2018-08-16T00:03:51.215743562+03:00 - description: Flux is a tool that automatically ensures that the state of a cluster - matches what is specified in version control - digest: 9e18fb8d175f4fac3b054905c7110d18b6d18f884011df9e9d010c66337da7ec - engine: gotpl - home: https://weave.works - icon: https://www.weave.works/assets/images/bltd108e8f850ae9e7c/weave-logo-512.png - maintainers: - - email: stefan@weave.works - name: Stefan Prodan - name: weave-flux - sources: - - https://github.com/weaveworks/flux - urls: - - https://stefanprodan.github.io/k8s-podinfo/weave-flux-0.1.0.tgz + - https://stefanprodan.github.io/k8s-podinfo/podinfo-istio-0.1.0.tgz version: 0.1.0 -generated: 2018-08-16T00:03:51.209830596+03:00 +generated: 2018-08-16T15:14:32.452369998+03:00 diff --git a/docs/podinfo-0.2.2.tgz b/docs/podinfo-0.2.2.tgz index 2383ed7..c31b76a 100644 Binary files a/docs/podinfo-0.2.2.tgz and b/docs/podinfo-0.2.2.tgz differ diff --git a/docs/podinfo-istio-0.1.0.tgz b/docs/podinfo-istio-0.1.0.tgz new file mode 100644 index 0000000..8520aa5 Binary files /dev/null and b/docs/podinfo-istio-0.1.0.tgz differ diff --git a/docs/weave-flux-0.1.0.tgz b/docs/weave-flux-0.1.0.tgz deleted file mode 100644 index 6be9128..0000000 Binary files a/docs/weave-flux-0.1.0.tgz and /dev/null differ diff --git a/docs/weave-flux-0.2.0.tgz b/docs/weave-flux-0.2.0.tgz deleted file mode 100644 index ee3c02a..0000000 Binary files a/docs/weave-flux-0.2.0.tgz and /dev/null differ