Skip to content

Commit 3552e27

Browse files
authored
[ratel] feat: allow namespace override (#115)
Signed-off-by: Artem Chubar <[email protected]>
1 parent 1987415 commit 3552e27

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

charts/ratel/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following table lists the configurable parameters of the ratel chart and the
4040
| `image.tag` | Container image tag | `v21.12.0` |
4141
| `imagePullSecrets` | Image pull secrets auth tokens used to access a private registry | `[]` |
4242
| `nameOverride` | Name override of the default chart name | `""` |
43+
| `namespaceOverride` | Namespace override | `nil` |
4344
| `fullnameOverride` | Full Name override of the release name + chart name | `""` |
4445
| `serviceAccount.create` | Specifies if service account should be created | `true` |
4546
| `serviceAccount.annotations` | Service Account annotations | `{}` |

charts/ratel/templates/NOTES.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
{{- end }}
77
{{- end }}
88
{{- else if contains "NodePort" .Values.service.type }}
9-
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ratel.fullname" . }})
10-
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
9+
export NODE_PORT=$(kubectl get --namespace {{ include "ratel.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ratel.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ include "ratel.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
1111
echo http://$NODE_IP:$NODE_PORT
1212
{{- else if contains "LoadBalancer" .Values.service.type }}
1313
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14-
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "ratel.fullname" . }}'
15-
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ratel.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
14+
You can watch the status of by running 'kubectl get --namespace {{ include "ratel.namespace" . }} svc -w {{ include "ratel.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "ratel.namespace" . }} {{ include "ratel.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
1616
echo http://$SERVICE_IP:{{ .Values.service.port }}
1717
{{- else if contains "ClusterIP" .Values.service.type }}
18-
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "ratel.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19-
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
18+
export POD_NAME=$(kubectl get pods --namespace {{ include "ratel.namespace" . }} -l "app.kubernetes.io/name={{ include "ratel.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ include "ratel.namespace" . }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
2020
echo "Visit http://127.0.0.1:8000 to use your application"
21-
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8000:$CONTAINER_PORT
21+
kubectl --namespace {{ include "ratel.namespace" . }} port-forward $POD_NAME 8000:$CONTAINER_PORT
2222
{{- end }}

charts/ratel/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ Create the name of the service account to use
6060
{{- default "default" .Values.serviceAccount.name }}
6161
{{- end }}
6262
{{- end }}
63+
64+
{{/*
65+
Allow overriding namespace
66+
*/}}
67+
{{- define "ratel.namespace" -}}
68+
{{- default .Release.Namespace .Values.namespaceOverride -}}
69+
{{- end -}}

charts/ratel/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ include "ratel.fullname" . }}
5+
namespace: {{ include "ratel.namespace" . }}
56
labels:
67
{{- include "ratel.labels" . | nindent 4 }}
78
spec:

charts/ratel/templates/ingress.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ apiVersion: extensions/v1beta1
1616
kind: Ingress
1717
metadata:
1818
name: {{ $fullName }}
19+
namespace: {{ include "ratel.namespace" . }}
1920
labels:
2021
{{- include "ratel.labels" . | nindent 4 }}
2122
{{- with .Values.ingress.annotations }}

charts/ratel/templates/service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: {{ include "ratel.fullname" . }}
5+
namespace: {{ include "ratel.namespace" . }}
56
labels:
67
{{- include "ratel.labels" . | nindent 4 }}
78
spec:

charts/ratel/templates/serviceaccount.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: v1
33
kind: ServiceAccount
44
metadata:
55
name: {{ include "ratel.serviceAccountName" . }}
6+
namespace: {{ include "ratel.namespace" . }}
67
labels:
78
{{- include "ratel.labels" . | nindent 4 }}
89
{{- with .Values.serviceAccount.annotations }}

charts/ratel/templates/tests/test-connection.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: v1
22
kind: Pod
33
metadata:
44
name: "{{ include "ratel.fullname" . }}-test-connection"
5+
namespace: {{ include "ratel.namespace" . }}
56
labels:
67
{{- include "ratel.labels" . | nindent 4 }}
78
annotations:

0 commit comments

Comments
 (0)