返回介绍

PART Ⅰ : 容器云OPENSHIFT

PART Ⅱ:容器云 KUBERNETES

PART Ⅲ:持续集成与持续部署

PART Ⅴ:日志/监控/告警

PART Ⅵ:基础

PART Ⅶ:数据存储、处理

PART VIII:CODE

PART X:HACKINTOSH

PART XI:安全

Web IDE: VSCode

发布于 2024-06-08 21:16:46 字数 4610 浏览 0 评论 0 收藏 0

一、简介

文档:https://coder.com/docs/code-server/latest

Github:https://github.com/coder/code-server

Dockerhub:https://hub.docker.com/r/codercom/code-server

二、部署

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: developer-A
  namespace: ide
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 20Gi
  storageClassName: nfs-client
---
apiVersion: v1
kind: Service
metadata:
 name: developer-A-svc
 namespace: ide
spec:
 ports:
 - port: 80
   targetPort: 8080
 selector:
   code-server: developer-A
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: developer-A-vscode-server
  namespace: ide
spec:
  rules:
  - host: developer-A.curiouser.com
    http:
      paths:
      - backend:
          serviceName: developer-A-svc
          servicePort: 80
        path: /
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    code-server: developer-A
  name: developer-A
  namespace: ide
spec:
  selector:
    matchLabels:
      code-server: developer-A
  template:
    metadata:
      labels:
        code-server: developer-A
    spec:
      volumes:
        - name: user-workspace-data
          persistentVolumeClaim:
            claimName: developer-A
      hostname: developer-A
      containers:
      - image: hub.curiouser.com/vscode-server/backend:4.16.1-ubuntu
        imagePullPolicy: IfNotPresent
        name: vscode
        ports:
        - containerPort: 8080
        env:
        - name: HASHED_PASSWORD
          value: "4972cdcd065d9df443a8422c5a899d49be5b7b1e123ca9ff0663dbc8f461bf674"
        volumeMounts:
        - name: user-workspace-data
          mountPath: /home/coder
        resources:
          limits:
            cpu: "1500m"
            memory: 4000Mi
          requests:
            cpu: "100m"
            memory: 100Mi
        livenessProbe:
          failureThreshold: 3
          initialDelaySeconds: 10
          periodSeconds: 60
          successThreshold: 1
          tcpSocket:
            port: 8080
          timeoutSeconds: 2
        readinessProbe:
          failureThreshold: 3
          initialDelaySeconds: 10
          periodSeconds: 60
          successThreshold: 1
          tcpSocket:
            port: 8080
          timeoutSeconds: 2

三、定制镜像

  • 固定开发环境
    • 统一运行时软件版本、系统版本、系统工具
    • 配置文件化、统一配置、后期自由扩展

Dockerfile

FROM codercom/code-server:4.16.1-ubuntu
ENV LANG=en_US.UTF-8 \
    LANGUAGE=en_US.UTF-8 \
    TZ=Asia/Shanghai

RUN sudo sed -i -e 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' -e 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && \
    sudo apt update && \
    sudo apt install -y pip zsh vim jq telnet && \
    sudo apt-get clean && \
    sudo rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*

ENTRYPOINT [ "/usr/bin/entrypoint.sh","--disable-telemetry","--disable-getting-started-override","--disable-file-downloads","--bind-addr","0.0.0.0:8080","."]

Makefile

IMAGE_BASE_PUSH = hub.curiouser.com/vscode-server
IMAGE_NAME = backend
IMAGE_VERSION = 4.16.1-ubuntu
all: build push
build:
        docker build --rm -f Dockerfile -t ${IMAGE_BASE_PUSH}/${IMAGE_NAME}:${IMAGE_VERSION} .
push:
        docker push ${IMAGE_BASE_PUSH}/${IMAGE_NAME}:${IMAGE_VERSION}

四、网络访问

1、VSCode内应用的访问

https://coder.com/docs/code-server/latest/guide#accessing-web-services

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文