Skip to content

Commit ee5afd7

Browse files
update
1 parent b626538 commit ee5afd7

6 files changed

Lines changed: 53 additions & 9 deletions

File tree

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ RUN curl -L -o /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64
5252
chmod +x /usr/local/bin/mc
5353

5454
# Create non-root user with specific UID/GID
55-
RUN addgroup --gid 1001 devgroup && \
56-
adduser --uid 1001 --ingroup devgroup --shell /bin/bash --home /home/dev --disabled-password dev && \
55+
RUN addgroup --gid 1001 dev && \
56+
adduser --uid 1001 --ingroup dev --shell /bin/bash --home /home/dev --disabled-password dev && \
5757
echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
5858

5959
# Adjust permissions for /usr/local and home directories
60-
RUN chown -R dev:devgroup /usr/local /home/dev
60+
RUN chown -R dev:dev /usr/local /home/dev
6161

6262
# Switch to non-root user
6363
USER dev
@@ -67,8 +67,8 @@ COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
6767
RUN chmod 755 /usr/local/bin/entrypoint.sh
6868

6969
# Set environment variables, including PATH to specific directories
70-
ENV PATH="/usr/local/bin:$PATH"
7170
ENV VIRTUAL_ENV="/usr/local/venv"
71+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
7272

7373
# Expose SSH port
7474
EXPOSE 2222
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: dev-environment-entrypoint
4+
name: {{ .Release.Name }}-entrypoint
55
data:
66
entrypoint.sh: |
77
#!/bin/bash
@@ -25,11 +25,8 @@ data:
2525
2626
# Correct permissions for SSH keys
2727
chmod 600 /home/dev/ssh_keys/ssh_host_*
28-
29-
# Ensure the run directory for the PID file exists and has the right permissions
3028
echo "Ensuring run directory exists at /home/dev/run."
3129
mkdir -p /home/dev/run
32-
chown dev:dev /home/dev/run
3330
3431
3532
echo "Starting SSH service with host keys from /home/dev/ssh_keys on port 2222."

chart/templates/cm-sshconfig.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ .Release.Name }}-sshd-config
5+
data:
6+
sshd_config: |
7+
Port {{ .Values.service.targetPort }}
8+
PermitRootLogin no
9+
PasswordAuthentication yes
10+
ChallengeResponseAuthentication no
11+
UsePAM yes
12+
X11Forwarding yes
13+
PrintMotd no
14+
AcceptEnv LANG LC_*
15+
Subsystem sftp /usr/lib/openssh/sftp-server
16+
UseDNS no
17+
PidFile /home/dev/run/sshd.pid

chart/templates/cm-sshkeys.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ .Release.Name }}-ssh-keys
5+
data:
6+
authorized_keys: |-
7+
{{ .Values.ssh.authorizedKeys | nindent 4 }}
8+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDBMGGOs2OYGxj74/TS3AXmbGNoVLQ07gCG5LXamlrd6HoZLPRkqwy2X1YS+9mWvINwH7FzvPnzd+5P5fxeLiYiwTIEXamlqQ53rnTvvgtS9Wl7fI/4MdlI2pNsAS3jm1KOzn/w5ABTkvGUo9QtzgR2659ykpo/LicsShEqVKh0ItOv+D298JsD5Ykj9Y3S5GE4D84DGisBpvBxdkMWm3ZD4SYML4b/P2ihFL3IEdmPfewS7O37bpAe4TuhjltOmTBjy4QaQgQacMDXkz5WCrCYh3N2/2gmsPLR5lirH9YJLzyGR08uhsyFMe79Rxl+Fs+9UDvx5hcVjXMUOnO34G3fTu54OTcekN+h7l+6rLWuSuiRH0O+RIV3PvlT+ibOiRPwfWSWDQtMTTynRrYMKEtnFr/Eg0EtdQRzFhrwxwX9+zaAgAcmL/3qIDSzEwOWm6pVH1RNKjC9K8pDu9mKmD6zKFfkqsMh9aV6N+mSTcDnLfMRD9xYWSbJnH2Xj3c3uskJ2XsGDdHoxIQvx2KfStaGshN83mzbvn9Qx3SwdI2X/lpABIrrSg97kNKWPywB8s5J3a86Y+Knvd8fSz3lM/2Yk1lZ9oYN68wD0mqNmPbxIMQVaKh1pd4xTucVM+1E+IEKFk8Un6xNRk0luYanbGjvYpN5gxnEfq4NT1+VhKrcHw== marcel zapf@DESKTOP-CR0CINF

chart/templates/deployment.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ spec:
1414
spec:
1515
securityContext:
1616
fsGroup: 1001
17+
runAsUser: 1001
1718
containers:
1819
- name: {{ .Release.Name }}
1920
image: "{{ .Values.image.source }}"
@@ -36,13 +37,29 @@ spec:
3637
mountPath: /usr/local/bin/entrypoint.sh
3738
subPath: entrypoint.sh
3839
readOnly: true
40+
- name: ssh-keys
41+
mountPath: /home/dev/.ssh/authorized_keys
42+
subPath: authorized_keys
43+
readOnly: true
44+
- name: sshd-config-volume
45+
mountPath: /etc/ssh/sshd_config
46+
subPath: sshd_config
47+
readOnly: true
3948
resources:
4049
{{ toYaml .Values.resources | indent 10 }}
4150
volumes:
4251
- name: entrypoint-script
4352
configMap:
44-
name: dev-environment-entrypoint
53+
name: {{ .Release.Name }}-entrypoint
4554
defaultMode: 0755
4655
- name: home-volume
4756
persistentVolumeClaim:
4857
claimName: {{ .Release.Name }}-pvc
58+
- name: ssh-keys
59+
configMap:
60+
name: {{ .Release.Name }}-ssh-keys
61+
defaultMode: 0755
62+
- name: sshd-config-volume
63+
configMap:
64+
name: {{ .Release.Name }}-sshd-config
65+
defaultMode: 0755

chart/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ persistence:
1616

1717
resources: {}
1818

19+
ssh:
20+
authorizedKeys: |
21+
# Place auth keys here ...
22+
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu...
23+
1924
securityContext:
2025
runAsNonRoot: true
2126
runAsUser: 1001

0 commit comments

Comments
 (0)