Skip to content

More features for 0.4.0 #21

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

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## pre 1.0

### 0.4.0
* Add initScript container capability
* Bump nettools container image v1.10.0 -> v1.12.0
* Add additionalAnnotations
* Add additionalLabels
* Add imagePullSecrets

### 0.3.2

* add .helmignore for a clean chart
Expand Down
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "1.0"
description: A helm chart for a SFTP server
name: sftp-server
version: 0.3.2
version: 0.4.0
74 changes: 42 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,45 @@ The command removes all the Kubernetes components associated with the chart and

The following table lists the configurable parameters of the SFTP server chart and their default values.

| Parameter | Description | Default |
| -----------------------------------| ------------------------------------------ | ------------------------------------------- |
| `image.repository` | Docker repo to use | `atmoz/sftp` |
| `image.tag` | Docker tag to be used | `alpine-3.7` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `service.enabled` | If true, expose as Service | `true` |
| `service.type` | Type of exposed Service | `ClusterIP` |
| `service.port` | Port to expose Service | `22` |
| `sftpConfig.username` | SFTP username | `sftp` |
| `sftpConfig.password` | SFTP password for user | `""` |
| `sftpConfig.encrypted` | If true, password is given as hash | `false` |
| `sftpConfig.uid` | UID of SFTP user | `1000` |
| `sftpConfig.gid` | GID of SFTP user | `100` |
| `sftpConfig.hostKeys.secret` | name of secret for SSH host keys | `""` |
| `sftpConfig.hostKeys.keys` | list of items to be used from secret | `{}` |
| `sftpConfig.authorizedKeys` | list of authorized SSH keys | `{}` |
| `persistentVolume.enabled` | If true, use persistent volume | `true` |
| `persistentVolume.annotations` | annotations put on the volume | `{}` |
| `persistentVolume.accessModes` | access modes for volume | `[ReadWriteOnce]` |
| `persistentVolume.existingClaim` | If set, use existing PVC | `""` |
| `persistentVolume.size` | Size of volume | `20Gi` |
| `persistentVolume.storageClass` | StorageClass to be used in PVC | not set |
| `persistentVolume.subPath` | Use subPath of existing volume | `""` |
| `vxlanController.enabled` | If enabled, start kube-vxlan-controller | `false` |
| `vxlanController.annotationKey` | Annotation name to set for vxlan | `vxlan.openvnf.org/networks` |
| `vxlanController.metadataKey` | Metadata key to set for vxlan | `vxlan.openvnf.org` |
| `vxlanController.image.repository` | Docker repo to use | `openvnf/kube-vxlan-controller-agent` |
| `vxlanController.image.tag` | Docker tag to be used | `2.1.0` |
| `vxlanController.image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `vxlanController.network` | VXLAN network to attach to | `vxeth0` |
| `vxlanController.ip` | IP address to assign to vxlan interface | `{}` |
| `vxlanController.route` | additional route to configure | `{}` |
| Parameter | Description | Default |
| -------------------------------------- | ------------------------------------------ | ------------------------------------------- |
| `additionalAnnotations` | Annotations to add to the manifests | null |
| `additionalLabels` | Labels to add to the manifests | null |
| `image.repository` | Docker repo to use | `quay.io/openvnf/sftp` |
| `image.tag` | Docker tag to be used | `alpine-3.7` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `initScript.enabled` | If true, add initScript container | `false` |
| `initScript.additionalSecurityContext` | Additional security context for container | `{}` |
| `initScript.env` | Environment variables for the script | `{}` |
| `initScript.image.repository` | Docker repo to use | `quay.io/travelping/nettools` |
| `initScript.image.tag` | Docker tag to be used | `v1.12.0` |
| `initScript.image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `initScript.script` | The script to run | `echo "script configuration is missing"` |
| `service.enabled` | If true, expose as Service | `true` |
| `service.type` | Type of exposed Service | `ClusterIP` |
| `service.port` | Port to expose Service | `22` |
| `sftpConfig.username` | SFTP username | `sftp` |
| `sftpConfig.password` | SFTP password for user | `""` |
| `sftpConfig.encrypted` | If true, password is given as hash | `false` |
| `sftpConfig.uid` | UID of SFTP user | `1000` |
| `sftpConfig.gid` | GID of SFTP user | `100` |
| `sftpConfig.hostKeys.secret` | name of secret for SSH host keys | `""` |
| `sftpConfig.hostKeys.keys` | list of items to be used from secret | `{}` |
| `sftpConfig.authorizedKeys` | list of authorized SSH keys | `{}` |
| `persistentVolume.enabled` | If true, use persistent volume | `true` |
| `persistentVolume.annotations` | annotations put on the volume | `{}` |
| `persistentVolume.accessModes` | access modes for volume | `[ReadWriteOnce]` |
| `persistentVolume.existingClaim` | If set, use existing PVC | `""` |
| `persistentVolume.size` | Size of volume | `20Gi` |
| `persistentVolume.storageClass` | StorageClass to be used in PVC | not set |
| `persistentVolume.subPath` | Use subPath of existing volume | `""` |
| `pullSecrets` | imagePullSecretst to use for the deployment| null |
| `vxlanController.enabled` | If enabled, start kube-vxlan-controller | `false` |
| `vxlanController.annotationKey` | Annotation name to set for vxlan | `vxlan.openvnf.org/networks` |
| `vxlanController.metadataKey` | Metadata key to set for vxlan | `vxlan.openvnf.org` |
| `vxlanController.image.repository` | Docker repo to use | `openvnf/kube-vxlan-controller-agent` |
| `vxlanController.image.tag` | Docker tag to be used | `2.1.0` |
| `vxlanController.image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `vxlanController.network` | VXLAN network to attach to | `vxeth0` |
| `vxlanController.ip` | IP address to assign to vxlan interface | null |
| `vxlanController.route` | additional route to configure | null |
14 changes: 14 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o errtrace

HELM="${HELM:-helm}"

cd "tests/values"

for file in *yaml; do
echo "helm $file"
${HELM} template ../../ -f "${file}" --include-crds --namespace test-namespace > "../outputs/${file}"
done
35 changes: 28 additions & 7 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{/* Expand the name of the chart. */}}
{{- define "sftp-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/* Create chart name and version as used by the chart label. */}}
{{- define "sftp-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | 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).
Expand All @@ -24,9 +28,26 @@ If release name contains chart name it will be used as a full name.
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "sftp-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- /*
sftp-server.labels prints the standard Helm labels.
The standard labels are frequently used in metadata.
*/ -}}
{{- define "sftp-server.labels" -}}
app: {{ template "sftp-server.name" . }}
run: {{ template "sftp-server.fullname" . }}
chart: {{ template "sftp-server.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{- define "sftp-server.selector.labels" -}}
app: {{ template "sftp-server.name" . }}
release: {{ .Release.Name }}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
6 changes: 6 additions & 0 deletions templates/authorized-keys-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{{- if .Values.sftpConfig.authorizedKeys }}
---
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
name: {{ template "sftp-server.fullname" . }}-authorized-keys
data:
id_rsa.pub: |
Expand Down
6 changes: 6 additions & 0 deletions templates/data-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{{- if .Values.persistentVolume.enabled -}}
{{- if not .Values.persistentVolume.existingClaim -}}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
{{- if .Values.persistentVolume.annotations }}
annotations:
{{ toYaml .Values.persistentVolume.annotations | indent 4 }}
{{- end }}
labels:
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
name: {{ template "sftp-server.fullname" . }}-data
spec:
accessModes:
Expand Down
62 changes: 53 additions & 9 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "sftp-server.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "sftp-server.name" . }}
helm.sh/chart: {{ include "sftp-server.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "sftp-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "sftp-server.selector.labels" . | nindent 6 }}
strategy:
type: Recreate
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "sftp-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "sftp-server.labels" . | nindent 8 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 8 }}
{{- end }}
{{- if .Values.vxlanController.enabled }}
{{ .Values.vxlanController.metadataKey }}: "true"
{{- end }}
annotations:
checksum/config: {{ include (print .Template.BasePath "/sftp-config.yaml") . | sha256sum }}
checksum/keys: {{ include (print .Template.BasePath "/authorized-keys-config.yaml") . | sha256sum }}
{{- if .Values.vxlanController.enabled }}
{{ .Values.vxlanController.annotationKey }}: |
{{ .Values.vxlanController.annotationKey }}: |
{{ .Values.vxlanController.network }}
{{ if .Values.vxlanController.ip -}} ip= {{- .Values.vxlanController.ip }} {{- end}}
{{ if .Values.vxlanController.route -}} route= {{- .Values.vxlanController.route }} {{- end}}
{{- end }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 8 }}
{{- end }}
spec:
initContainers:
{{- if .Values.vxlanController.enabled }}
Expand All @@ -42,6 +49,30 @@ spec:
capabilities:
add: ["NET_ADMIN"]
{{- end }}
{{- if .Values.initScript.enabled }}
- name: init-script
image: {{ .Values.initScript.image.repository }}:{{ .Values.initScript.image.tag }}
imagePullPolicy: {{ .Values.initScript.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.resources.initScript | indent 10 }}
securityContext:
capabilities:
add:
- "NET_ADMIN"
{{- if .Values.initScript.additionalSecurityContext }}
{{ toYaml .Values.initScript.additionalSecurityContext | indent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "sftp-server.fullname" . }}-init-script-env
command:
- sh
- /opt/initScript/initScript.sh
volumeMounts:
- name: init-script
mountPath: /opt/initScript/
readOnly: true
{{- end }}
containers:
{{- if .Values.debug.enabled }}
- name: debug
Expand Down Expand Up @@ -125,6 +156,19 @@ spec:
persistentVolumeClaim:
claimName: {{ if .Values.persistentVolume.existingClaim }}{{ .Values.persistentVolume.existingClaim }}{{- else }}{{ template "sftp-server.fullname" . }}-data{{- end }}
{{- end }}
{{- if .Values.initScript.enabled }}
- name: init-script
configMap:
name: {{ template "sftp-server.fullname" . }}-init-script
defaultMode: 0544
items:
- key: initScript.sh
path: initScript.sh
{{- end }}
{{- if .Values.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.pullSecrets | indent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
14 changes: 14 additions & 0 deletions templates/init-script-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.initScript.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "sftp-server.fullname" . }}-init-script
labels:
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
data:
initScript.sh: {{ .Values.initScript.script | quote}}
{{- end }}
14 changes: 14 additions & 0 deletions templates/init-script-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.initScript.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "sftp-server.fullname" . }}-init-script-env
labels:
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
data:
{{ toYaml .Values.initScript.env | indent 2 }}
{{- end }}
9 changes: 5 additions & 4 deletions templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{{- if .Values.service.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "sftp-server.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "sftp-server.name" . }}
helm.sh/chart: {{ include "sftp-server.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
Expand Down
6 changes: 6 additions & 0 deletions templates/sftp-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "sftp-server.labels" . | nindent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
name: {{ template "sftp-server.fullname" . }}-users
data:
users.conf: |
Expand Down
Loading