[ser2sock] migrate to common library (#719)

* migrate ser2sock to common
This commit is contained in:
ᗪєνιη ᗷυнʟ 2021-03-26 03:12:08 -04:00 committed by GitHub
parent 01983ee081
commit 91aef6139f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 154 additions and 290 deletions

View File

@ -167,7 +167,12 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Check lint matrix status - name: Check lint matrix status
if: ${{ needs.lint.result != 'success' }} if: |
!contains(github.event.head_commit.message, '[ci-skip]')
&&
needs.changes-lint.outputs.detected == 'true'
&&
needs.lint.result != 'success'
run: exit 1 run: exit 1
unittest: unittest:
@ -255,5 +260,10 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Check install matrix status - name: Check install matrix status
if: ${{ needs.install.result != 'success' }} if: |
!contains(github.event.head_commit.message, '[ci-skip]')
&&
needs.changes-install.outputs.detected == 'true'
&&
needs.install.result != 'success'
run: exit 1 run: exit 1

View File

@ -22,3 +22,5 @@
.vscode/ .vscode/
# OWNERS file for Kubernetes # OWNERS file for Kubernetes
OWNERS OWNERS
# helm-docs templates
*.gotmpl

View File

@ -2,14 +2,19 @@ apiVersion: v2
appVersion: 1.0.0 appVersion: 1.0.0
description: Serial to Socket Redirector description: Serial to Socket Redirector
name: ser2sock name: ser2sock
version: 2.0.3 version: 3.0.0
kubeVersion: ">=1.16.0-0"
keywords: keywords:
- ser2sock - ser2sock
home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/ser2sock home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/ser2sock
icon: https://i.imgur.com/GfZ7McO.png icon: https://i.imgur.com/GfZ7McO.png
sources: sources:
- https://github.com/nutechsoftware/ser2sock - https://github.com/nutechsoftware/ser2sock
- https://github.com/tenstartups/ser2sock - https://github.com/tenstartups/ser2sock
maintainers: maintainers:
- name: billimek - name: billimek
email: jeff@billimek.com email: jeff@billimek.com
dependencies:
- name: common
repository: https://library-charts.k8s-at-home.com
version: 2.0.1

View File

@ -1,6 +1,6 @@
# ser2sock # ser2sock
![Version: 2.0.3](https://img.shields.io/badge/Version-2.0.3-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) ![Version: 3.0.0](https://img.shields.io/badge/Version-3.0.0-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square)
Serial to Socket Redirector Serial to Socket Redirector
@ -13,10 +13,13 @@ Serial to Socket Redirector
## Requirements ## Requirements
Kubernetes: `>=1.16.0-0`
## Dependencies ## Dependencies
| Repository | Name | Version | | Repository | Name | Version |
|------------|------|---------| |------------|------|---------|
| https://library-charts.k8s-at-home.com | common | 2.0.1 |
## TL;DR ## TL;DR
@ -65,9 +68,22 @@ helm install ser2sock k8s-at-home/ser2sock -f values.yaml
## Custom configuration ## Custom configuration
**IMPORTANT NOTE:** the USB device must be accessible on the node where this pod runs, in order for this chart to function properly. **IMPORTANT NOTE:** a ser2sock controller device must be accessible on the node where this pod runs, in order for this chart to function properly.
A way to achieve this can be with nodeAffinity rules, for example: First, you will need to mount your ser2sock device into the pod, you can do so by adding the following to your values:
```yaml
additionalVolumeMounts:
- name: usb
mountPath: /path/to/device
additionalVolumes:
- name: usb
hostPath:
path: /path/to/device
```
Second you will need to set a nodeAffinity rule, for example:
```yaml ```yaml
affinity: affinity:
@ -75,13 +91,13 @@ affinity:
requiredDuringSchedulingIgnoredDuringExecution: requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms: nodeSelectorTerms:
- matchExpressions: - matchExpressions:
- key: usb - key: app
operator: In operator: In
values: values:
- alarmdecoder - ser2sock-controller
``` ```
... where a node with an attached Coral USB device is labeled with `usb: alarmdecoder` ... where a node with an attached ser2sock controller USB device is labeled with `app: ser2sock-controller`
## Values ## Values
@ -89,31 +105,17 @@ affinity:
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| affinity | object | `{}` | Affinity settings for pod assignment of the GUI | | additionalVolumeMounts | list | `[]` | |
| baudRate | int | `115200` | Baudrate | | additionalVolumes | list | `[]` | |
| device | string | `"/dev/ttyUSB0"` | USB Device to use | | env.BAUD_RATE | int | `115200` | |
| fullnameOverride | string | `""` | | | env.LISTENER_PORT | int | `10000` | |
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy | | env.SERIAL_DEVICE | string | `"/dev/ttyUSB0"` | |
| image.repository | string | `"tenstartups/ser2sock"` | Image repository | | image.pullPolicy | string | `"IfNotPresent"` | |
| image.tag | string | `"latest"` | Image tag. Possible values listed [here](https://hub.docker.com/r/tenstartups/ser2sock/tags). | | image.repository | string | `"tenstartups/ser2sock"` | |
| nameOverride | string | `""` | | | image.tag | string | `"latest"` | |
| nodeSelector | object | `{}` | Node labels for pod assignment of the GUI | | ingress.enabled | bool | `false` | |
| pgid | string | `"1001"` | GID to run as | | service.port.port | int | `10000` | |
| podAnnotations | object | `{}` | Pod annotations | | strategy.type | string | `"Recreate"` | |
| puid | string | `"1001"` | UID to run as |
| resources | object | `{}` | CPU/Memory resource requests/limits or the GUI |
| service.annotations | object | `{}` | Service annotations for the GUI |
| service.clusterIP | string | `nil` | Cluster IP for the GUI |
| service.externalIPs | string | `nil` | External IPs for the GUI |
| service.externalTrafficPolicy | string | `nil` | Loadbalancer externalTrafficPolicy |
| service.loadBalancerIP | string | `nil` | Loadbalancer IP for the GUI |
| service.loadBalancerSourceRanges | string | `nil` | Loadbalancer client IP restriction range for the GUI |
| service.nodePort | string | `nil` | nodePort to listen on for the GUI |
| service.port | int | `10000` | Kubernetes port where the GUI is exposed |
| service.type | string | `"ClusterIP"` | Kubernetes service type for the GUI |
| strategyType | string | `"Recreate"` | Specifies the strategy used to replace old Pods by new ones |
| timezone | string | `nil` | Timezone the ser2sock instance should run as, e.g. 'America/New_York' |
| tolerations | list | `[]` | Toleration labels for pod assignment of the GUI |
## Changelog ## Changelog
@ -121,7 +123,21 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [2.0.2] ### [3.0.0]
#### Added
- N/A
#### Changed
- **BREAKING** Migrate ser2sock to the common library, Helm configuration values have changed.
#### Removed
- N/A
### [1.0.0]
#### Added #### Added
@ -135,7 +151,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- N/A - N/A
[2.0.2]: #2.0.2 [3.0.0]: #3.0.0
[1.0.0]: #1.0.0
## Support ## Support

View File

@ -9,7 +9,21 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [2.0.2] ### [3.0.0]
#### Added
- N/A
#### Changed
- **BREAKING** Migrate ser2sock to the common library, Helm configuration values have changed.
#### Removed
- N/A
### [1.0.0]
#### Added #### Added
@ -23,5 +37,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- N/A - N/A
[2.0.2]: #2.0.2 [3.0.0]: #3.0.0
[1.0.0]: #1.0.0
{{- end -}} {{- end -}}

View File

@ -5,9 +5,22 @@
{{- define "custom.custom.configuration" -}} {{- define "custom.custom.configuration" -}}
{{ template "custom.custom.configuration.header" . }} {{ template "custom.custom.configuration.header" . }}
**IMPORTANT NOTE:** the USB device must be accessible on the node where this pod runs, in order for this chart to function properly. **IMPORTANT NOTE:** a ser2sock controller device must be accessible on the node where this pod runs, in order for this chart to function properly.
A way to achieve this can be with nodeAffinity rules, for example: First, you will need to mount your ser2sock device into the pod, you can do so by adding the following to your values:
```yaml
additionalVolumeMounts:
- name: usb
mountPath: /path/to/device
additionalVolumes:
- name: usb
hostPath:
path: /path/to/device
```
Second you will need to set a nodeAffinity rule, for example:
```yaml ```yaml
affinity: affinity:
@ -15,11 +28,11 @@ affinity:
requiredDuringSchedulingIgnoredDuringExecution: requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms: nodeSelectorTerms:
- matchExpressions: - matchExpressions:
- key: usb - key: app
operator: In operator: In
values: values:
- alarmdecoder - ser2sock-controller
``` ```
... where a node with an attached Coral USB device is labeled with `usb: alarmdecoder` ... where a node with an attached ser2sock controller USB device is labeled with `app: ser2sock-controller`
{{- end -}} {{- end -}}

View File

@ -1,15 +1 @@
1. Get the application URL by running these commands: {{- include "common.notes.defaultNotes" . -}}
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ser2sock.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 {{ include "ser2sock.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ser2sock.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.kubernetes.io/name={{ include "ser2sock.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:5000 to use your application"
kubectl port-forward $POD_NAME 5000:5000
{{- end }}

View File

@ -1,45 +0,0 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "ser2sock.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 "ser2sock.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 "ser2sock.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "ser2sock.labels" -}}
app.kubernetes.io/name: {{ include "ser2sock.name" . }}
helm.sh/chart: {{ include "ser2sock.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

View File

@ -0,0 +1 @@
{{ include "common.all" . }}

View File

@ -1,73 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ser2sock.fullname" . }}
labels:
{{ include "ser2sock.labels" . | indent 4 }}
spec:
replicas: 1
revisionHistoryLimit: 3
strategy:
type: {{ .Values.strategyType }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "ser2sock.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "ser2sock.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podAnnotations }}
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
privileged: true
ports:
- name: http
containerPort: 10000
protocol: TCP
env:
{{- if .Values.timezone }}
- name: TZ
value: "{{ .Values.timezone }}"
{{- end }}
- name: LISTENER_PORT
value: "10000"
- name: BAUD_RATE
value: "{{ .Values.baudRate }}"
- name: SERIAL_DEVICE
value: "/dev/ttyUSB0"
- name: PUID
value: "{{ .Values.puid }}"
- name: PGID
value: "{{ .Values.pgid }}"
volumeMounts:
- mountPath: /dev/ttyUSB0
name: usb
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: usb
hostPath:
path: {{ .Values.device }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -1,49 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "ser2sock.fullname" . }}
labels:
{{ include "ser2sock.labels" . | indent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{end}}
{{- else if eq .Values.service.type "LoadBalancer" }}
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
ports:
- name: http
port: {{ .Values.service.port }}
protocol: TCP
targetPort: http
{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{.Values.service.nodePort}}
{{ end }}
selector:
app.kubernetes.io/name: {{ include "ser2sock.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -1,73 +1,55 @@
# Default values for ser2sock. #
# This is a YAML-formatted file. # IMPORTANT NOTE
# Declare variables to be passed into your templates. #
# This chart inherits from our common library chart. You can check the default values/options here:
# -- Specifies the strategy used to replace old Pods by new ones # https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml
strategyType: Recreate #
image: image:
# -- Image repository
repository: tenstartups/ser2sock repository: tenstartups/ser2sock
# -- Image tag. Possible values listed [here](https://hub.docker.com/r/tenstartups/ser2sock/tags).
tag: latest
# -- Image pull policy
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
tag: latest
nameOverride: "" strategy:
fullnameOverride: "" type: Recreate
env:
# TZ:
# PUID:
# PGID:
LISTENER_PORT: 10000
BAUD_RATE: 115200
SERIAL_DEVICE: "/dev/ttyUSB0"
# -- (string) Timezone the ser2sock instance should run as, e.g. 'America/New_York'
timezone:
# -- USB Device to use
device: "/dev/ttyUSB0"
# -- UID to run as
puid: "1001"
# -- GID to run as
pgid: "1001"
# -- Baudrate
baudRate: 115200
service: service:
# -- Kubernetes service type for the GUI port:
type: ClusterIP port: 10000
# -- Kubernetes port where the GUI is exposed
port: 10000
# -- Service annotations for the GUI
annotations: {}
# -- (string) Cluster IP for the GUI
clusterIP:
# -- (string) External IPs for the GUI
externalIPs:
# -- (string) Loadbalancer IP for the GUI
loadBalancerIP:
# -- (string) Loadbalancer client IP restriction range for the GUI
loadBalancerSourceRanges:
# -- (string) Loadbalancer externalTrafficPolicy
externalTrafficPolicy:
# -- (string) nodePort to listen on for the GUI
nodePort:
# -- CPU/Memory resource requests/limits or the GUI ingress:
resources: {} enabled: false
# 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
# -- Node labels for pod assignment of the GUI # Privileged may be required if USB controller is accessed directly through the host machine
nodeSelector: {} # securityContext:
# privileged: true
# -- Toleration labels for pod assignment of the GUI # Path to your ser2sock device in the container
tolerations: [] additionalVolumeMounts: []
# - name: usb
# mountPath: /dev/ttyUSB0
# -- Affinity settings for pod assignment of the GUI # Path to your ser2sock device on the host
affinity: {} additionalVolumes: []
# - name: usb
# hostPath:
# path: /dev/ttyUSB0
# -- Pod annotations # affinity:
podAnnotations: {} # nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: app
# operator: In
# values:
# - ser2sock-controller