From 65e6abdd648488175c7666566f4442bd54d02fe9 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 13 Mar 2018 11:26:44 +0200 Subject: [PATCH] Ambassador helm chart v0.1.0 --- chart/stable/ambassador/.helmignore | 21 ++++++ chart/stable/ambassador/Chart.yaml | 11 +++ chart/stable/ambassador/README.md | 70 ++++++++++++++++++ chart/stable/ambassador/templates/NOTES.txt | 15 ++++ .../stable/ambassador/templates/_helpers.tpl | 43 +++++++++++ .../ambassador/templates/deployment.yaml | 72 +++++++++++++++++++ chart/stable/ambassador/templates/rbac.yaml | 42 +++++++++++ .../stable/ambassador/templates/service.yaml | 23 ++++++ .../ambassador/templates/serviceaccount.yaml | 11 +++ chart/stable/ambassador/values.yaml | 44 ++++++++++++ 10 files changed, 352 insertions(+) create mode 100644 chart/stable/ambassador/.helmignore create mode 100644 chart/stable/ambassador/Chart.yaml create mode 100755 chart/stable/ambassador/README.md create mode 100644 chart/stable/ambassador/templates/NOTES.txt create mode 100644 chart/stable/ambassador/templates/_helpers.tpl create mode 100644 chart/stable/ambassador/templates/deployment.yaml create mode 100644 chart/stable/ambassador/templates/rbac.yaml create mode 100644 chart/stable/ambassador/templates/service.yaml create mode 100644 chart/stable/ambassador/templates/serviceaccount.yaml create mode 100644 chart/stable/ambassador/values.yaml diff --git a/chart/stable/ambassador/.helmignore b/chart/stable/ambassador/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/chart/stable/ambassador/.helmignore @@ -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 diff --git a/chart/stable/ambassador/Chart.yaml b/chart/stable/ambassador/Chart.yaml new file mode 100644 index 0000000..b354915 --- /dev/null +++ b/chart/stable/ambassador/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +appVersion: "0.28.2" +description: A Helm chart for Datawire Ambassador +name: ambassador +version: 0.1.0 +sources: +- https://github.com/datawire/ambassador +maintainers: + - name: stefanprodan + email: stefanprodan@users.noreply.github.com +engine: gotpl diff --git a/chart/stable/ambassador/README.md b/chart/stable/ambassador/README.md new file mode 100755 index 0000000..f71a127 --- /dev/null +++ b/chart/stable/ambassador/README.md @@ -0,0 +1,70 @@ +# Ambassador + +Ambassador is an open source, Kubernetes-native [microservices API gateway](https://www.getambassador.io/about/microservices-api-gateways) built on the [Envoy Proxy](https://www.envoyproxy.io/). + +## TL;DR; + +```console +$ helm install stable/ambassador +``` + +## Introduction + +This chart bootstraps an [Ambassador](https://www.getambassador.io) deployment on +a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.7+ + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release stable/ambassador +``` + +The command deploys Ambassador API gateway on the Kubernetes cluster in the default configuration. +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 Ambassador chart and their default values. + +| Parameter | Description | Default | +| ------------------------------- | ------------------------------------------ | ---------------------------------------------------------- | +| `image` | Image | `quay.io/datawire/ambassador` +| `imageTag` | Image tag | `0.28.0` +| `imagePullPolicy` | Image pull policy | `IfNotPresent` +| `replicaCount` | Number of ambassador replicas | `1` +| `resources` | CPU/memory resource requests/limits | None +| `rbac.create` | If `true`, create and use RBAC resources | `true` +| `serviceAccount.create` | If `true`, create a new service account | `true` +| `serviceAccount.name` | Service account to be used | `ambassador` +| `service.type` | Service type to be used | `LoadBalancer` +| `exporter.image` | Prometheus exporter image | `datawire/prom-statsd-exporter:0.6.0` + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm upgrade --install --wait --name my-release \ + --set service.type=NodePort \ + stable/ambassador +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm upgrade --install --wait --name my-release -f values.yaml stable/ambassador +``` diff --git a/chart/stable/ambassador/templates/NOTES.txt b/chart/stable/ambassador/templates/NOTES.txt new file mode 100644 index 0000000..202dc82 --- /dev/null +++ b/chart/stable/ambassador/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ambassador.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "ambassador.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ambassador.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ambassador.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/chart/stable/ambassador/templates/_helpers.tpl b/chart/stable/ambassador/templates/_helpers.tpl new file mode 100644 index 0000000..6540f58 --- /dev/null +++ b/chart/stable/ambassador/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "ambassador.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 "ambassador.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 "ambassador.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ambassador.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "ambassador.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/chart/stable/ambassador/templates/deployment.yaml b/chart/stable/ambassador/templates/deployment.yaml new file mode 100644 index 0000000..d6bbffd --- /dev/null +++ b/chart/stable/ambassador/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "ambassador.fullname" . }} + labels: + app: {{ template "ambassador.name" . }} + chart: {{ template "ambassador.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "ambassador.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "ambassador.name" . }} + release: {{ .Release.Name }} + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9102" + spec: + serviceAccountName: {{ template "ambassador.serviceAccountName" . }} + containers: + - name: statsd-sink + image: "{{ .Values.exporter.image }}" + ports: + - name: metrics + containerPort: 9102 + - name: ambassador + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + - name: admin + containerPort: 8877 + env: + - name: AMBASSADOR_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + livenessProbe: + httpGet: + path: /ambassador/v0/check_alive + port: admin + initialDelaySeconds: 10 + periodSeconds: 3 + readinessProbe: + httpGet: + path: /ambassador/v0/check_ready + port: admin + initialDelaySeconds: 10 + periodSeconds: 3 + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/chart/stable/ambassador/templates/rbac.yaml b/chart/stable/ambassador/templates/rbac.yaml new file mode 100644 index 0000000..ecf9458 --- /dev/null +++ b/chart/stable/ambassador/templates/rbac.yaml @@ -0,0 +1,42 @@ +{{- if .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: {{ template "ambassador.fullname" . }} + labels: + app: {{ template "ambassador.name" . }} + chart: {{ template "ambassador.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +rules: + - apiGroups: [""] + resources: + - services + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: + - configmaps + verbs: ["create", "update", "patch", "get", "list", "watch"] + - apiGroups: [""] + resources: + - secrets + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: {{ template "ambassador.fullname" . }} + labels: + app: {{ template "ambassador.name" . }} + chart: {{ template "ambassador.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "ambassador.fullname" . }} +subjects: + - name: {{ template "ambassador.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} + kind: ServiceAccount +{{- end -}} diff --git a/chart/stable/ambassador/templates/service.yaml b/chart/stable/ambassador/templates/service.yaml new file mode 100644 index 0000000..e57add9 --- /dev/null +++ b/chart/stable/ambassador/templates/service.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "ambassador.fullname" . }} + labels: + app: {{ template "ambassador.name" . }} + chart: {{ template "ambassador.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + - port: 443 + targetPort: https + protocol: TCP + name: https + selector: + app: {{ template "ambassador.name" . }} + release: {{ .Release.Name }} diff --git a/chart/stable/ambassador/templates/serviceaccount.yaml b/chart/stable/ambassador/templates/serviceaccount.yaml new file mode 100644 index 0000000..ae5644e --- /dev/null +++ b/chart/stable/ambassador/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "ambassador.serviceAccountName" . }} + labels: + app: {{ template "ambassador.name" . }} + chart: {{ template "ambassador.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- end -}} diff --git a/chart/stable/ambassador/values.yaml b/chart/stable/ambassador/values.yaml new file mode 100644 index 0000000..5ffc630 --- /dev/null +++ b/chart/stable/ambassador/values.yaml @@ -0,0 +1,44 @@ +# Default values for ambassador. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: quay.io/datawire/ambassador + tag: 0.28.0 + pullPolicy: IfNotPresent + +service: + type: LoadBalancer + port: 80 + +rbac: + # Specifies whether RBAC resources should be created + create: true + +serviceAccount: + # Specifies whether a service account should be created + create: true + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +resources: {} + # If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +exporter: + image: datawire/prom-statsd-exporter:0.6.0