Skip to content

Commit

Permalink
Merge pull request #12 from epoch8/simple_app_services
Browse files Browse the repository at this point in the history
simple_app 0.10.0
  • Loading branch information
elephantum authored Jul 21, 2023
2 parents 827ab02 + ec824ae commit 1285de2
Show file tree
Hide file tree
Showing 17 changed files with 764 additions and 70 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v1
uses: azure/setup-helm@v3
with:
version: v3.4.0
version: v3.11.0

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.1.0
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run tests

on:
push:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.11.0

- name: Install helm-unittest
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
- name: Run tests
run: |
helm unittest charts/* -o test-report.xml -t junit
- name: Test report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: test report
path: test-report.xml
reporter: java-junit
11 changes: 11 additions & 0 deletions charts/simple-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 0.10.0

## Backwards incompatibility

* Default names for all resources equal to release name
* Delete `Values.probe`. `livenessProbe` and `readinessProbe` import from values file
* Rename `.service.port` -> `.servicePort`, `.service.type` -> `.serviceType`
* Rename `.servicePorts` -> `.extraPorts`
* Add `.extraPorts[*].servicePort` config


# 0.9.1

* Add support for `.initialDelaySeconds` in `livenessProbe` and `readinessProbe`
Expand Down
2 changes: 1 addition & 1 deletion charts/simple-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "0.9.1"
version: "0.10.0"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 4 additions & 0 deletions charts/simple-app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# helm plugin install https://github.com/helm-unittest/helm-unittest.git

test:
helm unittest .
5 changes: 0 additions & 5 deletions charts/simple-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ If release name contains chart name it will be used as a full name.
{{- 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 }}

Expand Down
48 changes: 13 additions & 35 deletions charts/simple-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,52 +68,30 @@ spec:
- name: http
containerPort: {{ .Values.port }}
protocol: TCP
{{- range .Values.servicePorts }}
{{- range .Values.extraPorts }}
- name: {{ .name }}
containerPort: {{ .port }}
protocol: {{ .protocol | default "TCP" }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
{{- if .Values.livenessProbe }}
{{- with .Values.livenessProbe }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- else }}
httpGet:
path: {{ .Values.probe.httpGet.path }}
path: /
port: http
{{- if .Values.livenessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.livenessProbe.timeoutSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.livenessProbe.periodSeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
{{- end }}
{{- if .Values.livenessProbe.successThreshold }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
{{- end }}
{{- if .Values.livenessProbe.failureThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
{{- if .Values.readinessProbe }}
{{- with .Values.readinessProbe }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- else }}
httpGet:
path: {{ .Values.probe.httpGet.path }}
path: /
port: http
{{- if .Values.livenessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.readinessProbe.timeoutSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.readinessProbe.periodSeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
{{- end }}
{{- if .Values.readinessProbe.successThreshold }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
{{- end }}
{{- if .Values.readinessProbe.failureThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/simple-app/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "simple-app.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- $svcPort := .Values.servicePort -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
Expand Down
8 changes: 4 additions & 4 deletions charts/simple-app/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ metadata:
labels:
{{- include "simple-app.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
type: {{ .Values.serviceType }}
ports:
- port: {{ .Values.service.port }}
- port: {{ .Values.servicePort }}
targetPort: http
protocol: TCP
name: http
{{- range .Values.servicePorts}}
- port: {{ .port }}
{{- range .Values.extraPorts}}
- port: {{ .servicePort | default .port }}
targetPort: {{ .name }}
protocol: {{ .protocol | default "TCP" }}
name: {{ .name }}
Expand Down
116 changes: 116 additions & 0 deletions charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
All manifests should match snapshot:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-app
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-app-0.10.0
name: simple
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: simple
app.kubernetes.io/name: simple-app
template:
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/name: simple-app
spec:
containers:
- image: test:1.1.1
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: simple-app
ports:
- containerPort: 9000
name: http
protocol: TCP
- containerPort: 1
name: port1
protocol: TCP
- containerPort: 2
name: port2
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
volumeMounts: null
securityContext: {}
serviceAccountName: simple
volumes: null
2: |
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations: null
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-app
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-app-0.10.0
name: simple
spec:
rules:
- host: test.epoch8.co
http:
paths:
- backend:
service:
name: simple
port:
number: 9000
path: /*
pathType: ImplementationSpecific
3: |
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-app
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-app-0.10.0
name: simple
spec:
ports:
- name: http
port: 9000
protocol: TCP
targetPort: http
- name: port1
port: 1
protocol: TCP
targetPort: port1
- name: port2
port: 22022
protocol: TCP
targetPort: port2
selector:
app.kubernetes.io/instance: simple
app.kubernetes.io/name: simple-app
type: ClusterIP
4: |
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-app
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-app-0.10.0
name: simple
Loading

0 comments on commit 1285de2

Please sign in to comment.