diff --git a/incubator/honeydipper/.helmignore b/incubator/honeydipper/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/incubator/honeydipper/.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/incubator/honeydipper/Chart.yaml b/incubator/honeydipper/Chart.yaml new file mode 100644 index 0000000000..1529940f81 --- /dev/null +++ b/incubator/honeydipper/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +appVersion: 0.1.9 +description: An event driven orchestration system +name: honeydipper +version: 0.1.2 +icon: "https://raw.githubusercontent.com/honeydipper/honeydipper/master/logo/log_medium.png" +home: "https://honeydipper.io" +maintainers: + - name: Charles546 + email: charles.huang@joinhoney.com + url: https://honeydipper.io +keywords: + - event-driven + - orchestration + - integration + - workflows + - templating diff --git a/incubator/honeydipper/OWNERS b/incubator/honeydipper/OWNERS new file mode 100644 index 0000000000..e8ba28546f --- /dev/null +++ b/incubator/honeydipper/OWNERS @@ -0,0 +1,6 @@ +approvers: +- Charles546 +- wyardley +reviewers: +- Charles546 +- wyardley diff --git a/incubator/honeydipper/README.md b/incubator/honeydipper/README.md new file mode 100644 index 0000000000..fd570c977d --- /dev/null +++ b/incubator/honeydipper/README.md @@ -0,0 +1,109 @@ +# Honeydipper + +[Honeydipper](https://github.com/honeydipper/honeydipper) is basically, your swiss army knife for systems engineering and operations. An event-driven, policy-based orchestration system, with a pluggable open architecture. + +## Introduction + +This chart creates a deployment to run the Honeydipper daemon, and exposes a service pointing to the webhook listener. + +## Prerequisites + + * Kubernetes 1.10+ + +## Required Configuration + +Honeydipper daemon loads most of the configurations from git repos. To start, a few environment variables are required to bootstrap repo. Below are the settings required. + + * daemon.env.REPO, defaults to `https://github.com/honeydipper/honeydipper-config-essentials.git` + +Please refer to [values.yaml](./values.yaml) for detailed example. + +## Customization + +The following options are supported . See [values.yaml](./values.yaml) for more detailed explanation and examples: + +| Parameter | Description | Default | +| --------- | ----------- | ------- | +| daemon.dnsConfig | dnsConfig specifies the DNS parameters of the pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy | | +| daemon.serviceAccountName | name of the ServiceAccount to use to run this pod, More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ | | +| daemon.replicaCount | The number of replicas of daemons to start | 1 | +| daemon.image.repository | The docker image for Honeydipper daemon | `honeydipper/honeydipper` | +| daemon.image.tag | The version tag of the docker image to use | `latest` | +| daemon.image.pullPolicy | Pull policy for the docker image | `Always` | +| daemon.args | Honeydipper daemon args, should be a list of Honeydipper daemon services, empty means all | | +| daemon.resources | The pod resource spec, cpu limit, memory limit, etc., as defined in a pod sped | | +| daemon.nodeSelector | A map of node selectors for the pod, as defined in a pod sped | | +| daemon.affinity | A map of affinity settings for the pod, as defined in a pod sped | | +| daemon.tolerations | A list of toleration settings for the pod, as defined in a pod sped | | +| daemon.extraVolumes | A list of volumns to be added to the pod | | +| daemon.extraVolumeMounts | A list of volumns to be mounted to main daemon container | | +| daemon.env | A list of environment variables to be added to the main daemon container | | +| drivers.webhook.service.type | The exposed service type for the webhook | `LoadBalancer` | +| drivers.webhook.service.port | The exposed service port for the webhook, needs to match the driver configurations set in the configuration repo | 8080 | +| drivers.webhook.service.nodePort | The exposed service node port for the webhook. If set to 0, Kubernetes will assign a random port. | 0 | +| drivers.webhook.ingress.enabled | Use ingress controller for the webhook service | `false` | +| drivers.webhook.ingress.annotations | If using ingress controllers, specify a map of anotations | | +| drivers.webhook.ingress.path | If using ingress controllers, specify the path mapped to webhook | | +| drivers.webhook.ingress.hosts | If using ingress controllers, specify a list of host names for the webhook | | +| drivers.webhook.ingress.tls | If using ingress controllers, specify the secret that defines the key and certs | | +| drivers.redis.local | Use redis sidecar container for eventbus, this is only useful for testing. In production, multiple replicas of daemon should share the redis server | true | +| drivers.redis.image.repository | When using redis sidecar container for eventbus, this is used to specify the image repository | redis | +| drivers.redis.image.tag | When using redis sidecar container for eventbus, this is used to specify the image tag | 5 | + +### Specifying environment + +Using command line: + +```helm +helm -f values.yaml install --name test incubator/honeydipper +``` + +In values file + +```yaml +daemon: + env: + - name: REPO + value: git@github.com:example/example.git + - name: BOOTSTRAP_PATH + value: /submodule + - name: BRANCH + value: test_branch + - name: SECRET_VARIABLE + valueFrom: + secretRef: + name: my-secret + key: my-key +``` + +### Mounting volumes + +Using values file + +```yaml +daemon: + extraVolumeMounts: + - name: my-config + mountPath: /etc/myconfig/file + subPath: file + extraVolumes: + - name: my-config + configMap: + name: my-config +``` + +## Testing the Deployment + +To perform a sanity test (i.e. ensure Honeydipper daemon is running, and when you curl the webhook url `http(s)://your-service-url/health`, you should get a `200` response code.) + + 1. Install the chart + +```bash +helm install -f test-values.yaml --name trial incubator/honeydipper --debug +``` + + 2. Run the tests + +```bash +helm test trial +``` diff --git a/incubator/honeydipper/templates/NOTES.txt b/incubator/honeydipper/templates/NOTES.txt new file mode 100644 index 0000000000..35bd08f748 --- /dev/null +++ b/incubator/honeydipper/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.drivers.webhook.ingress.enabled }} +{{- range .Values.drivers.webhook.ingress.hosts }} + http{{ if $.Values.drivers.webhook.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.drivers.webhook.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.drivers.webhook.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "honeydipper.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.drivers.webhook.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 {{ include "honeydipper.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "honeydipper.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.drivers.webhook.service.port }} +{{- else if contains "ClusterIP" .Values.drivers.webhook.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "honeydipper.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Try sending your webhook request to http://127.0.0.1:8080" + kubectl port-forward $POD_NAME 8080:8080 +{{- end }} diff --git a/incubator/honeydipper/templates/_helpers.tpl b/incubator/honeydipper/templates/_helpers.tpl new file mode 100644 index 0000000000..da40fc7bfc --- /dev/null +++ b/incubator/honeydipper/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "honeydipper.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 "honeydipper.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 "honeydipper.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/incubator/honeydipper/templates/daemon-deployment.yaml b/incubator/honeydipper/templates/daemon-deployment.yaml new file mode 100644 index 0000000000..d2c592ae1f --- /dev/null +++ b/incubator/honeydipper/templates/daemon-deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "honeydipper.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "honeydipper.name" . }} + helm.sh/chart: {{ include "honeydipper.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.daemon.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "honeydipper.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "honeydipper.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + {{- with .Values.daemon.dnsConfig }} + dnsConfig: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.daemon.serviceAccountName }} + serviceAccountName: "{{ . }}" + {{- end }} + containers: + {{- if .Values.drivers.redis.local }} + - name: {{ .Chart.Name }}-redis + image: "{{ .Values.drivers.redis.image.repository }}:{{ .Values.drivers.redis.image.tag }}" + {{- end }} + - name: {{ .Chart.Name }} + image: "{{ .Values.daemon.image.repository }}:{{ .Values.daemon.image.tag }}" + imagePullPolicy: {{ .Values.daemon.image.pullPolicy }} + {{- with .Values.daemon.args }} + args: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.daemon.env }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.daemon.resources }} + resources: + {{- toYaml .Values.daemon.resources | nindent 12 }} + {{- end }} + {{- with .Values.daemon.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + readinessProbe: + tcpSocket: + port: {{ .Values.drivers.webhook.service.port }} + initialDelaySeconds: 20 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: {{ .Values.drivers.webhook.service.port }} + initialDelaySeconds: 20 + periodSeconds: 20 + {{- with .Values.daemon.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.daemon.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.daemon.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.daemon.extraVolumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/incubator/honeydipper/templates/tests/test-webhook-service.yaml b/incubator/honeydipper/templates/tests/test-webhook-service.yaml new file mode 100644 index 0000000000..fb5504d8eb --- /dev/null +++ b/incubator/honeydipper/templates/tests/test-webhook-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ .Release.Name }}-webhook-test" + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: {{ .Release.Name }}-webhook-test + image: alpine:3.8 + command: + - "sh" + - "-c" + - | + wget -nv http://{{ include "honeydipper.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.drivers.webhook.service.port }}/hz/alive + restartPolicy: Never diff --git a/incubator/honeydipper/templates/webhook-ingress.yaml b/incubator/honeydipper/templates/webhook-ingress.yaml new file mode 100644 index 0000000000..7ab6025101 --- /dev/null +++ b/incubator/honeydipper/templates/webhook-ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.drivers.webhook.ingress.enabled -}} +{{- $fullName := include "honeydipper.fullname" . -}} +{{- $ingressPath := .Values.drivers.webhook.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "honeydipper.name" . }} + helm.sh/chart: {{ include "honeydipper.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- with .Values.drivers.webhook.ingress.annotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} +spec: +{{- if .Values.drivers.webhook.ingress.tls }} + tls: + {{- range .Values.drivers.webhook.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.drivers.webhook.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- end }} diff --git a/incubator/honeydipper/templates/webhook-service.yaml b/incubator/honeydipper/templates/webhook-service.yaml new file mode 100644 index 0000000000..c0857b7afa --- /dev/null +++ b/incubator/honeydipper/templates/webhook-service.yaml @@ -0,0 +1,24 @@ +{{- if or (has "receiver" .Values.daemon.args) (not .Values.daemon.args) -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "honeydipper.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "honeydipper.name" . }} + helm.sh/chart: {{ include "honeydipper.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.drivers.webhook.service.type }} + ports: + - port: {{ .Values.drivers.webhook.service.port }} + targetPort: {{ .Values.drivers.webhook.service.port }} + {{- if .Values.drivers.webhook.service.nodePort }} + nodePort: {{ .Values.drivers.webhook.service.nodePort }} + {{- end }} + protocol: TCP + name: webhook + selector: + app.kubernetes.io/name: {{ include "honeydipper.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/incubator/honeydipper/test-values.yaml b/incubator/honeydipper/test-values.yaml new file mode 100644 index 0000000000..3fb8c082f0 --- /dev/null +++ b/incubator/honeydipper/test-values.yaml @@ -0,0 +1,6 @@ +daemon: + env: + - name: REPO + value: https://github.com/honeydipper/honeydipper + - name: BOOTSTRAP_PATH + value: /deployments/helm/honeydipper/test_fixtures diff --git a/incubator/honeydipper/test_fixtures/init.yaml b/incubator/honeydipper/test_fixtures/init.yaml new file mode 100644 index 0000000000..5ec812ce85 --- /dev/null +++ b/incubator/honeydipper/test_fixtures/init.yaml @@ -0,0 +1,11 @@ +--- +repos: + - repo: https://github.com/honeydipper/honeydipper-config-essentials + +rules: + - when: + driver: webhook + conditions: + url: "/health" + do: + content: noop diff --git a/incubator/honeydipper/values.yaml b/incubator/honeydipper/values.yaml new file mode 100644 index 0000000000..831bcf3f57 --- /dev/null +++ b/incubator/honeydipper/values.yaml @@ -0,0 +1,103 @@ +# Default values for honeydipper. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# nameOverride is used to override the chart name part of the release name +nameOverride: "" +# fullnameOverride is used to override the release name +fullnameOverride: "" + +# daemon is used to specify the settings for the daemon +daemon: + # dnsConfig specifies the DNS parameters of the pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy. + dnsConfig: {} + + # serviceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ + serviceAccountName: "" + + # replicaCount specifies how many replica daemon should be running + replicaCount: 1 + + # image specifies what image to use to start the daemon + image: + # repository is the image repository for the daemon container + repository: honeydipper/honeydipper + # tag is the version of the docker image to use + tag: "0.1.10" + # pullPolicy specify when to refresh the image + pullPolicy: IfNotPresent + + # args are the arguments passed to the daemon, a list of services to run in the daemon + args: [] + + # resources specifies the resource limitation for the daemon container + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. 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 is used for specifying what nodes to place the daemon containers on + nodeSelector: {} + + # tolerations is used in the daemon pod speicification + tolerations: [] + + # tolerations is used in the daemon pod speicification + affinity: {} + + # env is a list of environment variables for the daemon container + env: + - name: REPO + value: https://github.com/honeydipper/honeydipper-config-essentials + + # extraVolumeMounts is a list of volumes to be mounted on the daemon container + extraVolumeMounts: [] + + # extraVolumes is a list of volumes to be mounted on the daemon container + extraVolumes: [] + +# drivers containers the settings for the drivers +drivers: + # redis settings for the redis related drivers + redis: + # local means run a local redis side car container, only useful for testing + local: true + image: + # when using local redis sidecar container specify the name of the image repository + repository: redis + # when using local redis sidecar container specify the tag of the image + tag: 5 + # webhook settings for the webhook driver + webhook: + # service specifies how the webhook driver service is exposed + service: + # type is the type of kubernetes service for the webhook + type: LoadBalancer + port: 8080 + nodePort: 0 + + # ingress controller settings + ingress: + # enabled is used for creating an ingress kubernetes resouce + enabled: false + # annotations are the annotations for the ingress resource + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # path specify the path of the ingress + path: / + # hosts specify the hosts of the ingress + hosts: + - chart-example.local + # tls is used for specifying the ssl cert using secret + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local