Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-8812] Create operator secret for tyk-oss chart #272

Merged
merged 10 commits into from
Apr 29, 2024
22 changes: 12 additions & 10 deletions tyk-oss/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
Thank you for installing Tyk OSS Chart. Your release is named {{ .Release.Name }}.
At this point, Tyk Gateway {{- if .Values.global.components.pump }} and Tyk Pump are {{- else }} is {{- end }} fully installed and should be accessible.

{{- if index .Values "tyk-gateway" "gateway" "control" "enabled" }}
{{ $gwSvcName := printf "gateway-control-svc-%v" (include "tyk-gateway.fullname" (index .Subcharts "tyk-gateway")) }}
{{ $gwSvcName := (include "tyk-oss.gwControlServiceName" . ) }}
{{- $port := (include "tyk-oss.gwControlPort" . ) -}}
To quickly test everything is ok, you can port-forward Tyk Gateway pod:
kubectl port-forward --namespace {{ .Release.Namespace }} service/{{ $gwSvcName }} {{ index .Values "tyk-gateway" "gateway" "control" "port" }}:{{ index .Values "tyk-gateway" "gateway" "control" "containerPort" }}
curl localhost:{{ index .Values "tyk-gateway" "gateway" "control" "port" }}/hello
{{- else }}
{{ $gwSvcName := printf "gateway-svc-%v" (include "tyk-gateway.fullname" (index .Subcharts "tyk-gateway")) }}
To quickly test everything is ok, you can port-forward Tyk Gateway pod:
kubectl port-forward --namespace {{ .Release.Namespace }} service/{{ $gwSvcName }} {{ index .Values "global" "servicePorts" "gateway" }}:{{ index .Values "global" "servicePorts" "gateway" }}
curl localhost:{{ index .Values "global" "servicePorts" "gateway" }}/hello
{{- end }}
kubectl port-forward --namespace {{ .Release.Namespace }} service/{{ $gwSvcName }} {{ $port }}:{{ $port }}
curl localhost:{{ $port }}/hello

=== API Secret (TYK_GW_SECRET) ===
{{- if not .Values.global.secrets.useSecretName -}}
Expand All @@ -26,3 +20,11 @@ To quickly test everything is ok, you can port-forward Tyk Gateway pod:
===================================================
You might want to install Tyk Operator next to manage Ingress resources or manage your APIs.
Please check Tyk Operator documentation at https://tyk.io/docs/tyk-operator/
{{ if .Values.operatorSecret.enabled }}
=== Tyk Operator Secret (tyk-operator-conf) ===
The `tyk-operator-conf` secret, required for Tyk Operator to establish a connection with Tyk Gateway, is generated in the {{ .Release.Namespace }} namespace.

If API Secret of Tyk Gateway has configured via `global.secret.useSecretName` field, ensure that the `TYK_AUTH` field in the `tyk-operator-conf` secret contains the API secret of Tyk Gateway. This step ensures that Tyk Operator correctly identifies the API secret.

NOTE: After updating `tyk-operator-conf`, make sure that Tyk Operator pod is restarted.
{{- end }}
20 changes: 20 additions & 0 deletions tyk-oss/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,23 @@ http
{{- define "tyk-oss.gwServicePort" -}}
{{ .Values.global.servicePorts.gateway }}
{{- end -}}

{{- define "tyk-oss.gwControlServiceName" -}}
{{- if index .Values "tyk-gateway" "gateway" "control" "enabled" -}}
{{ printf "gateway-control-svc-%v" (include "tyk-gateway.fullname" (index .Subcharts "tyk-gateway")) }}
{{- else -}}
{{ printf "gateway-svc-%v" (include "tyk-gateway.fullname" (index .Subcharts "tyk-gateway")) }}
{{- end -}}
{{- end -}}

{{- define "tyk-oss.gwControlPort" -}}
{{- if index .Values "tyk-gateway" "gateway" "control" "enabled" -}}
{{ index .Values "tyk-gateway" "gateway" "control" "port" }}
{{- else -}}
{{ .Values.global.servicePorts.gateway }}
{{- end -}}
{{- end -}}

{{- define "tyk-oss.gwControlURL" -}}
{{ printf "%v://%v.%v.svc:%v" (include "tyk-oss.gw_proto" . ) (include "tyk-oss.gwControlServiceName" . ) .Release.Namespace (include "tyk-oss.gwControlPort" . ) }}
{{- end -}}
14 changes: 14 additions & 0 deletions tyk-oss/templates/tyk-operator-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.operatorSecret.enabled}}
apiVersion: v1
kind: Secret
metadata:
name: tyk-operator-conf
type: Opaque
stringData:
TYK_MODE: "ce"
{{- if not .Values.global.secrets.useSecretName}}
TYK_AUTH: "{{ .Values.global.secrets.APISecret}}"
{{- end }}
TYK_URL: "{{ include "tyk-oss.gwControlURL" . }}"
TYK_ORG: "{{ .Values.operatorSecret.orgID}}"
{{- end }}
8 changes: 8 additions & 0 deletions tyk-oss/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ nameOverride: ""
# fullnameOverride overrides App name. It is truncated to 63 characters.
fullnameOverride: ""

# operatorSecret controls if a secret needed to connect to Operator will be created
operatorSecret:
# enabled if set to true creates secret
enabled: true
# OSS doesn't have concept of OrgID. But we need to support some features (eg. basic auth key) in OSS
# You can set it to any arbitary value
orgID: "orgid"

global:
components:
# Determines whether the pump component should be installed.
Expand Down