Skip to content

Commit

Permalink
feat: add kurl proxy resources to AdminConsole helm chart (#32)
Browse files Browse the repository at this point in the history
* feat: Add kurl proxy service to allow TLS setup

* Add admin-console labels to kurl resources

* Only deploy admin console service if kURL proxy is absent

* Remove duplicate labels

* Delete helm chart before building and correct template error
  • Loading branch information
banjoh authored Jan 12, 2024
1 parent d1cf8e8 commit 419f1f2
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ scripts/
/*.yaml.tmpl
/.image.env
/.git
/.github
/.github
/.tgz
1 change: 1 addition & 0 deletions scripts/build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export $(cat .image.env | sed 's/#.*//g' | xargs)
envsubst < Chart.yaml.tmpl > Chart.yaml
envsubst < values.yaml.tmpl > values.yaml

rm -f admin-console-*.tgz
export CHART_NAME=`helm package . | rev | cut -d/ -f1 | rev`
helm push $CHART_NAME oci://ttl.sh/${CURRENT_USER}

Expand Down
1 change: 1 addition & 0 deletions scripts/build-ttl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export $(cat .image.env | sed 's/#.*//g' | xargs)
envsubst < Chart.yaml.tmpl > Chart.yaml
envsubst < values.yaml.tmpl > values.yaml

rm -f admin-console-*.tgz
export CHART_NAME=`helm package . | rev | cut -d/ -f1 | rev`
helm push $CHART_NAME oci://ttl.sh/$USER

Expand Down
15 changes: 12 additions & 3 deletions templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
{{- else if .Values.service.enabled }}
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "admin-console.fullname" . }})
Create an external IP for your NodePort service. This IP should be the public IP address of your instance. Add the IP under spec.externalIPs
Create an external IP for your NodePort service. This IP should be the public IP address of your instance. Add the IP under spec.externalIPs
kubectl edit svc admin-console --namespace {{ .Release.Namespace }}
Ensure your security group allows for inbound requests on $NODE_PORT
export EXTERNAL_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "admin-console.fullname" . }} -o jsonpath="{.spec.externalIPs[0]}")
Expand All @@ -23,4 +24,12 @@
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
The default password is `password` and it is recommended to change this immediately after initially logging in.
{{- else if .Values.kurlProxy.enabled }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "admin-console.fullname" . }})
Create an external IP for your NodePort service. This IP should be the public IP address of your instance. Add the IP under spec.externalIPs
kubectl edit svc kurl-proxy-kotsadm --namespace {{ .Release.Namespace }}
Ensure your security group allows for inbound requests on $NODE_PORT
export EXTERNAL_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "admin-console.fullname" . }} -o jsonpath="{.spec.externalIPs[0]}")
echo http://$EXTERNAL_IP:$NODE_PORT
{{- end }}
The default password is `password` and it is recommended to change this immediately after initially logging in.
2 changes: 2 additions & 0 deletions templates/kotsadm-service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ if .Values.service.enabled }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -17,3 +18,4 @@ spec:
type: {{ .Values.service.type }}
status:
loadBalancer: {}
{{ end }}
54 changes: 54 additions & 0 deletions templates/kurl-proxy-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{ if .Values.kurlProxy.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: kurl-proxy-kotsadm
labels:
app: kurl-proxy-kotsadm
{{- include "admin-console.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: kurl-proxy-kotsadm
template:
metadata:
labels:
app: kurl-proxy-kotsadm
{{- include "admin-console.labels" . | nindent 8 }}
spec:
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: proxy
image: {{ .Values.images.kurlProxy }}
imagePullPolicy: IfNotPresent
env:
- name: NODE_PORT
value: "{{ .Values.kurlProxy.targetPort }}"
- name: UPSTREAM_ORIGIN
value: http://kotsadm:3000
- name: TLS_SECRET_NAME
value: kotsadm-tls
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: kotsadm-config
mountPath: /etc/kotsadm
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 50m
memory: 50Mi
serviceAccount: kurl-proxy
volumes:
- name: kotsadm-config
configMap:
name: kotsadm-application-metadata
optional: true
{{ end }}
37 changes: 37 additions & 0 deletions templates/kurl-proxy-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ if .Values.kurlProxy.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: kurl-proxy
namespace: {{ .Release.Namespace }}
labels:
{{- include "admin-console.labels" . | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: {{ .Release.Namespace }}
name: secret-manager
labels:
{{- include "admin-console.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list", "create", "patch", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kurl-proxy-tls-secrets
namespace: {{ .Release.Namespace }}
labels:
{{- include "admin-console.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: secret-manager
subjects:
- kind: ServiceAccount
name: kurl-proxy
namespace: {{ .Release.Namespace }}
{{ end }}
18 changes: 18 additions & 0 deletions templates/kurl-proxy-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ if .Values.kurlProxy.enabled }}
apiVersion: v1
kind: Service
metadata:
name: kurl-proxy-kotsadm
labels:
{{- include "admin-console.labels" . | nindent 4 }}
spec:
type: NodePort
selector:
app: kurl-proxy-kotsadm
ports:
- port: {{ .Values.kurlProxy.targetPort }}
targetPort: {{ .Values.kurlProxy.targetPort }}
{{- if .Values.kurlProxy.nodePort }}
nodePort: {{ .Values.kurlProxy.nodePort }}
{{- end}}
{{ end }}
6 changes: 6 additions & 0 deletions values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ images:
migrations: ${KOTSADM_REGISTRY}/kotsadm-migrations:${KOTS_TAG}
minio: ${KOTSADM_REGISTRY}/minio:${MINIO_TAG}
rqlite: ${KOTSADM_REGISTRY}/rqlite:${RQLITE_TAG}
kurlProxy: ${KOTSADM_REGISTRY}/kurl-proxy:${KOTS_TAG}
password: ""
minimalRBAC: true
isHelmManaged: true
Expand Down Expand Up @@ -47,6 +48,7 @@ securityContext: {}
# runAsUser: 1000

service:
enabled: true
type: NodePort
port: 80

Expand Down Expand Up @@ -102,3 +104,7 @@ affinity:
operator: NotIn
values:
- arm64

kurlProxy:
enabled: false
targetPort: 8800

0 comments on commit 419f1f2

Please sign in to comment.