Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helm chart for vcenter-connector #569

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install-armhf: namespaces
kubectl apply -f yaml_armhf/

charts:
cd chart && helm package openfaas/ && helm package kafka-connector/ && helm package cron-connector/
cd chart && helm package openfaas/ && helm package kafka-connector/ && helm package cron-connector/ && helm package vcenter-connector/
mv chart/*.tgz docs/
helm repo index docs --url https://openfaas.github.io/faas-netes/ --merge ./docs/index.yaml
./contrib/create-static-manifest.sh
Expand Down
22 changes: 22 additions & 0 deletions chart/vcenter-connector/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
.vscode/
18 changes: 18 additions & 0 deletions chart/vcenter-connector/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
description: Connect OpenFaaS functions to vCenter events
name: vcenter-connector
version: 0.4.0
sources:
- https://github.com/openfaas-incubator/openfaas-vcenter-connector
home: https://www.openfaas.com
icon: https://raw.githubusercontent.com/openfaas/media/master/OpenFaaS_logo_stacked_opaque.png
keywords:
- functions
- service
- vCenter
- vmware
maintainers:
- name: alexellis
email: [email protected]
- name: embano1
email: [email protected]
74 changes: 74 additions & 0 deletions chart/vcenter-connector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# OpenFaaS vCenter Connector

The [OpenFaaS vCenter connector](https://github.com/openfaas-incubator/openfaas-vcenter-connector) brings vCenter events to OpenFaaS by invoking functions based on vCenter event(s) topic annotations.

## Prerequisites

- Install OpenFaaS

You must have a working OpenFaaS installation. You can find [instructions in the docs](https://docs.openfaas.com/deployment/kubernetes/#pick-helm-or-yaml-files-for-deployment-a-or-b), including instructions to also install OpenFaaS via Helm.

- Have a working VMware vCenter environment (dev/testing) that you can connect to

## Install the Chart

- Create a Kubernetes secret holding the vCenter credentials to be used by the vcenter-connector

```
kubectl create secret generic vcenter-secrets \
-n openfaas \
--from-literal vcenter-username=user \
--from-literal vcenter-password=pass
```

> **Note:** Replace "user" and "pass" with the actual values. It is a good practice to use a dedicated vCenter service account instead of an administrator role for the vcenter-connector.

- Add the OpenFaaS chart repo and deploy the `vcenter-connector` chart. We recommend installing it in the same namespace as the rest of OpenFaaS

```sh
$ helm repo add openfaas https://openfaas.github.io/faas-netes/
$ helm upgrade vcenter-connector openfaas/vcenter-connector \
--install \
--namespace openfaas
```

> **Note:** The above command will also update your helm repo to pull in any new releases.

After you have [verified](#verify-the-installationtroubleshooting) that the installation succeeded you might want to run through an actual [function example](https://github.com/openfaas-incubator/openfaas-vcenter-connector#examples--community).

### Verify the installation/Troubleshooting

1) Check that the `vcenter-connector` deployment in the given Kubernetes namespace (default: "openfaas") is ready, i.e. shows `1/1` pods in running state
2) If you see error messages or `0/1` (note: it might take some time to pull the container image) verify that
1) you have followed the [installation](#install-the-chart) steps as outlined above (vCenter secret deployed?)
2) the status of the corresponding `ReplicaSet` with `kubectl -n openfaas get rs`
3) the logs of the container don't show any errors with `kubectl -n openfaas logs deploy/vcenter-connector`

## Customizing the Helm Chart

Additional vcenter-connector options in `values.yaml`:

| Parameter | Description | Default |
|----------------------|-----------------------------------------------------------------------------------|--------------------------------|
| `resources.requests` | Compute resources Kubernetes will guarantee to this pod | `100m (CPU), 120Mi (Memory)` |
| `vc_k8s_secret` | vCenter secrets name as stored in Kubernetes | `vcenter-secrets` |
| `basic_auth` | Use basic authentication against OpenFaaS gateway | `true` |
| `extraArgs.gateway` | The URL of the OpenFaaS API gateway | `http://gateway.openfaas:8080` |
| `extraArgs.vcenter` | The URL of the vCenter server | `http://vcsim.openfaas:8989` |
| `extraArgs.insecure` | Don't verify vCenter server certificate (remove this parameter to force checking) | `insecure` |

Specify each parameter you want to change using the `--set key=value[,key=value]` argument to `helm install`, e.g.:

```
helm install vcenter-connector ./vcenter-connector --namespace openfaas --set extraArgs.vcenter=https://10.160.94.63/sdk
```

See `values.yaml` for detailed configuration.

## Removing the vCenter Connector

The vCenter connector can be cleaned up with the following helm command:

```sh
helm uninstall vcenter-connector --namespace openfaas
```
7 changes: 7 additions & 0 deletions chart/vcenter-connector/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Thank you for installing vcenter-connector. Please follow the instructions below to retrieve the status of the connector.
If you experience problems please also refer to the troubleshooting instructions in the README provided with this chart.

You can watch the Connector logs to see incoming vCenter events and invoked functions based on topic annotations (if any):

$ kubectl logs -n {{ .Release.Namespace }} deploy/{{ template "connector.fullname" . }} -f

33 changes: 33 additions & 0 deletions chart/vcenter-connector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "connector.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 "connector.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 "connector.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

106 changes: 106 additions & 0 deletions chart/vcenter-connector/templates/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
# Original Helm labels v
app: {{ template "connector.name" . }}
component: vcenter-connector
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
# Helm/k8s recommended label names v
app.kubernetes.io/name: {{ template "connector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/component: vcenter-connector
app.kubernetes.io/part-of: openfaas
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
name: {{ template "connector.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: {{ template "connector.name" . }}
component: vcenter-connector
template:
metadata:
annotations:
prometheus.io.scrape: "false"
labels:
app: {{ template "connector.name" . }}
component: vcenter-connector
spec:
volumes:
- name: auth-secrets-projected
projected:
defaultMode: 420
sources:
{{- if .Values.basic_auth }}
- secret:
items:
- key: basic-auth-user
path: basic-auth-user
- key: basic-auth-password
path: basic-auth-password
name: basic-auth
{{- end }}
- secret:
items:
- key: vcenter-username
path: vcenter-username
- key: vcenter-password
path: vcenter-password
name: {{ .Values.vc_k8s_secret | quote }}
containers:
- name: vcenter
image: {{ .Values.image }}
resources:
{{- .Values.resources | toYaml | nindent 12 }}
command: ["./connector"]
args:
{{- range $key, $value := .Values.extraArgs }}
{{- if $value }}
- --{{ $key }}={{ $value }}
{{- else }}
- --{{ $key }}
{{- end }}
{{- end }}
env:
- name: gateway_url
value: {{ .Values.extraArgs.gateway | quote }}
- name: print_response
value: {{ .Values.print_response | quote }}
- name: print_response_body
value: {{ .Values.print_response_body | quote }}
- name: secret_mount_path
value: {{ .Values.secret_mount | quote }}
{{- if .Values.basic_auth }}
- name: basic_auth
value: "true"
{{- end }}
{{- if .Values.upstream_timeout }}
- name: upstream_timeout
value: {{ .Values.upstream_timeout | quote }}
{{- end }}
{{- if .Values.rebuild_interval }}
- name: rebuild_interval
value: {{ .Values.rebuild_interval | quote }}
{{- end }}
volumeMounts:
- name: auth-secrets-projected
readOnly: true
mountPath: "/var/openfaas/secrets/"
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
21 changes: 21 additions & 0 deletions chart/vcenter-connector/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
image: openfaas/vcenter-connector:0.4.0
replicas: 1
resources:
requests:
memory: "120Mi"
cpu: "100m"
vc_k8s_secret: vcenter-secrets
secret_mount: /var/openfaas/secrets/
basic_auth: true
extraArgs:
gateway: http://gateway.openfaas:8080
vcenter: http://vcsim.openfaas:8989
vc-user-secret-name: vcenter-username
vc-pass-secret-name: vcenter-password
insecure:

nodeSelector: {}

tolerations: []

affinity: {}