Skip to content

Commit

Permalink
Merge pull request #9 from MqllR/fix_ingress_api
Browse files Browse the repository at this point in the history
fix: Ingress apiVersion for k8s >= 1.19
  • Loading branch information
MqllR authored Apr 26, 2022
2 parents c33af9f + e69841f commit bc39704
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Parameter | Description | Default | Required
`metrics.image.pullPolicy` | Container pull policy | `IfNotPresent` | no
`metrics.securtyContext` | Custom security context for container | `{}` | no
`metrics.resources` | Resources request and limit YAML | `{}` | no
`ingress.enabled` | If true, an ingress object will be created | `false` | no
`ingress.enabled` | If true, an ingress object will be created to expose the __stat dashboard only__ | `false` | no
`ingress.annotations` | Annotations for the ingress | `{}` | no
`ingress.hosts` | Ingress hostname | `[]` | no
`ingress.tls` | Ingress TLS | `[]` | no
Expand All @@ -107,7 +107,7 @@ helm repo add storj-storagenode-chart https://mqllr.github.io/storj-storagenode-

2. Create your identity

Create a secret with your identity in kubernetes
Create a secret in kubernetes with your node identity

```
curl -L https://github.com/MqllR/storj-storagenode-chart/releases/download/identity/identity-to-kube-secret-amd64 -o identity-to-kube-secret
Expand Down
18 changes: 1 addition & 17 deletions charts/storj-storagenode/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
apiVersion: v2
name: storj-storagenode
description: A Helm chart for the storagenode STORJ

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.
version: 0.3.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.
version: 0.3.1
appVersion: 1.14.7

maintainers:
- name: MqllR
email: [email protected]
52 changes: 37 additions & 15 deletions charts/storj-storagenode/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "storj-storagenode.fullname" . -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- if and .Values.ingress.enabled .Values.service.stats.enabled -}}
{{- $prefix := include "storj-storagenode.fullname" . -}}
{{- $fullName := printf "%s-%s" $prefix "stats" -}}
{{- $svcPort := .Values.service.stats.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
Expand All @@ -15,26 +24,39 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
serviceName: {{ $fullName }}-stats
servicePort: stats
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/storj-storagenode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ ingress:
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: ["/"]
paths:
- path: "/"
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down

0 comments on commit bc39704

Please sign in to comment.