Deploy VSCode on Kubernetes cluster

Time:2022-11-25

Deploy VSCode on Kubernetes cluster

Visual Studio Code

Visual Studio Code is a lightweight yet powerful source code editor that runs on your desktop for Windows, macOS and Linux. It has built-in support for JavaScript, TypeScript, and Node.js, and provides a rich ecosystem of extensions for other languages ​​(such as C++, C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity).

In terms of development tools, cloud IDEs are gradually gaining attention. Visual Studio Code has an official web version. Due to unstable access, it can be deployed in the local environment with the help of Code-Server.

Official address:https://vscode.dev/

traditional installation

# Install
curl -fsSL https://code-server.dev/install.sh | sh

# View configuration
cat .config/code-server/config.yaml 
bind-addr: 0.0.0.0:8080
auth: password
password: c5d4b8deec690d04e81ef0d5
cert: false

docker installation

# enable container
mkdir -p ~/.config
docker run -d --name code-server  \
-p 8080:8080   \
-v "$HOME/.config:/home/coder/.config"   \
-v "$PWD:/home/coder/project"   \
-u "$(id -u):$(id -g)"   \
-e "DOCKER_USER=$USER"  \
codercom/code-server:latest  

# View password
docker exec -it code-server  cat ~/.config/code-server/config.yaml
bind-addr: 127.0.0.1:8080
auth: password
password: cca029c905426a228d46d3ea
cert: false

Install in kubernetes mode

apiVersion: v1
kind: Namespace
metadata:
  name: code-server
---
apiVersion: v1
kind: Service
metadata:
  name: code-server
  namespace: code-server
spec:
  type: NodePort
  selector:
    app: code-server
  ports:
  - port: 80
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: code-server
  namespace: code-server
  labels:
    app: code-server
spec:
  replicas: 3
  strategy:
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: 3
    type: RollingUpdate
  selector:
    matchLabels:
      app: code-server
  template:
    metadata:
      labels:
        app: code-server
    spec:
      containers:
      - name: code-server
        image: codercom/code-server
        imagePullPolicy: IfNotPresent
        env:
        - name: PASSWORD
          value: "123123"
        resources:
          limits:
            memory: "512Mi"
            cpu: "4096m"
        ports:
        - containerPort: 8080

kubernetes mode verification test

kubectl  get svc -n code-server 
NAME          TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
code-server   NodePort   10.97.52.132   <none>        80:31274/TCP   2d21h

curl -I 192.168.1.61:31274
HTTP/1.1 302 Found
Location: ./login
Vary: Accept, Accept-Encoding
Content-Type: text/plain; charset=utf-8
Content-Length: 29
Date: Mon, 13 Jun 2022 01:11:16 GMT
Connection: keep-alive
Keep-Alive: timeout=5

about

https://www.oiox.cn/

https://www.oiox.cn/index.php…

CSDN, GitHub, Zhihu, WeChat public account, Open Source China, Sifu, Nuggets, Jianshu, Huawei Cloud, Alibaba Cloud, Tencent Cloud, Bilibili, Today’s Headlines, Sina Weibo, Personal Blog, All Network Available Search “Little Chen Yunwei”

Articles are mainly published on the WeChat public account

Recommended Today

5. “Illustrated HTTP” – RSS and Network Attacks

tjhttp 5. “Illustrated HTTP” – RSS and Network Attacks This section is about the discussion of RSS and common network attacks. RSS seems to always be considered as “why it hasn’t disappeared”, but after personal understanding and experience, I found that it is surprisingly useful. The part about network attacks sometimes becomes the test point […]