-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chart): store ssh keys in k8s secrets
- Loading branch information
1 parent
2bf1af0
commit bc428f7
Showing
7 changed files
with
116 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
apiVersion: v1 | ||
appVersion: 0.4.0 | ||
appVersion: 0.4.1 | ||
description: A Helm chart for k8s bastion | ||
name: k8s-ssh-bastion | ||
version: 0.4.0 | ||
version: 0.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: "{{ .Release.Name }}-{{ .Release.Revision }}" | ||
spec: | ||
ttlSecondsAfterFinished: 300 | ||
template: | ||
spec: | ||
serviceAccountName: {{ .Release.Name }} | ||
containers: | ||
- name: ssh-keygen | ||
image: "{{ .Values.image.repository }}:{{ tpl .Values.image.tag $ }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
command: | ||
- /bin/bash | ||
- -ec | ||
- | | ||
cd /etc/ssh | ||
for key_type in rsa ecdsa ed25519; do | ||
if kubectl -n k8s-bastion get secrets {{ .Release.Name }}-${key_type} -o name; then | ||
continue | ||
fi | ||
lengh=4096 | ||
[ $key_type == "ecdsa" ] && lengh=256 | ||
test -f ssh_host_${key_type}_key || \ | ||
ssh-keygen -q -N "" -t ${key_type} -b $lengh -f ./ssh_host_${key_type}_key | ||
kubectl create secret generic {{ .Release.Name }}-${key_type} \ | ||
--from-file=ssh_host_${key_type}_key=./ssh_host_${key_type}_key \ | ||
--from-file=ssh_host_${key_type}_key.pub=./ssh_host_${key_type}_key.pub | ||
done | ||
volumeMounts: | ||
- name: opt | ||
mountPath: /etc/ssh | ||
volumes: | ||
- name: opt | ||
emptyDir: {} | ||
restartPolicy: Never | ||
backoffLimit: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ .Release.Name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ .Release.Name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ .Release.Name }} | ||
rules: | ||
- verbs: | ||
- create | ||
- get | ||
apiGroups: | ||
- '' | ||
resources: | ||
- secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ .Release.Name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters