Skip to content

Commit b82783e

Browse files
committed
feat: allow define & run custom scripts while startup
1 parent 52d7375 commit b82783e

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

charts/k8s-ssh-bastion/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ apiVersion: v1
22
appVersion: 0.3.0
33
description: A Helm chart for k8s bastion
44
name: k8s-ssh-bastion
5-
version: 0.3.5
5+
version: 0.3.6

charts/k8s-ssh-bastion/templates/deployment.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ spec:
4848
4949
mkdir -p /run/sshd
5050
51+
{{- with .Values.initscripts }}
52+
{{- range $key, $value := . }}
53+
{{ $key }}
54+
{{- end }}
55+
{{- end }}
56+
5157
/usr/sbin/sshd -D -e -E /proc/1/fd/1
5258
lifecycle: {{ .Values.lifecycle | toJson }}
5359
ports:
@@ -61,6 +67,8 @@ spec:
6167
mountPath: /etc/ssh
6268
- name: sshd-configs-origin
6369
mountPath: /etc/ssh_origin
70+
- name: usr-share-initscripts
71+
mountPath: /usr/share/initscripts
6472
resources:
6573
{{ toYaml .Values.resources | indent 12 }}
6674
hostNetwork: {{ .Values.hostNetwork }}
@@ -84,6 +92,10 @@ spec:
8492
- name: sshd-configs-origin
8593
configMap:
8694
name: {{ .Release.Name }}-etc-ssh-origin
95+
- name: usr-share-startup
96+
configMap:
97+
name: {{ .Release.Name }}-usr-share-initscripts
98+
defaultMode: 0755
8799
---
88100
apiVersion: v1
89101
kind: ConfigMap
@@ -100,6 +112,15 @@ metadata:
100112
data:
101113
{{ tpl (toYaml .Values.ssh) $ | indent 2 }}
102114

115+
---
116+
# Additional startup commands
117+
apiVersion: v1
118+
kind: ConfigMap
119+
metadata:
120+
name: {{ .Release.Name }}-usr-share-initscripts
121+
data:
122+
{{ tpl (toYaml .Values.initscripts) $ | indent 2 }}
123+
103124
---
104125
# Used to store ssh host keys & other stuff
105126
apiVersion: v1

charts/k8s-ssh-bastion/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ topologySpreadConstraints:
5656

5757
storageClass: "efs"
5858

59+
initscripts: {}
60+
# install-tools.sh: |
61+
# #!/bin/bash
62+
# echo do something
63+
5964
# Override files under /etc/ssh
6065
ssh:
6166
banner: |

0 commit comments

Comments
 (0)