Skip to content
Snippets Groups Projects
Commit cc6c1345 authored by Andri Joos's avatar Andri Joos :blush:
Browse files

add initial ssh jumphost chart

parent 9b04128b
No related branches found
No related tags found
No related merge requests found
ssh-jump-host/charts
out/
include:
- project: charts/ci-templates
ref: master
file: gitlab_deployment.gitlab-ci.yml
variables:
CHART_DIRECTORY: ssh-jump-host/
CHANNEL: stable
deploy_on_gitlab:
only:
- tags
# SSH Jump Host
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
# Installation instructions
```sh
helm repo add jumphost https://git.420joos.dev/api/v4/projects/295/packages/helm/stable
helm install my-jump-host jumphost/ssh-jump-host --namespace my-namespace
```
cd existing_repo
git remote add origin https://git.420joos.dev/charts/ssh-jump-host.git
git branch -M master
git push -uf origin master
```
## Integrate with your tools
- [ ] [Set up project integrations](https://git.420joos.dev/charts/ssh-jump-host/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
dependencies:
- name: common
repository: https://git.420joos.dev/api/v4/projects/293/packages/helm/stable
version: 1.0.0
digest: sha256:d2732df02ba3fec1c88a9f69b8a96014cf722b236e19a6dea717ee23967d7703
generated: "2025-01-24T21:05:52.174192659+01:00"
apiVersion: v2
name: ssh-jump-host
description: SSH Jump Host in Kubernetes
type: application
version: 1.0.0
appVersion: "latest"
dependencies:
- name: common
repository: https://git.420joos.dev/api/v4/projects/293/packages/helm/stable
version: 1.0.0
{{/*
Expand the name of the chart.
*/}}
{{- define "ssh-jump-host.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ssh-jump-host.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ssh-jump-host.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "ssh-jump-host.labels" -}}
helm.sh/chart: {{ include "ssh-jump-host.chart" . }}
{{ include "ssh-jump-host.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "ssh-jump-host.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ssh-jump-host.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- range $id, $values := .Values.configs }}
{{ include "common.configmap" (dict "Values" $values "Chart" $.Chart "Release" $.Release) }}
{{- end }}
# Init scripts
{{- $values := .Files.Get "values/init-configmap.yaml" | fromYaml }}
{{ include "common.configmap" (dict "Values" $values "Chart" $.Chart "Release" $.Release) }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ssh-jump-host.fullname" . }}
labels:
{{- include "ssh-jump-host.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "ssh-jump-host.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
configs-hash: {{ .Values.configs | toYaml | sha256sum | quote }}
ssh-keys-hash: {{ (dict "hostKeys" .Values.hostKeys "userKeys" .Values.userKeys) | toYaml | sha256sum | quote }}
labels:
{{- include "ssh-jump-host.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
- name: ssh-keys
image: busybox
command:
- sh
- /init_script.sh
volumeMounts:
- name: ssh-host-keys-secret
mountPath: /ssh_host_keys_secret
- name: ssh-host-keys
mountPath: /ssh_host_keys
- name: ssh-user-keys-secret
mountPath: /ssh_user_keys_secret
- name: ssh-user-keys
mountPath: /ssh_user_keys
- name: init-scripts
mountPath: /init_script.sh
subPath: init_script.sh
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: PUID
value: "1000"
- name: PGID
value: "1000"
- name: PUBLIC_KEY_DIR
value: /authorized_keys
- name: PASSWORD_ACCESS
value: {{ .Values.passwordEnabled | quote }}
- name: SUDO_ACCESS
value: {{ .Values.sudoEnabled | quote }}
- name: USER_NAME
value: {{ .Values.username | quote }}
- name: LOG_STDOUT
value: {{ .Values.loggingEnabled | quote }}
ports:
- name: ssh
containerPort: 2222
protocol: TCP
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
- name: ssh-host-keys
mountPath: /config/ssh_host_keys
- name: ssh-user-keys
mountPath: /authorized_keys
- name: sshd-config
mountPath: /etc/ssh/sshd_config.d/
- name: startup-scripts
mountPath: /custom-cont-init.d
- name: banner
mountPath: /etc/ssh/ssh_banner
subPath: ssh_banner
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
- name: ssh-host-keys-secret
secret:
secretName: {{ .Values.hostKeys.name }}
- name: ssh-host-keys
emptyDir: {}
- name: ssh-user-keys-secret
secret:
secretName: {{ .Values.userKeys.name }}
- name: ssh-user-keys
emptyDir: {}
- name: sshd-config
configMap:
name: {{ .Values.configs.sshd.name }}
- name: startup-scripts
configMap:
name: {{ .Values.configs.startupScripts.name }}
- name: banner
configMap:
name: {{ .Values.configs.banner.name }}
items:
- key: ssh_banner
path: ssh_banner
- name: init-scripts
configMap:
name: {{ (.Files.Get "values/init-configmap.yaml" | fromYaml).name }}
items:
- key: init_script.sh
path: init_script.sh
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "ssh-jump-host.fullname" . }}
labels:
{{- include "ssh-jump-host.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "ssh-jump-host.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.tcpRoute.enabled }}
{{ include "common.traefik.ingressroutetcp" (dict "Values" .Values.tcpRoute "Chart" $.Chart "Release" $.Release) }}
{{- end }}
{{ include "common.secret" (dict "Values" .Values.hostKeys "Chart" .Chart "Release" .Release) }}
{{ include "common.secret" (dict "Values" .Values.userKeys "Chart" .Chart "Release" .Release) }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "ssh-jump-host.fullname" . }}
labels:
{{- include "ssh-jump-host.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: ssh
protocol: TCP
name: ssh
selector:
{{- include "ssh-jump-host.selectorLabels" . | nindent 4 }}
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
image:
repository: lscr.io/linuxserver/openssh-server
pullPolicy: IfNotPresent
tag: "latest"
# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
imagePullSecrets: []
# This is to override the chart name.
nameOverride: ""
fullnameOverride: ""
# This is for setting Kubernetes Annotations to a Pod.
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
podAnnotations: {}
# This is for setting Kubernetes Labels to a Pod.
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
podLabels: {}
podSecurityContext:
fsGroup: 0
securityContext:
runAsUser: 0
runAsGroup: 0
# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/
service:
# This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
type: ClusterIP
# This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
port: 22
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
livenessProbe:
tcpSocket:
port: ssh
initialDelaySeconds: 20
periodSeconds: 60
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
readinessProbe:
tcpSocket:
port: ssh
initialDelaySeconds: 0
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false
# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true
nodeSelector: {}
tolerations: []
affinity: {}
loggingEnabled: false
passwordEnabled: false
sudoEnabled: false
username: jumpuser
tcpRoute: # Currently, only traefik is supported
enabled: true
name: ssh-jump-host
entryPoints:
- ssh-jump-host # must match the port name in traefik
routes:
- match: HostSNI(`*`)
services:
- name: ssh-jump-host # must be changed according to fullname
port: 22 # must match the service port
configs:
startupScripts: # This is the suggested way of linuxserver https://www.linuxserver.io/blog/2019-09-14-customizing-our-containers
name: startup-scripts
data:
include_sshd_files.sh: |
#!/bin/bash
sed -i '\|#Include /etc/ssh/sshd_config.d/\*.conf|s|^#||' /config/sshd/sshd_config
sshd:
name: sshd
data:
jump_host.conf: |
AllowTcpForwarding yes
PermitTunnel no
X11Forwarding no
PermitTTY no
GatewayPorts no
ForceCommand echo "This server is restricted to use as a jump host only."
banner.conf:
Banner /etc/ssh/ssh_banner
banner:
name: banner
data:
ssh_banner: |
####################################################
Welcome to the SSH Jump Host! Authorized users only.
####################################################
hostKeys:
name: ssh-host-keys # secret name
data: # At least one key pair MUST be added to successfully start the server
ssh_host_ecdsa_key: ''
ssh_host_ecdsa_key.pub: ''
ssh_host_ed25519_key: ''
ssh_host_ed25519_key.pub: ''
ssh_host_rsa_key: ''
ssh_host_rsa_key.pub: ''
userKeys:
name: ssh-user-keys # secret name
data: {}
# dummyUser: base64EncodedDummyUserPublicKey
name: init-scripts
data:
init_script.sh: |
#!/bin/bash
host_keys_secret_dir="/ssh_host_keys_secret"
host_keys_dir="/ssh_host_keys"
user_keys_secret_dir="/ssh_user_keys_secret"
user_keys_dir="/ssh_user_keys"
if find $host_keys_secret_dir -mindepth 1 -maxdepth 1 | read; then
cp $host_keys_secret_dir/* $host_keys_dir
chmod 600 $host_keys_dir/*
fi
if find "$user_keys_secret_dir" -mindepth 1 -maxdepth 1 | read; then
cp $user_keys_secret_dir/* $user_keys_dir
fi
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment