Skip to content

Commit

Permalink
feat: allow define & run custom scripts while startup
Browse files Browse the repository at this point in the history
  • Loading branch information
nefelim4ag committed Dec 8, 2022
1 parent 52d7375 commit b82783e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/k8s-ssh-bastion/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: 0.3.0
description: A Helm chart for k8s bastion
name: k8s-ssh-bastion
version: 0.3.5
version: 0.3.6
21 changes: 21 additions & 0 deletions charts/k8s-ssh-bastion/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ spec:
mkdir -p /run/sshd
{{- with .Values.initscripts }}
{{- range $key, $value := . }}
{{ $key }}
{{- end }}
{{- end }}
/usr/sbin/sshd -D -e -E /proc/1/fd/1
lifecycle: {{ .Values.lifecycle | toJson }}
ports:
Expand All @@ -61,6 +67,8 @@ spec:
mountPath: /etc/ssh
- name: sshd-configs-origin
mountPath: /etc/ssh_origin
- name: usr-share-initscripts
mountPath: /usr/share/initscripts
resources:
{{ toYaml .Values.resources | indent 12 }}
hostNetwork: {{ .Values.hostNetwork }}
Expand All @@ -84,6 +92,10 @@ spec:
- name: sshd-configs-origin
configMap:
name: {{ .Release.Name }}-etc-ssh-origin
- name: usr-share-startup
configMap:
name: {{ .Release.Name }}-usr-share-initscripts
defaultMode: 0755
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -100,6 +112,15 @@ metadata:
data:
{{ tpl (toYaml .Values.ssh) $ | indent 2 }}

---
# Additional startup commands
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-usr-share-initscripts
data:
{{ tpl (toYaml .Values.initscripts) $ | indent 2 }}

---
# Used to store ssh host keys & other stuff
apiVersion: v1
Expand Down
5 changes: 5 additions & 0 deletions charts/k8s-ssh-bastion/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ topologySpreadConstraints:

storageClass: "efs"

initscripts: {}
# install-tools.sh: |
# #!/bin/bash
# echo do something

# Override files under /etc/ssh
ssh:
banner: |
Expand Down

0 comments on commit b82783e

Please sign in to comment.