From e84d705f1162a062b280f782c0730e3e2183819e Mon Sep 17 00:00:00 2001 From: Panda <2952699675@qq.com> Date: Mon, 22 Apr 2024 13:29:15 +0800 Subject: [PATCH] =?UTF-8?q?sshd=E6=A8=A1=E6=9D=BF=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E5=9C=A8=E5=8E=9F=E6=9C=89=E7=9A=84=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E4=B8=8A=E5=8A=A0=E5=85=A5=E4=BA=86=E5=86=85=E7=BD=91?= =?UTF-8?q?=E7=A9=BF=E9=80=8F=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E7=BC=96=E5=86=99=E4=BA=86Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/ubuntu-sshd.yaml | 119 ++++++++++++++++++++++++++++++-------- 1 file changed, 94 insertions(+), 25 deletions(-) diff --git a/template/ubuntu-sshd.yaml b/template/ubuntu-sshd.yaml index d850f392..5f705895 100644 --- a/template/ubuntu-sshd.yaml +++ b/template/ubuntu-sshd.yaml @@ -3,38 +3,59 @@ kind: Template metadata: name: ubuntu-sshd spec: - title: 'docker-ubuntu-sshd' - url: 'https://github.com/takeyamajp/docker-ubuntu-sshd' - gitRepo: 'https://github.com/takeyamajp/docker-ubuntu-sshd' - author: 'Sealos' - description: 'Ubuntu image with SSH & SFTP' - readme: 'https://github.com/takeyamajp/docker-ubuntu-sshd/blob/master/README.md' - icon: 'https://avatars.githubusercontent.com/u/11237572?s=48&v=4' + title: sshd-web + url: https://github.com/PandaaKai/sshd-web + gitRepo: https://github.com/PandaaKai/sshd-web + author: Sealos + description: sshd-web + readme: https://github.com/PandaaKai/sshd-web/blob/main/README.md + icon: https://zhieasy.oss-cn-hangzhou.aliyuncs.com/zhiyilogo.jpg templateType: inline - categories: - - tool defaults: app_name: type: string value: ubuntu-sshd-${{ random(8) }} + app_host: + type: string + value: ${{ random(8) }} inputs: - IMAGE_TAG: - description: 'tag with takeyamajp/ubuntu-sshd' + PORT: + description: port type: string - default: 'ubuntu22.04' + default: "8080" required: true ROOT_PASSWORD: - description: 'root password' + description: root password type: string - default: 'root@qmywad' + default: root@sadazxc required: true --- +apiVersion: v1 +kind: ConfigMap +metadata: + name: ${{ defaults.app_name }} +data: + default: |- + server { + listen 80; + server_name _; + + location / { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://localhost:${{ inputs.PORT }}; + } + } +--- apiVersion: apps/v1 kind: Deployment metadata: name: ${{ defaults.app_name }} annotations: - originImageName: takeyamajp/ubuntu-sshd + originImageName: registry.cn-hangzhou.aliyuncs.com/pandak/ssh:latest deploy.cloud.sealos.io/minReplicas: '1' deploy.cloud.sealos.io/maxReplicas: '1' labels: @@ -46,20 +67,14 @@ spec: selector: matchLabels: app: ${{ defaults.app_name }} - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 - maxSurge: 0 template: metadata: labels: app: ${{ defaults.app_name }} spec: - automountServiceAccountToken: false containers: - - name: ubuntu-sshd - image: takeyamajp/ubuntu-sshd:${{ inputs.IMAGE_TAG }} + - name: ${{ defaults.app_name }} + image: registry.cn-hangzhou.aliyuncs.com/pandak/ssh:latest resources: requests: cpu: 100m @@ -72,11 +87,21 @@ spec: env: - name: ROOT_PASSWORD value: ${{ inputs.ROOT_PASSWORD }} + - name: WEB_PORT + value: ${{ inputs.PORT }} ports: - containerPort: 22 + name: sshd + - containerPort: 80 + name: web imagePullPolicy: Always - volumeMounts: [] - volumes: [] + volumeMounts: + - name: default + mountPath: /etc/nginx/sites-available + volumes: + - name: default + configMap: + name: ${{ defaults.app_name }} --- apiVersion: v1 kind: Service @@ -89,5 +114,49 @@ spec: ports: - port: 22 targetPort: 22 + name: sshd + - port: 80 + targetPort: 80 + name: web selector: app: ${{ defaults.app_name }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ${{ defaults.app_name }} + labels: + cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }} + cloud.sealos.io/app-deploy-manager-domain: ${{ defaults.app_host }} + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/proxy-body-size: 32m + nginx.ingress.kubernetes.io/server-snippet: | + client_header_buffer_size 64k; + large_client_header_buffers 4 128k; + nginx.ingress.kubernetes.io/ssl-redirect: 'false' + nginx.ingress.kubernetes.io/backend-protocol: HTTP + nginx.ingress.kubernetes.io/rewrite-target: /$2 + nginx.ingress.kubernetes.io/client-body-buffer-size: 64k + nginx.ingress.kubernetes.io/proxy-buffer-size: 64k + nginx.ingress.kubernetes.io/configuration-snippet: | + if ($request_uri ~* \.(js|css|gif|jpe?g|png)) { + expires 30d; + add_header Cache-Control "public"; + } +spec: + rules: + - host: ${{ defaults.app_host }}.${{ SEALOS_CLOUD_DOMAIN }} + http: + paths: + - pathType: Prefix + path: / + backend: + service: + name: ${{ defaults.app_name }} + port: + number: 80 + tls: + - hosts: + - ${{ defaults.app_host }}.${{ SEALOS_CLOUD_DOMAIN }} + secretName: ${{ SEALOS_CERT_SECRET_NAME }} \ No newline at end of file