Skip to content

Commit

Permalink
Update-2023-08-17_17:48:21
Browse files Browse the repository at this point in the history
  • Loading branch information
pogossian committed Aug 17, 2023
1 parent c0b7dcd commit 1a2592b
Show file tree
Hide file tree
Showing 19 changed files with 1,065 additions and 504 deletions.
4 changes: 2 additions & 2 deletions charts/netris-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ 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: 1.0.20
version: 1.4.2

# 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
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 3.0.10.3
appVersion: 3.4.2
home: https://netris.ai
icon: https://www.netris.ai/wp-content/uploads/2021/01/logo-300.png # [todo] Change url to permalink
keywords:
Expand Down
95 changes: 67 additions & 28 deletions charts/netris-controller/README.md

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions charts/netris-controller/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
1. Get the application URL by running these commands:
{{- if .Values.app.ingress.enabled }}
{{- $path := .Values.app.ingress.path }}
{{- range $host := .Values.app.ingress.hosts }}
http{{ if $.Values.app.ingress.tls }}s{{ end }}://{{ $host }}{{ $path }}
{{- if .Values.ingress.enabled }}
{{- $path := .Values.ingress.path }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ $path }}
{{- end }}
{{- else if contains "NodePort" .Values.app.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ printf "%s-%s" (include "netris-controller.fullname" .) "app" }})
{{- else if contains "NodePort" (index .Values "web-service-frontend").service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ printf "%s-%s" (include "netris-controller.fullname" .) "web-service-frontend" }})
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.app.service.type }}
{{- else if contains "LoadBalancer" (index .Values "web-service-frontend").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 --namespace {{ .Release.Namespace }} svc -w {{ printf "%s-%s" (include "netris-controller.fullname" .) "app" }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ printf "%s-%s" (include "netris-controller.fullname" .) "app" }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.app.service.port }}
{{- else if contains "ClusterIP" .Values.app.service.type }}
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ printf "%s-%s" (include "netris-controller.fullname" .) "web-service-frontend" }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ printf "%s-%s" (include "netris-controller.fullname" .) "web-service-frontend" }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ (index .Values "web-service-frontend").service.port }}
{{- else if contains "ClusterIP" (index .Values "web-service-frontend").service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "netris-controller.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}

{{/* run deprecations */}}
{{ include "deprecations" . }}
34 changes: 34 additions & 0 deletions charts/netris-controller/templates/_deprecations.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- define "deprecations" -}}
{{- $deprecated := list -}}
{{/* add templates here */}}
{{- $deprecated = append $deprecated (include "deprecate.appIngress" .) -}}
{{- $deprecated = append $deprecated (include "deprecate.app" .) -}}

{{- /* prepare output */}}
{{- $deprecated = without $deprecated "" -}}
{{- $message := join "\n" $deprecated -}}

{{- /* print output */}}
{{- if $message -}}
{{- printf "\nDEPRECATIONS:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}


{{/* Deprecation behaviors for .app.ingress */}}
{{- define "deprecate.appIngress" -}}
{{- if .Values.app }}
{{- if hasKey .Values.app "ingress" -}}
app.ingress:
The configuration of `app.ingress` has been renamed. Please use `ingress` instead.
{{- end -}}
{{- end -}}
{{- end -}}

{{/* Deprecation behaviors for .app */}}
{{- define "deprecate.app" -}}
{{- if .Values.app }}
app:
The configuration of `app` has been renamed. Please use `web-service-backend` or `web-service-frontend` instead.
{{- end -}}
{{- end -}}
12 changes: 12 additions & 0 deletions charts/netris-controller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ secret-key: {{ (index $secret.data "secret-key") }}
secret-key: {{ randAlphaNum 40 | b64enc }}
{{- end }}
{{- end }}

{{/*
Generate a grpc-secret secret or use the existing one
*/}}
{{- define "grpc.secret" -}}
{{- $secret := lookup "v1" "Secret" .Release.Namespace (printf "%s-%s" (include "netris-controller.fullname" .) "grpc-secret") -}}
{{- if $secret }}
secret-key: {{ (index $secret.data "secret-key") }}
{{- else }}
secret-key: {{ randAlphaNum 40 | b64enc }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/netris-controller/templates/equinix-metal-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
command:
- sh
- -c
- for i in $(seq 1 200); do nc -z -w3 {{ printf "%s-%s" (include "netris-controller.fullname" .) "app" }} {{ .Values.app.service.port }} && exit 0 || sleep 3; done; exit 1
- for i in $(seq 1 200); do nc -z -w3 {{ printf "%s-%s" (include "netris-controller.fullname" .) "web-service-backend" }} {{ (index .Values "web-service-backend").service.port }} && exit 0 || sleep 3; done; exit 1
- name: init-wait-websession
image: alpine:3.11
command:
Expand All @@ -54,7 +54,7 @@ spec:
- name: EQUINIX_ADDR
value: https://api.packet.net
- name: CONTROLLER_ADDR
value: http://{{ printf "%s-%s" (include "netris-controller.fullname" .) "app" }}:{{ .Values.app.service.port }}
value: http://{{ printf "%s-%s" (include "netris-controller.fullname" .) "web-service-backend" }}:{{ (index .Values "web-service-backend").service.port }}
- name: SESSION_PROVIDER_HOST
value: http://{{ printf "%s-%s" (include "netris-controller.fullname" .) "web-session-generator" }}:{{ (index .Values "web-session-generator").service.port }}
- name: WEB_SESSION_SECRET
Expand Down
16 changes: 16 additions & 0 deletions charts/netris-controller/templates/grpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ (index .Values $microservicename).image.repository }}:{{ (index .Values $microservicename).image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ (index .Values $microservicename).image.pullPolicy }}
env:
- name: GRPC_AUTH_KEYS
valueFrom:
secretKeyRef:
name: {{ printf "%s-%s" (include "netris-controller.fullname" .) "grpc-secret" }}
key: secret-key
command: ['/app/servicebin', '-c', '/app/config/grpc.conf']
ports:
- name: {{ (index .Values $microservicename).service.name }}
Expand Down Expand Up @@ -161,3 +167,13 @@ data:
password={{ .Values.mariadb.auth.password }}
database={{ .Values.mariadb.auth.database }}
port={{ .Values.mariadb.primary.service.port }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-%s" (include "netris-controller.fullname" .) "grpc-secret" }}
labels:
{{- include "netris-controller.labels" . | nindent 4 }}
type: Opaque
data:
{{- ( include "grpc.secret" . ) | indent 2 -}}
77 changes: 77 additions & 0 deletions charts/netris-controller/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
{{- if .Values.ingress.enabled -}}
{{- $fullName := printf "%s-%s" (include "netris-controller.fullname" .) "web-service-frontend" -}}
{{- $servicePort := (index .Values "web-service-frontend").service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $ingressPathType := .Values.ingress.pathType -}}
{{- $newAPI := .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
{{- if $newAPI -}}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "netris-controller.labels" . | nindent 4 }}
{{- printf "%s-%s" (include "netris-controller.selectorLabels" .) "web-service-frontend" | nindent 4 }}
{{- if .Values.ingress.labels }}
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- end }}
{{- if .Values.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ tpl (toYaml .Values.ingress.tls) $ | indent 4 }}
{{- end }}
rules:
{{- if .Values.ingress.hosts }}
{{- range .Values.ingress.hosts }}
- host: {{ tpl . $}}
http:
paths:
- path: {{ $ingressPath }}
{{- if $newAPI }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $newAPI }}
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end }}
{{- else }}
- http:
paths:
- backend:
{{- if $newAPI }}
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
pathType: {{ $ingressPathType }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- if $ingressPath }}
path: {{ $ingressPath }}
{{- end }}
{{- end -}}
{{- end }}
6 changes: 6 additions & 0 deletions charts/netris-controller/templates/migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ metadata:
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
backoffLimit: 0
template:
metadata:
{{- with .Values.podAnnotations }}
Expand Down Expand Up @@ -54,6 +55,11 @@ spec:
secretKeyRef:
name: {{ printf "%s-%s" (include "netris-controller.fullname" .) "mariadb" }}
key: mariadb-password
- name: DB_PASS_ROOT
valueFrom:
secretKeyRef:
name: {{ printf "%s-%s" (include "netris-controller.fullname" .) "mariadb" }}
key: mariadb-root-password
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand Down
Loading

0 comments on commit 1a2592b

Please sign in to comment.